aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/genetlink.h
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/net/genetlink.h
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'include/net/genetlink.h')
-rw-r--r--include/net/genetlink.h65
1 files changed, 44 insertions, 21 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index bdfbe68c1c3..82d8d09faa4 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -5,8 +5,6 @@
5#include <net/netlink.h> 5#include <net/netlink.h>
6#include <net/net_namespace.h> 6#include <net/net_namespace.h>
7 7
8#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN)
9
10/** 8/**
11 * struct genl_multicast_group - generic netlink multicast group 9 * struct genl_multicast_group - generic netlink multicast group
12 * @name: name of the multicast group, names are per-family 10 * @name: name of the multicast group, names are per-family
@@ -65,7 +63,7 @@ struct genl_family {
65/** 63/**
66 * struct genl_info - receiving information 64 * struct genl_info - receiving information
67 * @snd_seq: sending sequence number 65 * @snd_seq: sending sequence number
68 * @snd_portid: netlink portid of sender 66 * @snd_pid: netlink pid of sender
69 * @nlhdr: netlink message header 67 * @nlhdr: netlink message header
70 * @genlhdr: generic netlink message header 68 * @genlhdr: generic netlink message header
71 * @userhdr: user specific header 69 * @userhdr: user specific header
@@ -75,7 +73,7 @@ struct genl_family {
75 */ 73 */
76struct genl_info { 74struct genl_info {
77 u32 snd_seq; 75 u32 snd_seq;
78 u32 snd_portid; 76 u32 snd_pid;
79 struct nlmsghdr * nlhdr; 77 struct nlmsghdr * nlhdr;
80 struct genlmsghdr * genlhdr; 78 struct genlmsghdr * genlhdr;
81 void * userhdr; 79 void * userhdr;
@@ -130,11 +128,36 @@ extern int genl_register_mc_group(struct genl_family *family,
130 struct genl_multicast_group *grp); 128 struct genl_multicast_group *grp);
131extern void genl_unregister_mc_group(struct genl_family *family, 129extern void genl_unregister_mc_group(struct genl_family *family,
132 struct genl_multicast_group *grp); 130 struct genl_multicast_group *grp);
133extern void genl_notify(struct sk_buff *skb, struct net *net, u32 portid,
134 u32 group, struct nlmsghdr *nlh, gfp_t flags);
135 131
136void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, 132/**
137 struct genl_family *family, int flags, u8 cmd); 133 * genlmsg_put - Add generic netlink header to netlink message
134 * @skb: socket buffer holding the message
135 * @pid: netlink pid the message is addressed to
136 * @seq: sequence number (usually the one of the sender)
137 * @family: generic netlink family
138 * @flags netlink message flags
139 * @cmd: generic netlink command
140 *
141 * Returns pointer to user specific header
142 */
143static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
144 struct genl_family *family, int flags, u8 cmd)
145{
146 struct nlmsghdr *nlh;
147 struct genlmsghdr *hdr;
148
149 nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN +
150 family->hdrsize, flags);
151 if (nlh == NULL)
152 return NULL;
153
154 hdr = nlmsg_data(nlh);
155 hdr->cmd = cmd;
156 hdr->version = family->version;
157 hdr->reserved = 0;
158
159 return (char *) hdr + GENL_HDRLEN;
160}
138 161
139/** 162/**
140 * genlmsg_nlhdr - Obtain netlink header from user specified header 163 * genlmsg_nlhdr - Obtain netlink header from user specified header
@@ -183,7 +206,7 @@ static inline void *genlmsg_put_reply(struct sk_buff *skb,
183 struct genl_family *family, 206 struct genl_family *family,
184 int flags, u8 cmd) 207 int flags, u8 cmd)
185{ 208{
186 return genlmsg_put(skb, info->snd_portid, info->snd_seq, family, 209 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
187 flags, cmd); 210 flags, cmd);
188} 211}
189 212
@@ -212,49 +235,49 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr)
212 * genlmsg_multicast_netns - multicast a netlink message to a specific netns 235 * genlmsg_multicast_netns - multicast a netlink message to a specific netns
213 * @net: the net namespace 236 * @net: the net namespace
214 * @skb: netlink message as socket buffer 237 * @skb: netlink message as socket buffer
215 * @portid: own netlink portid to avoid sending to yourself 238 * @pid: own netlink pid to avoid sending to yourself
216 * @group: multicast group id 239 * @group: multicast group id
217 * @flags: allocation flags 240 * @flags: allocation flags
218 */ 241 */
219static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, 242static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb,
220 u32 portid, unsigned int group, gfp_t flags) 243 u32 pid, unsigned int group, gfp_t flags)
221{ 244{
222 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags); 245 return nlmsg_multicast(net->genl_sock, skb, pid, group, flags);
223} 246}
224 247
225/** 248/**
226 * genlmsg_multicast - multicast a netlink message to the default netns 249 * genlmsg_multicast - multicast a netlink message to the default netns
227 * @skb: netlink message as socket buffer 250 * @skb: netlink message as socket buffer
228 * @portid: own netlink portid to avoid sending to yourself 251 * @pid: own netlink pid to avoid sending to yourself
229 * @group: multicast group id 252 * @group: multicast group id
230 * @flags: allocation flags 253 * @flags: allocation flags
231 */ 254 */
232static inline int genlmsg_multicast(struct sk_buff *skb, u32 portid, 255static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid,
233 unsigned int group, gfp_t flags) 256 unsigned int group, gfp_t flags)
234{ 257{
235 return genlmsg_multicast_netns(&init_net, skb, portid, group, flags); 258 return genlmsg_multicast_netns(&init_net, skb, pid, group, flags);
236} 259}
237 260
238/** 261/**
239 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces 262 * genlmsg_multicast_allns - multicast a netlink message to all net namespaces
240 * @skb: netlink message as socket buffer 263 * @skb: netlink message as socket buffer
241 * @portid: own netlink portid to avoid sending to yourself 264 * @pid: own netlink pid to avoid sending to yourself
242 * @group: multicast group id 265 * @group: multicast group id
243 * @flags: allocation flags 266 * @flags: allocation flags
244 * 267 *
245 * This function must hold the RTNL or rcu_read_lock(). 268 * This function must hold the RTNL or rcu_read_lock().
246 */ 269 */
247int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, 270int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid,
248 unsigned int group, gfp_t flags); 271 unsigned int group, gfp_t flags);
249 272
250/** 273/**
251 * genlmsg_unicast - unicast a netlink message 274 * genlmsg_unicast - unicast a netlink message
252 * @skb: netlink message as socket buffer 275 * @skb: netlink message as socket buffer
253 * @portid: netlink portid of the destination socket 276 * @pid: netlink pid of the destination socket
254 */ 277 */
255static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 portid) 278static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid)
256{ 279{
257 return nlmsg_unicast(net->genl_sock, skb, portid); 280 return nlmsg_unicast(net->genl_sock, skb, pid);
258} 281}
259 282
260/** 283/**
@@ -264,7 +287,7 @@ static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 port
264 */ 287 */
265static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) 288static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
266{ 289{
267 return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid); 290 return genlmsg_unicast(genl_info_net(info), skb, info->snd_pid);
268} 291}
269 292
270/** 293/**