Lines Matching refs:nlp

114 nl_set_thread_nlp(struct thread *td, struct nlpcb *nlp)  in nl_set_thread_nlp()  argument
116 NLP_LOG(LOG_DEBUG2, nlp, "Set thread %p nlp to %p (slot %u)", td, nlp, osd_slot_id); in nl_set_thread_nlp()
117 if (osd_set(OSD_THREAD, &td->td_osd, osd_slot_id, nlp) == 0) in nl_set_thread_nlp()
121 osd_set_reserved(OSD_THREAD, &td->td_osd, osd_slot_id, rsv, nlp); in nl_set_thread_nlp()
131 struct nlpcb *nlp; in nl_port_lookup() local
133 CK_LIST_FOREACH(nlp, &V_nl_ctl.ctl_port_head, nl_port_next) { in nl_port_lookup()
134 if (nlp->nl_port == port_id) in nl_port_lookup()
135 return (nlp); in nl_port_lookup()
141 nlp_join_group(struct nlpcb *nlp, unsigned int group_id) in nlp_join_group() argument
147 if (!nlp_unconstrained_vnet(nlp)) in nlp_join_group()
150 BIT_SET(NLP_MAX_GROUPS, group_id, &nlp->nl_groups); in nlp_join_group()
154 nlp_leave_group(struct nlpcb *nlp, unsigned int group_id) in nlp_leave_group() argument
159 BIT_CLR(NLP_MAX_GROUPS, group_id, &nlp->nl_groups); in nlp_leave_group()
163 nlp_memberof_group(struct nlpcb *nlp, unsigned int group_id) in nlp_memberof_group() argument
168 return (BIT_ISSET(NLP_MAX_GROUPS, group_id, &nlp->nl_groups)); in nlp_memberof_group()
172 nlp_get_groups_compat(struct nlpcb *nlp) in nlp_get_groups_compat() argument
179 if (nlp_memberof_group(nlp, i + 1)) in nlp_get_groups_compat()
207 struct nlpcb *nlp; in nl_send_group() local
220 CK_LIST_FOREACH(nlp, &V_nl_ctl.ctl_pcb_head, nl_next) { in nl_send_group()
222 nlp->nl_socket->so_cred, nw->group.priv) == 0) && in nl_send_group()
223 nlp->nl_proto == nw->group.proto && in nl_send_group()
224 nlp_memberof_group(nlp, nw->group.id)) { in nl_send_group()
239 nlp_last = nlp; in nl_send_group()
256 struct nlpcb *nlp; in nl_clear_group() local
259 CK_LIST_FOREACH(nlp, &V_nl_ctl.ctl_pcb_head, nl_next) in nl_clear_group()
260 if (nlp_memberof_group(nlp, group)) in nl_clear_group()
261 nlp_leave_group(nlp, group); in nl_clear_group()
286 nl_bind_locked(struct nlpcb *nlp, struct sockaddr_nl *snl) in nl_bind_locked() argument
288 if (nlp->nl_bound) { in nl_bind_locked()
289 if (nlp->nl_port != snl->nl_pid) { in nl_bind_locked()
293 nlp->nl_port, snl->nl_pid); in nl_bind_locked()
301 nlp->nl_port = snl->nl_pid; in nl_bind_locked()
302 nlp->nl_bound = true; in nl_bind_locked()
303 CK_LIST_INSERT_HEAD(&V_nl_ctl.ctl_port_head, nlp, nl_port_next); in nl_bind_locked()
307 nlp_join_group(nlp, i + 1); in nl_bind_locked()
309 nlp_leave_group(nlp, i + 1); in nl_bind_locked()
318 struct nlpcb *nlp; in nl_attach() local
333 nlp = malloc(sizeof(struct nlpcb), M_PCB, M_WAITOK | M_ZERO); in nl_attach()
336 free(nlp, M_PCB); in nl_attach()
341 so->so_pcb = nlp; in nl_attach()
342 nlp->nl_socket = so; in nl_attach()
343 nlp->nl_proto = proto; in nl_attach()
344 nlp->nl_process_id = curproc->p_pid; in nl_attach()
345 nlp->nl_linux = is_linux; in nl_attach()
346 nlp->nl_unconstrained_vnet = !jailed_without_vnet(so->so_cred); in nl_attach()
347 nlp->nl_need_thread_setup = true; in nl_attach()
348 NLP_LOCK_INIT(nlp); in nl_attach()
349 refcount_init(&nlp->nl_refcount, 1); in nl_attach()
351 nlp->nl_taskqueue = taskqueue_create("netlink_socket", M_WAITOK, in nl_attach()
352 taskqueue_thread_enqueue, &nlp->nl_taskqueue); in nl_attach()
353 TASK_INIT(&nlp->nl_task, 0, nl_taskqueue_handler, nlp); in nl_attach()
354 taskqueue_start_threads(&nlp->nl_taskqueue, 1, PWAIT, in nl_attach()
355 "netlink_socket (PID %u)", nlp->nl_process_id); in nl_attach()
358 CK_LIST_INSERT_HEAD(&V_nl_ctl.ctl_pcb_head, nlp, nl_next); in nl_attach()
369 struct nlpcb *nlp = sotonlpcb(so); in nl_bind() local
381 NLP_LOCK(nlp); in nl_bind()
382 error = nl_bind_locked(nlp, snl); in nl_bind()
383 NLP_UNLOCK(nlp); in nl_bind()
393 nl_assign_port(struct nlpcb *nlp, uint32_t port_id) in nl_assign_port() argument
401 NLP_LOCK(nlp); in nl_assign_port()
402 snl.nl_groups = nlp_get_groups_compat(nlp); in nl_assign_port()
403 error = nl_bind_locked(nlp, &snl); in nl_assign_port()
404 NLP_UNLOCK(nlp); in nl_assign_port()
407 NL_LOG(LOG_DEBUG3, "socket %p, port assign: %d, error: %d", nlp->nl_socket, port_id, error); in nl_assign_port()
417 nl_autobind_port(struct nlpcb *nlp, uint32_t candidate_id) in nl_autobind_port() argument
425 NL_LOG(LOG_DEBUG3, "socket %p, trying to assign port %d", nlp->nl_socket, port_id); in nl_autobind_port()
430 error = nl_assign_port(nlp, port_id); in nl_autobind_port()
436 NL_LOG(LOG_DEBUG3, "socket %p, autobind to %d, error: %d", nlp->nl_socket, port_id, error); in nl_autobind_port()
444 struct nlpcb *nlp; in nl_connect() local
452 nlp = sotonlpcb(so); in nl_connect()
453 if (!nlp->nl_bound) { in nl_connect()
454 int error = nl_autobind_port(nlp, td->td_proc->p_pid); in nl_connect()
471 struct nlpcb *nlp; in destroy_nlpcb_epoch() local
473 nlp = __containerof(ctx, struct nlpcb, nl_epoch_ctx); in destroy_nlpcb_epoch()
475 NLP_LOCK_DESTROY(nlp); in destroy_nlpcb_epoch()
476 free(nlp, M_PCB); in destroy_nlpcb_epoch()
483 struct nlpcb *nlp; in nl_close() local
487 nlp = sotonlpcb(so); in nl_close()
490 NLP_LOCK(nlp); in nl_close()
491 bool was_bound = nlp->nl_bound; in nl_close()
492 NLP_UNLOCK(nlp); in nl_close()
495 taskqueue_drain_all(nlp->nl_taskqueue); in nl_close()
496 taskqueue_free(nlp->nl_taskqueue); in nl_close()
499 NLP_LOCK(nlp); in nl_close()
501 CK_LIST_REMOVE(nlp, nl_port_next); in nl_close()
502 NL_LOG(LOG_DEBUG3, "socket %p, unlinking bound pid %u", so, nlp->nl_port); in nl_close()
504 CK_LIST_REMOVE(nlp, nl_next); in nl_close()
505 nlp->nl_socket = NULL; in nl_close()
506 NLP_UNLOCK(nlp); in nl_close()
523 NET_EPOCH_CALL(destroy_nlpcb_epoch, &nlp->nl_epoch_ctx); in nl_close()
552 struct nlpcb *nlp = sotonlpcb(so); in nl_sosend() local
579 if (nlp->nl_linux) in nl_sosend()
612 NLP_LOCK(nlp); in nl_sosend()
613 nl_schedule_taskqueue(nlp); in nl_sosend()
614 NLP_UNLOCK(nlp); in nl_sosend()
628 nl_createcontrol(struct nlpcb *nlp) in nl_createcontrol() argument
637 .val = nlp->nl_process_id, in nl_createcontrol()
642 .val = nlp->nl_port, in nl_createcontrol()
660 struct nlpcb *nlp = sotonlpcb(so); in nl_soreceive() local
675 if (controlp != NULL && (nlp->nl_flags & NLF_MSG_INFO)) in nl_soreceive()
676 *controlp = nl_createcontrol(nlp); in nl_soreceive()
845 struct nlpcb *nlp = sotonlpcb(so); in nl_ctloutput() local
869 nlp_join_group(nlp, optval); in nl_ctloutput()
871 nlp_leave_group(nlp, optval); in nl_ctloutput()
884 if ((flag == NLF_MSG_INFO) && nlp->nl_linux) { in nl_ctloutput()
891 nlp->nl_flags |= flag; in nl_ctloutput()
893 nlp->nl_flags &= ~flag; in nl_ctloutput()
904 optval = nlp_get_groups_compat(nlp); in nl_ctloutput()
913 optval = (nlp->nl_flags & nl_getoptflag(sopt->sopt_name)) != 0; in nl_ctloutput()