Searched refs:nlk (Results 1 - 2 of 2) sorted by relevance

/linux-4.1.27/net/netlink/
H A Daf_netlink.c279 struct netlink_sock *nlk = nlk_sk(sk); netlink_overrun() local
281 if (!(nlk->flags & NETLINK_RECV_NO_ENOBUFS)) { netlink_overrun()
292 struct netlink_sock *nlk = nlk_sk(sk); netlink_rcv_wake() local
295 clear_bit(NETLINK_CONGESTED, &nlk->state); netlink_rcv_wake()
296 if (!test_bit(NETLINK_CONGESTED, &nlk->state)) netlink_rcv_wake()
297 wake_up_interruptible(&nlk->wait); netlink_rcv_wake()
352 static void **alloc_pg_vec(struct netlink_sock *nlk, alloc_pg_vec() argument
380 struct netlink_sock *nlk = nlk_sk(sk); __netlink_set_ring() local
385 ring = tx_ring ? &nlk->tx_ring : &nlk->rx_ring; __netlink_set_ring()
401 WARN_ON(atomic_read(&nlk->mapped)); __netlink_set_ring()
410 struct netlink_sock *nlk = nlk_sk(sk); netlink_set_ring() local
415 ring = tx_ring ? &nlk->tx_ring : &nlk->rx_ring; netlink_set_ring()
417 if (atomic_read(&nlk->mapped)) netlink_set_ring()
444 pg_vec = alloc_pg_vec(nlk, req, order); netlink_set_ring()
452 mutex_lock(&nlk->pg_vec_lock); netlink_set_ring()
453 if (atomic_read(&nlk->mapped) == 0) { netlink_set_ring()
455 mutex_unlock(&nlk->pg_vec_lock); netlink_set_ring()
459 mutex_unlock(&nlk->pg_vec_lock); netlink_set_ring()
496 struct netlink_sock *nlk = nlk_sk(sk); netlink_mmap() local
505 mutex_lock(&nlk->pg_vec_lock); netlink_mmap()
508 for (ring = &nlk->rx_ring; ring <= &nlk->tx_ring; ring++) { netlink_mmap()
522 for (ring = &nlk->rx_ring; ring <= &nlk->tx_ring; ring++) { netlink_mmap()
542 atomic_inc(&nlk->mapped); netlink_mmap()
546 mutex_unlock(&nlk->pg_vec_lock); netlink_mmap()
641 static bool netlink_dump_space(struct netlink_sock *nlk) netlink_dump_space() argument
643 struct netlink_ring *ring = &nlk->rx_ring; netlink_dump_space()
664 struct netlink_sock *nlk = nlk_sk(sk); netlink_poll() local
668 if (nlk->rx_ring.pg_vec != NULL) { netlink_poll()
673 while (nlk->cb_running && netlink_dump_space(nlk)) { netlink_poll()
687 if (nlk->rx_ring.pg_vec) { netlink_poll()
688 netlink_forward_ring(&nlk->rx_ring); netlink_poll()
689 if (!netlink_previous_frame(&nlk->rx_ring, NL_MMAP_STATUS_UNUSED)) netlink_poll()
695 if (nlk->tx_ring.pg_vec) { netlink_poll()
696 if (netlink_current_frame(&nlk->tx_ring, NL_MMAP_STATUS_UNUSED)) netlink_poll()
734 struct netlink_sock *nlk = nlk_sk(sk); netlink_mmap_sendmsg() local
741 mutex_lock(&nlk->pg_vec_lock); netlink_mmap_sendmsg()
743 ring = &nlk->tx_ring; netlink_mmap_sendmsg()
752 atomic_read(&nlk->tx_ring.pending)) netlink_mmap_sendmsg()
776 NETLINK_CB(skb).portid = nlk->portid; netlink_mmap_sendmsg()
799 atomic_read(&nlk->tx_ring.pending))); netlink_mmap_sendmsg()
804 mutex_unlock(&nlk->pg_vec_lock); netlink_mmap_sendmsg()
827 struct netlink_sock *nlk = nlk_sk(sk); netlink_ring_set_copied() local
828 struct netlink_ring *ring = &nlk->rx_ring; netlink_ring_set_copied()
915 struct netlink_sock *nlk = nlk_sk(sk); netlink_sock_destruct() local
917 if (nlk->cb_running) { netlink_sock_destruct()
918 if (nlk->cb.done) netlink_sock_destruct()
919 nlk->cb.done(&nlk->cb); netlink_sock_destruct()
921 module_put(nlk->cb.module); netlink_sock_destruct()
922 kfree_skb(nlk->cb.skb); netlink_sock_destruct()
931 if (nlk->rx_ring.pg_vec) netlink_sock_destruct()
934 if (nlk->tx_ring.pg_vec) netlink_sock_destruct()
1018 const struct netlink_sock *nlk = ptr; netlink_compare() local
1020 return nlk->portid != x->portid || netlink_compare()
1021 !net_eq(sock_net(&nlk->sk), read_pnet(&x->pnet)); netlink_compare()
1164 struct netlink_sock *nlk; __netlink_create() local
1174 nlk = nlk_sk(sk); __netlink_create()
1176 nlk->cb_mutex = cb_mutex; __netlink_create()
1178 nlk->cb_mutex = &nlk->cb_def_mutex; __netlink_create()
1179 mutex_init(nlk->cb_mutex); __netlink_create()
1181 init_waitqueue_head(&nlk->wait); __netlink_create()
1183 mutex_init(&nlk->pg_vec_lock); __netlink_create()
1196 struct netlink_sock *nlk; netlink_create() local
1238 nlk = nlk_sk(sock->sk); netlink_create()
1239 nlk->module = module; netlink_create()
1240 nlk->netlink_bind = bind; netlink_create()
1241 nlk->netlink_unbind = unbind; netlink_create()
1252 struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu); deferred_put_nlk_sk() local
1254 sock_put(&nlk->sk); deferred_put_nlk_sk()
1260 struct netlink_sock *nlk; netlink_release() local
1267 nlk = nlk_sk(sk); netlink_release()
1277 if (nlk->netlink_unbind) { netlink_release()
1280 for (i = 0; i < nlk->ngroups; i++) netlink_release()
1281 if (test_bit(i, nlk->groups)) netlink_release()
1282 nlk->netlink_unbind(sock_net(sk), i + 1); netlink_release()
1289 wake_up_interruptible_all(&nlk->wait); netlink_release()
1293 if (nlk->portid && nlk->bound) { netlink_release()
1297 .portid = nlk->portid, netlink_release()
1303 module_put(nlk->module); netlink_release()
1323 kfree(nlk->groups); netlink_release()
1324 nlk->groups = NULL; netlink_release()
1329 call_rcu(&nlk->rcu, deferred_put_nlk_sk); netlink_release()
1442 struct netlink_sock *nlk = nlk_sk(sk); netlink_update_subscriptions() local
1444 if (nlk->subscriptions && !subscriptions) netlink_update_subscriptions()
1446 else if (!nlk->subscriptions && subscriptions) netlink_update_subscriptions()
1448 nlk->subscriptions = subscriptions; netlink_update_subscriptions()
1453 struct netlink_sock *nlk = nlk_sk(sk); netlink_realloc_groups() local
1466 if (nlk->ngroups >= groups) netlink_realloc_groups()
1469 new_groups = krealloc(nlk->groups, NLGRPSZ(groups), GFP_ATOMIC); netlink_realloc_groups()
1474 memset((char *)new_groups + NLGRPSZ(nlk->ngroups), 0, netlink_realloc_groups()
1475 NLGRPSZ(groups) - NLGRPSZ(nlk->ngroups)); netlink_realloc_groups()
1477 nlk->groups = new_groups; netlink_realloc_groups()
1478 nlk->ngroups = groups; netlink_realloc_groups()
1487 struct netlink_sock *nlk = nlk_sk(sk); netlink_undo_bind() local
1490 if (!nlk->netlink_unbind) netlink_undo_bind()
1495 nlk->netlink_unbind(sock_net(sk), undo + 1); netlink_undo_bind()
1503 struct netlink_sock *nlk = nlk_sk(sk); netlink_bind() local
1524 bound = nlk->bound; netlink_bind()
1526 /* Ensure nlk->portid is up-to-date. */ netlink_bind()
1529 if (nladdr->nl_pid != nlk->portid) netlink_bind()
1533 if (nlk->netlink_bind && groups) { netlink_bind()
1536 for (group = 0; group < nlk->ngroups; group++) { netlink_bind()
1539 err = nlk->netlink_bind(net, group + 1); netlink_bind()
1555 netlink_undo_bind(nlk->ngroups, groups, sk); netlink_bind()
1560 if (!groups && (nlk->groups == NULL || !(u32)nlk->groups[0])) netlink_bind()
1564 netlink_update_subscriptions(sk, nlk->subscriptions + netlink_bind()
1566 hweight32(nlk->groups[0])); netlink_bind()
1567 nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | groups; netlink_bind()
1579 struct netlink_sock *nlk = nlk_sk(sk); netlink_connect() local
1587 nlk->dst_portid = 0; netlink_connect()
1588 nlk->dst_group = 0; netlink_connect()
1601 if (!nlk->bound) netlink_connect()
1606 nlk->dst_portid = nladdr->nl_pid; netlink_connect()
1607 nlk->dst_group = ffs(nladdr->nl_groups); netlink_connect()
1617 struct netlink_sock *nlk = nlk_sk(sk); netlink_getname() local
1625 nladdr->nl_pid = nlk->dst_portid; netlink_getname()
1626 nladdr->nl_groups = netlink_group_mask(nlk->dst_group); netlink_getname()
1628 nladdr->nl_pid = nlk->portid; netlink_getname()
1629 nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0; netlink_getname()
1637 struct netlink_sock *nlk; netlink_getsockbyportid() local
1644 nlk = nlk_sk(sock); netlink_getsockbyportid()
1646 nlk->dst_portid != nlk_sk(ssk)->portid) { netlink_getsockbyportid()
1707 struct netlink_sock *nlk; netlink_attachskb() local
1709 nlk = nlk_sk(sk); netlink_attachskb()
1712 test_bit(NETLINK_CONGESTED, &nlk->state)) && netlink_attachskb()
1724 add_wait_queue(&nlk->wait, &wait); netlink_attachskb()
1727 test_bit(NETLINK_CONGESTED, &nlk->state)) && netlink_attachskb()
1732 remove_wait_queue(&nlk->wait, &wait); netlink_attachskb()
1807 struct netlink_sock *nlk = nlk_sk(sk); netlink_unicast_kernel() local
1810 if (nlk->netlink_rcv != NULL) { netlink_unicast_kernel()
1815 nlk->netlink_rcv(skb); netlink_unicast_kernel()
1948 struct netlink_sock *nlk = nlk_sk(sk); netlink_broadcast_deliver() local
1951 !test_bit(NETLINK_CONGESTED, &nlk->state)) { netlink_broadcast_deliver()
1977 struct netlink_sock *nlk = nlk_sk(sk); do_one_broadcast() local
1983 if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups || do_one_broadcast()
1984 !test_bit(p->group - 1, nlk->groups)) do_one_broadcast()
2012 if (nlk->flags & NETLINK_BROADCAST_SEND_ERROR) do_one_broadcast()
2022 if (nlk->flags & NETLINK_BROADCAST_SEND_ERROR) do_one_broadcast()
2100 struct netlink_sock *nlk = nlk_sk(sk); do_one_set_err() local
2109 if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups || do_one_set_err()
2110 !test_bit(p->group - 1, nlk->groups)) do_one_set_err()
2113 if (p->code == ENOBUFS && nlk->flags & NETLINK_RECV_NO_ENOBUFS) { do_one_set_err()
2157 static void netlink_update_socket_mc(struct netlink_sock *nlk, netlink_update_socket_mc() argument
2163 old = test_bit(group - 1, nlk->groups); netlink_update_socket_mc()
2164 subscriptions = nlk->subscriptions - old + new; netlink_update_socket_mc()
2166 __set_bit(group - 1, nlk->groups); netlink_update_socket_mc()
2168 __clear_bit(group - 1, nlk->groups); netlink_update_socket_mc()
2169 netlink_update_subscriptions(&nlk->sk, subscriptions); netlink_update_socket_mc()
2170 netlink_update_listeners(&nlk->sk); netlink_update_socket_mc()
2177 struct netlink_sock *nlk = nlk_sk(sk); netlink_setsockopt() local
2192 nlk->flags |= NETLINK_RECV_PKTINFO; netlink_setsockopt()
2194 nlk->flags &= ~NETLINK_RECV_PKTINFO; netlink_setsockopt()
2204 if (!val || val - 1 >= nlk->ngroups) netlink_setsockopt()
2206 if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) { netlink_setsockopt()
2207 err = nlk->netlink_bind(sock_net(sk), val); netlink_setsockopt()
2212 netlink_update_socket_mc(nlk, val, netlink_setsockopt()
2215 if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind) netlink_setsockopt()
2216 nlk->netlink_unbind(sock_net(sk), val); netlink_setsockopt()
2223 nlk->flags |= NETLINK_BROADCAST_SEND_ERROR; netlink_setsockopt()
2225 nlk->flags &= ~NETLINK_BROADCAST_SEND_ERROR; netlink_setsockopt()
2230 nlk->flags |= NETLINK_RECV_NO_ENOBUFS; netlink_setsockopt()
2231 clear_bit(NETLINK_CONGESTED, &nlk->state); netlink_setsockopt()
2232 wake_up_interruptible(&nlk->wait); netlink_setsockopt()
2234 nlk->flags &= ~NETLINK_RECV_NO_ENOBUFS; netlink_setsockopt()
2267 struct netlink_sock *nlk = nlk_sk(sk); netlink_getsockopt() local
2283 val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0; netlink_getsockopt()
2293 val = nlk->flags & NETLINK_BROADCAST_SEND_ERROR ? 1 : 0; netlink_getsockopt()
2303 val = nlk->flags & NETLINK_RECV_NO_ENOBUFS ? 1 : 0; netlink_getsockopt()
2326 struct netlink_sock *nlk = nlk_sk(sk); netlink_sendmsg() local
2354 dst_portid = nlk->dst_portid; netlink_sendmsg()
2355 dst_group = nlk->dst_group; netlink_sendmsg()
2358 if (!nlk->bound) { netlink_sendmsg()
2363 /* Ensure nlk is hashed and visible. */ netlink_sendmsg()
2387 NETLINK_CB(skb).portid = nlk->portid; netlink_sendmsg()
2420 struct netlink_sock *nlk = nlk_sk(sk); netlink_recvmsg() local
2455 nlk->max_recvmsg_len = max(nlk->max_recvmsg_len, len); netlink_recvmsg()
2456 nlk->max_recvmsg_len = min_t(size_t, nlk->max_recvmsg_len, netlink_recvmsg()
2477 if (nlk->flags & NETLINK_RECV_PKTINFO) netlink_recvmsg()
2487 if (nlk->cb_running && netlink_recvmsg()
2519 struct netlink_sock *nlk; __netlink_kernel_create() local
2560 nlk = nlk_sk(sk); __netlink_kernel_create()
2561 nlk->flags |= NETLINK_KERNEL_SOCKET; __netlink_kernel_create()
2682 struct netlink_sock *nlk = nlk_sk(sk); netlink_dump() local
2690 mutex_lock(nlk->cb_mutex); netlink_dump()
2691 if (!nlk->cb_running) { netlink_dump()
2705 cb = &nlk->cb; netlink_dump()
2708 if (alloc_min_size < nlk->max_recvmsg_len) { netlink_dump()
2709 alloc_size = nlk->max_recvmsg_len; netlink_dump()
2710 skb = netlink_alloc_skb(sk, alloc_size, nlk->portid, netlink_dump()
2717 skb = netlink_alloc_skb(sk, alloc_size, nlk->portid, netlink_dump()
2739 mutex_unlock(nlk->cb_mutex); netlink_dump()
2764 nlk->cb_running = false; netlink_dump()
2765 mutex_unlock(nlk->cb_mutex); netlink_dump()
2771 mutex_unlock(nlk->cb_mutex); netlink_dump()
2782 struct netlink_sock *nlk; __netlink_dump_start() local
2802 nlk = nlk_sk(sk); __netlink_dump_start()
2803 mutex_lock(nlk->cb_mutex); __netlink_dump_start()
2805 if (nlk->cb_running) { __netlink_dump_start()
2815 cb = &nlk->cb; __netlink_dump_start()
2825 nlk->cb_running = true; __netlink_dump_start()
2827 mutex_unlock(nlk->cb_mutex); __netlink_dump_start()
2842 mutex_unlock(nlk->cb_mutex); __netlink_dump_start()
2996 struct netlink_sock *nlk; __netlink_seq_next() local
3002 nlk = rhashtable_walk_next(&iter->hti); __netlink_seq_next()
3004 if (IS_ERR(nlk)) { __netlink_seq_next()
3005 if (PTR_ERR(nlk) == -EAGAIN) __netlink_seq_next()
3008 return nlk; __netlink_seq_next()
3011 if (nlk) __netlink_seq_next()
3022 } while (sock_net(&nlk->sk) != seq_file_net(seq)); __netlink_seq_next()
3024 return nlk; __netlink_seq_next()
3071 struct netlink_sock *nlk = nlk_sk(s); netlink_seq_show() local
3076 nlk->portid, netlink_seq_show()
3077 nlk->groups ? (u32)nlk->groups[0] : 0, netlink_seq_show()
3080 nlk->cb_running, netlink_seq_show()
3196 const struct netlink_sock *nlk = data; netlink_hash() local
3199 netlink_compare_arg_init(&arg, sock_net(&nlk->sk), nlk->portid); netlink_hash()
H A Ddiag.c27 struct netlink_sock *nlk = nlk_sk(sk); sk_diag_put_rings_cfg() local
30 mutex_lock(&nlk->pg_vec_lock); sk_diag_put_rings_cfg()
31 ret = sk_diag_put_ring(&nlk->rx_ring, NETLINK_DIAG_RX_RING, nlskb); sk_diag_put_rings_cfg()
33 ret = sk_diag_put_ring(&nlk->tx_ring, NETLINK_DIAG_TX_RING, sk_diag_put_rings_cfg()
35 mutex_unlock(&nlk->pg_vec_lock); sk_diag_put_rings_cfg()
48 struct netlink_sock *nlk = nlk_sk(sk); sk_diag_dump_groups() local
50 if (nlk->groups == NULL) sk_diag_dump_groups()
53 return nla_put(nlskb, NETLINK_DIAG_GROUPS, NLGRPSZ(nlk->ngroups), sk_diag_dump_groups()
54 nlk->groups); sk_diag_dump_groups()
63 struct netlink_sock *nlk = nlk_sk(sk); sk_diag_fill() local
77 rep->ndiag_portid = nlk->portid; sk_diag_fill()
78 rep->ndiag_dst_portid = nlk->dst_portid; sk_diag_fill()
79 rep->ndiag_dst_group = nlk->dst_group; sk_diag_fill()

Completed in 82 milliseconds