diff options
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index a5bd63ca86bc..4ce7dcbcb6ef 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -92,6 +92,11 @@ static inline struct netlink_sock *nlk_sk(struct sock *sk) | |||
92 | return container_of(sk, struct netlink_sock, sk); | 92 | return container_of(sk, struct netlink_sock, sk); |
93 | } | 93 | } |
94 | 94 | ||
95 | static inline int netlink_is_kernel(struct sock *sk) | ||
96 | { | ||
97 | return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; | ||
98 | } | ||
99 | |||
95 | struct nl_pid_hash { | 100 | struct nl_pid_hash { |
96 | struct hlist_head *table; | 101 | struct hlist_head *table; |
97 | unsigned long rehash_time; | 102 | unsigned long rehash_time; |
@@ -489,7 +494,7 @@ static int netlink_release(struct socket *sock) | |||
489 | module_put(nlk->module); | 494 | module_put(nlk->module); |
490 | 495 | ||
491 | netlink_table_grab(); | 496 | netlink_table_grab(); |
492 | if (nlk->flags & NETLINK_KERNEL_SOCKET) { | 497 | if (netlink_is_kernel(sk)) { |
493 | kfree(nl_table[sk->sk_protocol].listeners); | 498 | kfree(nl_table[sk->sk_protocol].listeners); |
494 | nl_table[sk->sk_protocol].module = NULL; | 499 | nl_table[sk->sk_protocol].module = NULL; |
495 | nl_table[sk->sk_protocol].registered = 0; | 500 | nl_table[sk->sk_protocol].registered = 0; |
@@ -716,7 +721,7 @@ static struct sock *netlink_getsockbypid(struct sock *ssk, u32 pid) | |||
716 | 721 | ||
717 | /* Don't bother queuing skb if kernel socket has no input function */ | 722 | /* Don't bother queuing skb if kernel socket has no input function */ |
718 | nlk = nlk_sk(sock); | 723 | nlk = nlk_sk(sock); |
719 | if ((nlk->pid == 0 && !nlk->data_ready) || | 724 | if ((netlink_is_kernel(sock) && !nlk->data_ready) || |
720 | (sock->sk_state == NETLINK_CONNECTED && | 725 | (sock->sk_state == NETLINK_CONNECTED && |
721 | nlk->dst_pid != nlk_sk(ssk)->pid)) { | 726 | nlk->dst_pid != nlk_sk(ssk)->pid)) { |
722 | sock_put(sock); | 727 | sock_put(sock); |
@@ -762,7 +767,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, | |||
762 | test_bit(0, &nlk->state)) { | 767 | test_bit(0, &nlk->state)) { |
763 | DECLARE_WAITQUEUE(wait, current); | 768 | DECLARE_WAITQUEUE(wait, current); |
764 | if (!timeo) { | 769 | if (!timeo) { |
765 | if (!ssk || nlk_sk(ssk)->pid == 0) | 770 | if (!ssk || netlink_is_kernel(ssk)) |
766 | netlink_overrun(sk); | 771 | netlink_overrun(sk); |
767 | sock_put(sk); | 772 | sock_put(sk); |
768 | kfree_skb(skb); | 773 | kfree_skb(skb); |
@@ -861,7 +866,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group) | |||
861 | int res = 0; | 866 | int res = 0; |
862 | unsigned long *listeners; | 867 | unsigned long *listeners; |
863 | 868 | ||
864 | BUG_ON(!(nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET)); | 869 | BUG_ON(!netlink_is_kernel(sk)); |
865 | 870 | ||
866 | rcu_read_lock(); | 871 | rcu_read_lock(); |
867 | listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners); | 872 | listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners); |