netlink: don't store an extra pointer to so_cred

This commit is contained in:
Gleb Smirnoff 2025-02-04 16:36:14 -08:00
parent 164dec88e8
commit ef3991d70d
3 changed files with 2 additions and 5 deletions

View file

@ -328,8 +328,6 @@ nl_attach(struct socket *so, int proto, struct thread *td)
TAILQ_INIT(&so->so_snd.nl_queue);
so->so_pcb = nlp;
nlp->nl_socket = so;
/* Copy so_cred to avoid having socket_var.h in every header */
nlp->nl_cred = so->so_cred;
nlp->nl_proto = proto;
nlp->nl_process_id = curproc->p_pid;
nlp->nl_linux = is_linux;

View file

@ -85,13 +85,13 @@ struct rtbridge *netlink_callback_p = &ignore_cb;
bool
nlp_has_priv(struct nlpcb *nlp, int priv)
{
return (priv_check_cred(nlp->nl_cred, priv) == 0);
return (priv_check_cred(nlp->nl_socket->so_cred, priv) == 0);
}
struct ucred *
nlp_get_cred(struct nlpcb *nlp)
{
return (nlp->nl_cred);
return (nlp->nl_socket->so_cred);
}
uint32_t

View file

@ -69,7 +69,6 @@ struct nlpcb {
bool nl_need_thread_setup;
struct taskqueue *nl_taskqueue;
struct task nl_task;
struct ucred *nl_cred; /* Copy of nl_socket->so_cred */
uint64_t nl_dropped_bytes;
uint64_t nl_dropped_messages;
CK_LIST_ENTRY(nlpcb) nl_next;