diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 13:37:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-14 13:37:28 -0400 |
commit | d7e9660ad9d5e0845f52848bce31bcf5cdcdea6b (patch) | |
tree | c6c67d145771187b194d79d603742b31090a59d6 /include/net/genetlink.h | |
parent | b8cb48aae1b8c50b37dcb7710363aa69a7a0d9ca (diff) | |
parent | 13af7a6ea502fcdd4c0e3d7de6e332b102309491 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1623 commits)
netxen: update copyright
netxen: fix tx timeout recovery
netxen: fix file firmware leak
netxen: improve pci memory access
netxen: change firmware write size
tg3: Fix return ring size breakage
netxen: build fix for INET=n
cdc-phonet: autoconfigure Phonet address
Phonet: back-end for autoconfigured addresses
Phonet: fix netlink address dump error handling
ipv6: Add IFA_F_DADFAILED flag
net: Add DEVTYPE support for Ethernet based devices
mv643xx_eth.c: remove unused txq_set_wrr()
ucc_geth: Fix hangs after switching from full to half duplex
ucc_geth: Rearrange some code to avoid forward declarations
phy/marvell: Make non-aneg speed/duplex forcing work for 88E1111 PHYs
drivers/net/phy: introduce missing kfree
drivers/net/wan: introduce missing kfree
net: force bridge module(s) to be GPL
Subject: [PATCH] appletalk: Fix skb leak when ipddp interface is not loaded
...
Fixed up trivial conflicts:
- arch/x86/include/asm/socket.h
converted to <asm-generic/socket.h> in the x86 tree. The generic
header has the same new #define's, so that works out fine.
- drivers/net/tun.c
fix conflict between 89f56d1e9 ("tun: reuse struct sock fields") that
switched over to using 'tun->socket.sk' instead of the redundantly
available (and thus removed) 'tun->sk', and 2b980dbd ("lsm: Add hooks
to the TUN driver") which added a new 'tun->sk' use.
Noted in 'next' by Stephen Rothwell.
Diffstat (limited to 'include/net/genetlink.h')
-rw-r--r-- | include/net/genetlink.h | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 1b0e3ee4ddd8..2a1c06874c42 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/genetlink.h> | 4 | #include <linux/genetlink.h> |
5 | #include <net/netlink.h> | 5 | #include <net/netlink.h> |
6 | #include <net/net_namespace.h> | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * struct genl_multicast_group - generic netlink multicast group | 9 | * struct genl_multicast_group - generic netlink multicast group |
@@ -27,6 +28,8 @@ struct genl_multicast_group | |||
27 | * @name: name of family | 28 | * @name: name of family |
28 | * @version: protocol version | 29 | * @version: protocol version |
29 | * @maxattr: maximum number of attributes supported | 30 | * @maxattr: maximum number of attributes supported |
31 | * @netnsok: set to true if the family can handle network | ||
32 | * namespaces and should be presented in all of them | ||
30 | * @attrbuf: buffer to store parsed attributes | 33 | * @attrbuf: buffer to store parsed attributes |
31 | * @ops_list: list of all assigned operations | 34 | * @ops_list: list of all assigned operations |
32 | * @family_list: family list | 35 | * @family_list: family list |
@@ -39,6 +42,7 @@ struct genl_family | |||
39 | char name[GENL_NAMSIZ]; | 42 | char name[GENL_NAMSIZ]; |
40 | unsigned int version; | 43 | unsigned int version; |
41 | unsigned int maxattr; | 44 | unsigned int maxattr; |
45 | bool netnsok; | ||
42 | struct nlattr ** attrbuf; /* private */ | 46 | struct nlattr ** attrbuf; /* private */ |
43 | struct list_head ops_list; /* private */ | 47 | struct list_head ops_list; /* private */ |
44 | struct list_head family_list; /* private */ | 48 | struct list_head family_list; /* private */ |
@@ -62,8 +66,32 @@ struct genl_info | |||
62 | struct genlmsghdr * genlhdr; | 66 | struct genlmsghdr * genlhdr; |
63 | void * userhdr; | 67 | void * userhdr; |
64 | struct nlattr ** attrs; | 68 | struct nlattr ** attrs; |
69 | #ifdef CONFIG_NET_NS | ||
70 | struct net * _net; | ||
71 | #endif | ||
65 | }; | 72 | }; |
66 | 73 | ||
74 | #ifdef CONFIG_NET_NS | ||
75 | static inline struct net *genl_info_net(struct genl_info *info) | ||
76 | { | ||
77 | return info->_net; | ||
78 | } | ||
79 | |||
80 | static inline void genl_info_net_set(struct genl_info *info, struct net *net) | ||
81 | { | ||
82 | info->_net = net; | ||
83 | } | ||
84 | #else | ||
85 | static inline struct net *genl_info_net(struct genl_info *info) | ||
86 | { | ||
87 | return &init_net; | ||
88 | } | ||
89 | |||
90 | static inline void genl_info_net_set(struct genl_info *info, struct net *net) | ||
91 | { | ||
92 | } | ||
93 | #endif | ||
94 | |||
67 | /** | 95 | /** |
68 | * struct genl_ops - generic netlink operations | 96 | * struct genl_ops - generic netlink operations |
69 | * @cmd: command identifier | 97 | * @cmd: command identifier |
@@ -98,8 +126,6 @@ extern int genl_register_mc_group(struct genl_family *family, | |||
98 | extern void genl_unregister_mc_group(struct genl_family *family, | 126 | extern void genl_unregister_mc_group(struct genl_family *family, |
99 | struct genl_multicast_group *grp); | 127 | struct genl_multicast_group *grp); |
100 | 128 | ||
101 | extern struct sock *genl_sock; | ||
102 | |||
103 | /** | 129 | /** |
104 | * genlmsg_put - Add generic netlink header to netlink message | 130 | * genlmsg_put - Add generic netlink header to netlink message |
105 | * @skb: socket buffer holding the message | 131 | * @skb: socket buffer holding the message |
@@ -170,7 +196,21 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) | |||
170 | } | 196 | } |
171 | 197 | ||
172 | /** | 198 | /** |
173 | * genlmsg_multicast - multicast a netlink message | 199 | * genlmsg_multicast_netns - multicast a netlink message to a specific netns |
200 | * @net: the net namespace | ||
201 | * @skb: netlink message as socket buffer | ||
202 | * @pid: own netlink pid to avoid sending to yourself | ||
203 | * @group: multicast group id | ||
204 | * @flags: allocation flags | ||
205 | */ | ||
206 | static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, | ||
207 | u32 pid, unsigned int group, gfp_t flags) | ||
208 | { | ||
209 | return nlmsg_multicast(net->genl_sock, skb, pid, group, flags); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * genlmsg_multicast - multicast a netlink message to the default netns | ||
174 | * @skb: netlink message as socket buffer | 214 | * @skb: netlink message as socket buffer |
175 | * @pid: own netlink pid to avoid sending to yourself | 215 | * @pid: own netlink pid to avoid sending to yourself |
176 | * @group: multicast group id | 216 | * @group: multicast group id |
@@ -179,17 +219,29 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) | |||
179 | static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid, | 219 | static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid, |
180 | unsigned int group, gfp_t flags) | 220 | unsigned int group, gfp_t flags) |
181 | { | 221 | { |
182 | return nlmsg_multicast(genl_sock, skb, pid, group, flags); | 222 | return genlmsg_multicast_netns(&init_net, skb, pid, group, flags); |
183 | } | 223 | } |
184 | 224 | ||
185 | /** | 225 | /** |
226 | * genlmsg_multicast_allns - multicast a netlink message to all net namespaces | ||
227 | * @skb: netlink message as socket buffer | ||
228 | * @pid: own netlink pid to avoid sending to yourself | ||
229 | * @group: multicast group id | ||
230 | * @flags: allocation flags | ||
231 | * | ||
232 | * This function must hold the RTNL or rcu_read_lock(). | ||
233 | */ | ||
234 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, | ||
235 | unsigned int group, gfp_t flags); | ||
236 | |||
237 | /** | ||
186 | * genlmsg_unicast - unicast a netlink message | 238 | * genlmsg_unicast - unicast a netlink message |
187 | * @skb: netlink message as socket buffer | 239 | * @skb: netlink message as socket buffer |
188 | * @pid: netlink pid of the destination socket | 240 | * @pid: netlink pid of the destination socket |
189 | */ | 241 | */ |
190 | static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid) | 242 | static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid) |
191 | { | 243 | { |
192 | return nlmsg_unicast(genl_sock, skb, pid); | 244 | return nlmsg_unicast(net->genl_sock, skb, pid); |
193 | } | 245 | } |
194 | 246 | ||
195 | /** | 247 | /** |
@@ -199,7 +251,7 @@ static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid) | |||
199 | */ | 251 | */ |
200 | static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) | 252 | static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) |
201 | { | 253 | { |
202 | return genlmsg_unicast(skb, info->snd_pid); | 254 | return genlmsg_unicast(genl_info_net(info), skb, info->snd_pid); |
203 | } | 255 | } |
204 | 256 | ||
205 | /** | 257 | /** |