aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/genetlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r--net/netlink/genetlink.c56
1 files changed, 20 insertions, 36 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 95391e609046..1b897bc92e61 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -295,60 +295,49 @@ int genl_unregister_family(struct genl_family *family)
295 return -ENOENT; 295 return -ENOENT;
296} 296}
297 297
298static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, 298static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
299 int *errp)
300{ 299{
301 struct genl_ops *ops; 300 struct genl_ops *ops;
302 struct genl_family *family; 301 struct genl_family *family;
303 struct genl_info info; 302 struct genl_info info;
304 struct genlmsghdr *hdr = nlmsg_data(nlh); 303 struct genlmsghdr *hdr = nlmsg_data(nlh);
305 int hdrlen, err = -EINVAL; 304 int hdrlen, err;
306 305
307 family = genl_family_find_byid(nlh->nlmsg_type); 306 family = genl_family_find_byid(nlh->nlmsg_type);
308 if (family == NULL) { 307 if (family == NULL)
309 err = -ENOENT; 308 return -ENOENT;
310 goto errout;
311 }
312 309
313 hdrlen = GENL_HDRLEN + family->hdrsize; 310 hdrlen = GENL_HDRLEN + family->hdrsize;
314 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) 311 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
315 goto errout; 312 return -EINVAL;
316 313
317 ops = genl_get_cmd(hdr->cmd, family); 314 ops = genl_get_cmd(hdr->cmd, family);
318 if (ops == NULL) { 315 if (ops == NULL)
319 err = -EOPNOTSUPP; 316 return -EOPNOTSUPP;
320 goto errout;
321 }
322 317
323 if ((ops->flags & GENL_ADMIN_PERM) && security_netlink_recv(skb, CAP_NET_ADMIN)) { 318 if ((ops->flags & GENL_ADMIN_PERM) &&
324 err = -EPERM; 319 security_netlink_recv(skb, CAP_NET_ADMIN))
325 goto errout; 320 return -EPERM;
326 }
327 321
328 if (nlh->nlmsg_flags & NLM_F_DUMP) { 322 if (nlh->nlmsg_flags & NLM_F_DUMP) {
329 if (ops->dumpit == NULL) { 323 if (ops->dumpit == NULL)
330 err = -EOPNOTSUPP; 324 return -EOPNOTSUPP;
331 goto errout;
332 }
333 325
334 *errp = err = netlink_dump_start(genl_sock, skb, nlh, 326 err = netlink_dump_start(genl_sock, skb, nlh,
335 ops->dumpit, ops->done); 327 ops->dumpit, ops->done);
336 if (err == 0) 328 if (err == 0)
337 skb_pull(skb, min(NLMSG_ALIGN(nlh->nlmsg_len), 329 err = -EINTR;
338 skb->len)); 330 return err;
339 return -1;
340 } 331 }
341 332
342 if (ops->doit == NULL) { 333 if (ops->doit == NULL)
343 err = -EOPNOTSUPP; 334 return -EOPNOTSUPP;
344 goto errout;
345 }
346 335
347 if (family->attrbuf) { 336 if (family->attrbuf) {
348 err = nlmsg_parse(nlh, hdrlen, family->attrbuf, family->maxattr, 337 err = nlmsg_parse(nlh, hdrlen, family->attrbuf, family->maxattr,
349 ops->policy); 338 ops->policy);
350 if (err < 0) 339 if (err < 0)
351 goto errout; 340 return err;
352 } 341 }
353 342
354 info.snd_seq = nlh->nlmsg_seq; 343 info.snd_seq = nlh->nlmsg_seq;
@@ -358,12 +347,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
358 info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; 347 info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
359 info.attrs = family->attrbuf; 348 info.attrs = family->attrbuf;
360 349
361 *errp = err = ops->doit(skb, &info); 350 return ops->doit(skb, &info);
362 return err;
363
364errout:
365 *errp = err;
366 return -1;
367} 351}
368 352
369static void genl_rcv(struct sock *sk, int len) 353static void genl_rcv(struct sock *sk, int len)