diff options
author | Andrey Vagin <avagin@openvz.org> | 2013-03-21 12:33:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-21 12:38:02 -0400 |
commit | 0f29c768646809264d603574b4a1b15d2ff7ad79 (patch) | |
tree | fd0fdab9a15804cedb8f300a99889dfc9b6ac1a5 /net/netlink/af_netlink.c | |
parent | 953d276847b92524b34df8598bdaf30c9002c2b4 (diff) |
net: prepare netlink code for netlink diag
Move a few declarations in a header.
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>
Cc: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 59 |
1 files changed, 5 insertions, 54 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 1e3fd5bfcd86..a500ce201438 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -61,28 +61,7 @@ | |||
61 | #include <net/scm.h> | 61 | #include <net/scm.h> |
62 | #include <net/netlink.h> | 62 | #include <net/netlink.h> |
63 | 63 | ||
64 | #define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) | 64 | #include "af_netlink.h" |
65 | #define NLGRPLONGS(x) (NLGRPSZ(x)/sizeof(unsigned long)) | ||
66 | |||
67 | struct netlink_sock { | ||
68 | /* struct sock has to be the first member of netlink_sock */ | ||
69 | struct sock sk; | ||
70 | u32 portid; | ||
71 | u32 dst_portid; | ||
72 | u32 dst_group; | ||
73 | u32 flags; | ||
74 | u32 subscriptions; | ||
75 | u32 ngroups; | ||
76 | unsigned long *groups; | ||
77 | unsigned long state; | ||
78 | wait_queue_head_t wait; | ||
79 | struct netlink_callback *cb; | ||
80 | struct mutex *cb_mutex; | ||
81 | struct mutex cb_def_mutex; | ||
82 | void (*netlink_rcv)(struct sk_buff *skb); | ||
83 | void (*netlink_bind)(int group); | ||
84 | struct module *module; | ||
85 | }; | ||
86 | 65 | ||
87 | struct listeners { | 66 | struct listeners { |
88 | struct rcu_head rcu; | 67 | struct rcu_head rcu; |
@@ -94,48 +73,20 @@ struct listeners { | |||
94 | #define NETLINK_BROADCAST_SEND_ERROR 0x4 | 73 | #define NETLINK_BROADCAST_SEND_ERROR 0x4 |
95 | #define NETLINK_RECV_NO_ENOBUFS 0x8 | 74 | #define NETLINK_RECV_NO_ENOBUFS 0x8 |
96 | 75 | ||
97 | static inline struct netlink_sock *nlk_sk(struct sock *sk) | ||
98 | { | ||
99 | return container_of(sk, struct netlink_sock, sk); | ||
100 | } | ||
101 | |||
102 | static inline int netlink_is_kernel(struct sock *sk) | 76 | static inline int netlink_is_kernel(struct sock *sk) |
103 | { | 77 | { |
104 | return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; | 78 | return nlk_sk(sk)->flags & NETLINK_KERNEL_SOCKET; |
105 | } | 79 | } |
106 | 80 | ||
107 | struct nl_portid_hash { | 81 | struct netlink_table *nl_table; |
108 | struct hlist_head *table; | 82 | EXPORT_SYMBOL_GPL(nl_table); |
109 | unsigned long rehash_time; | ||
110 | |||
111 | unsigned int mask; | ||
112 | unsigned int shift; | ||
113 | |||
114 | unsigned int entries; | ||
115 | unsigned int max_shift; | ||
116 | |||
117 | u32 rnd; | ||
118 | }; | ||
119 | |||
120 | struct netlink_table { | ||
121 | struct nl_portid_hash hash; | ||
122 | struct hlist_head mc_list; | ||
123 | struct listeners __rcu *listeners; | ||
124 | unsigned int flags; | ||
125 | unsigned int groups; | ||
126 | struct mutex *cb_mutex; | ||
127 | struct module *module; | ||
128 | void (*bind)(int group); | ||
129 | int registered; | ||
130 | }; | ||
131 | |||
132 | static struct netlink_table *nl_table; | ||
133 | 83 | ||
134 | static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); | 84 | static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait); |
135 | 85 | ||
136 | static int netlink_dump(struct sock *sk); | 86 | static int netlink_dump(struct sock *sk); |
137 | 87 | ||
138 | static DEFINE_RWLOCK(nl_table_lock); | 88 | DEFINE_RWLOCK(nl_table_lock); |
89 | EXPORT_SYMBOL_GPL(nl_table_lock); | ||
139 | static atomic_t nl_table_users = ATOMIC_INIT(0); | 90 | static atomic_t nl_table_users = ATOMIC_INIT(0); |
140 | 91 | ||
141 | #define nl_deref_protected(X) rcu_dereference_protected(X, lockdep_is_held(&nl_table_lock)); | 92 | #define nl_deref_protected(X) rcu_dereference_protected(X, lockdep_is_held(&nl_table_lock)); |