diff options
author | Denis V. Lunev <den@openvz.org> | 2007-10-11 00:14:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-10-11 00:14:32 -0400 |
commit | aed815601f3f95281ab3a01f7e2cbe1bd54285a0 (patch) | |
tree | 9aa4d01bcb33ca319a5d13db1bf1e5c4549d64cc /net/netlink | |
parent | 7ee015e0fa3c856416e9477aac4b850ec6f09017 (diff) |
[NET]: unify netlink kernel socket recognition
There are currently two ways to determine whether the netlink socket is a
kernel one or a user one. This patch creates a single inline call for
this purpose and unifies all the calls in the af_netlink.c
No similar calls are found outside af_netlink.c.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Acked-by: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-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); |