diff options
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r-- | net/netlink/genetlink.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index fda497412fc3..f2aabb6f4105 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -501,7 +501,7 @@ EXPORT_SYMBOL(genl_unregister_family); | |||
501 | /** | 501 | /** |
502 | * genlmsg_put - Add generic netlink header to netlink message | 502 | * genlmsg_put - Add generic netlink header to netlink message |
503 | * @skb: socket buffer holding the message | 503 | * @skb: socket buffer holding the message |
504 | * @pid: netlink pid the message is addressed to | 504 | * @portid: netlink portid the message is addressed to |
505 | * @seq: sequence number (usually the one of the sender) | 505 | * @seq: sequence number (usually the one of the sender) |
506 | * @family: generic netlink family | 506 | * @family: generic netlink family |
507 | * @flags: netlink message flags | 507 | * @flags: netlink message flags |
@@ -509,13 +509,13 @@ EXPORT_SYMBOL(genl_unregister_family); | |||
509 | * | 509 | * |
510 | * Returns pointer to user specific header | 510 | * Returns pointer to user specific header |
511 | */ | 511 | */ |
512 | void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | 512 | void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, |
513 | struct genl_family *family, int flags, u8 cmd) | 513 | struct genl_family *family, int flags, u8 cmd) |
514 | { | 514 | { |
515 | struct nlmsghdr *nlh; | 515 | struct nlmsghdr *nlh; |
516 | struct genlmsghdr *hdr; | 516 | struct genlmsghdr *hdr; |
517 | 517 | ||
518 | nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + | 518 | nlh = nlmsg_put(skb, portid, seq, family->id, GENL_HDRLEN + |
519 | family->hdrsize, flags); | 519 | family->hdrsize, flags); |
520 | if (nlh == NULL) | 520 | if (nlh == NULL) |
521 | return NULL; | 521 | return NULL; |
@@ -585,7 +585,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
585 | } | 585 | } |
586 | 586 | ||
587 | info.snd_seq = nlh->nlmsg_seq; | 587 | info.snd_seq = nlh->nlmsg_seq; |
588 | info.snd_pid = NETLINK_CB(skb).pid; | 588 | info.snd_portid = NETLINK_CB(skb).portid; |
589 | info.nlhdr = nlh; | 589 | info.nlhdr = nlh; |
590 | info.genlhdr = nlmsg_data(nlh); | 590 | info.genlhdr = nlmsg_data(nlh); |
591 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; | 591 | info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; |
@@ -626,12 +626,12 @@ static struct genl_family genl_ctrl = { | |||
626 | .netnsok = true, | 626 | .netnsok = true, |
627 | }; | 627 | }; |
628 | 628 | ||
629 | static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, | 629 | static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq, |
630 | u32 flags, struct sk_buff *skb, u8 cmd) | 630 | u32 flags, struct sk_buff *skb, u8 cmd) |
631 | { | 631 | { |
632 | void *hdr; | 632 | void *hdr; |
633 | 633 | ||
634 | hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd); | 634 | hdr = genlmsg_put(skb, portid, seq, &genl_ctrl, flags, cmd); |
635 | if (hdr == NULL) | 635 | if (hdr == NULL) |
636 | return -1; | 636 | return -1; |
637 | 637 | ||
@@ -701,7 +701,7 @@ nla_put_failure: | |||
701 | return -EMSGSIZE; | 701 | return -EMSGSIZE; |
702 | } | 702 | } |
703 | 703 | ||
704 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | 704 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 portid, |
705 | u32 seq, u32 flags, struct sk_buff *skb, | 705 | u32 seq, u32 flags, struct sk_buff *skb, |
706 | u8 cmd) | 706 | u8 cmd) |
707 | { | 707 | { |
@@ -709,7 +709,7 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | |||
709 | struct nlattr *nla_grps; | 709 | struct nlattr *nla_grps; |
710 | struct nlattr *nest; | 710 | struct nlattr *nest; |
711 | 711 | ||
712 | hdr = genlmsg_put(skb, pid, seq, &genl_ctrl, flags, cmd); | 712 | hdr = genlmsg_put(skb, portid, seq, &genl_ctrl, flags, cmd); |
713 | if (hdr == NULL) | 713 | if (hdr == NULL) |
714 | return -1; | 714 | return -1; |
715 | 715 | ||
@@ -756,7 +756,7 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | |||
756 | continue; | 756 | continue; |
757 | if (++n < fams_to_skip) | 757 | if (++n < fams_to_skip) |
758 | continue; | 758 | continue; |
759 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).pid, | 759 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid, |
760 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 760 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
761 | skb, CTRL_CMD_NEWFAMILY) < 0) | 761 | skb, CTRL_CMD_NEWFAMILY) < 0) |
762 | goto errout; | 762 | goto errout; |
@@ -773,7 +773,7 @@ errout: | |||
773 | } | 773 | } |
774 | 774 | ||
775 | static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | 775 | static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, |
776 | u32 pid, int seq, u8 cmd) | 776 | u32 portid, int seq, u8 cmd) |
777 | { | 777 | { |
778 | struct sk_buff *skb; | 778 | struct sk_buff *skb; |
779 | int err; | 779 | int err; |
@@ -782,7 +782,7 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | |||
782 | if (skb == NULL) | 782 | if (skb == NULL) |
783 | return ERR_PTR(-ENOBUFS); | 783 | return ERR_PTR(-ENOBUFS); |
784 | 784 | ||
785 | err = ctrl_fill_info(family, pid, seq, 0, skb, cmd); | 785 | err = ctrl_fill_info(family, portid, seq, 0, skb, cmd); |
786 | if (err < 0) { | 786 | if (err < 0) { |
787 | nlmsg_free(skb); | 787 | nlmsg_free(skb); |
788 | return ERR_PTR(err); | 788 | return ERR_PTR(err); |
@@ -792,7 +792,7 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | |||
792 | } | 792 | } |
793 | 793 | ||
794 | static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, | 794 | static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, |
795 | u32 pid, int seq, u8 cmd) | 795 | u32 portid, int seq, u8 cmd) |
796 | { | 796 | { |
797 | struct sk_buff *skb; | 797 | struct sk_buff *skb; |
798 | int err; | 798 | int err; |
@@ -801,7 +801,7 @@ static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, | |||
801 | if (skb == NULL) | 801 | if (skb == NULL) |
802 | return ERR_PTR(-ENOBUFS); | 802 | return ERR_PTR(-ENOBUFS); |
803 | 803 | ||
804 | err = ctrl_fill_mcgrp_info(grp, pid, seq, 0, skb, cmd); | 804 | err = ctrl_fill_mcgrp_info(grp, portid, seq, 0, skb, cmd); |
805 | if (err < 0) { | 805 | if (err < 0) { |
806 | nlmsg_free(skb); | 806 | nlmsg_free(skb); |
807 | return ERR_PTR(err); | 807 | return ERR_PTR(err); |
@@ -853,7 +853,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) | |||
853 | return -ENOENT; | 853 | return -ENOENT; |
854 | } | 854 | } |
855 | 855 | ||
856 | msg = ctrl_build_family_msg(res, info->snd_pid, info->snd_seq, | 856 | msg = ctrl_build_family_msg(res, info->snd_portid, info->snd_seq, |
857 | CTRL_CMD_NEWFAMILY); | 857 | CTRL_CMD_NEWFAMILY); |
858 | if (IS_ERR(msg)) | 858 | if (IS_ERR(msg)) |
859 | return PTR_ERR(msg); | 859 | return PTR_ERR(msg); |
@@ -918,11 +918,11 @@ static int __net_init genl_pernet_init(struct net *net) | |||
918 | struct netlink_kernel_cfg cfg = { | 918 | struct netlink_kernel_cfg cfg = { |
919 | .input = genl_rcv, | 919 | .input = genl_rcv, |
920 | .cb_mutex = &genl_mutex, | 920 | .cb_mutex = &genl_mutex, |
921 | .flags = NL_CFG_F_NONROOT_RECV, | ||
921 | }; | 922 | }; |
922 | 923 | ||
923 | /* we'll bump the group number right afterwards */ | 924 | /* we'll bump the group number right afterwards */ |
924 | net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, | 925 | net->genl_sock = netlink_kernel_create(net, NETLINK_GENERIC, &cfg); |
925 | THIS_MODULE, &cfg); | ||
926 | 926 | ||
927 | if (!net->genl_sock && net_eq(net, &init_net)) | 927 | if (!net->genl_sock && net_eq(net, &init_net)) |
928 | panic("GENL: Cannot initialize generic netlink\n"); | 928 | panic("GENL: Cannot initialize generic netlink\n"); |
@@ -955,8 +955,6 @@ static int __init genl_init(void) | |||
955 | if (err < 0) | 955 | if (err < 0) |
956 | goto problem; | 956 | goto problem; |
957 | 957 | ||
958 | netlink_set_nonroot(NETLINK_GENERIC, NL_NONROOT_RECV); | ||
959 | |||
960 | err = register_pernet_subsys(&genl_pernet_ops); | 958 | err = register_pernet_subsys(&genl_pernet_ops); |
961 | if (err) | 959 | if (err) |
962 | goto problem; | 960 | goto problem; |
@@ -973,7 +971,7 @@ problem: | |||
973 | 971 | ||
974 | subsys_initcall(genl_init); | 972 | subsys_initcall(genl_init); |
975 | 973 | ||
976 | static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | 974 | static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, |
977 | gfp_t flags) | 975 | gfp_t flags) |
978 | { | 976 | { |
979 | struct sk_buff *tmp; | 977 | struct sk_buff *tmp; |
@@ -988,7 +986,7 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | |||
988 | goto error; | 986 | goto error; |
989 | } | 987 | } |
990 | err = nlmsg_multicast(prev->genl_sock, tmp, | 988 | err = nlmsg_multicast(prev->genl_sock, tmp, |
991 | pid, group, flags); | 989 | portid, group, flags); |
992 | if (err) | 990 | if (err) |
993 | goto error; | 991 | goto error; |
994 | } | 992 | } |
@@ -996,20 +994,20 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, | |||
996 | prev = net; | 994 | prev = net; |
997 | } | 995 | } |
998 | 996 | ||
999 | return nlmsg_multicast(prev->genl_sock, skb, pid, group, flags); | 997 | return nlmsg_multicast(prev->genl_sock, skb, portid, group, flags); |
1000 | error: | 998 | error: |
1001 | kfree_skb(skb); | 999 | kfree_skb(skb); |
1002 | return err; | 1000 | return err; |
1003 | } | 1001 | } |
1004 | 1002 | ||
1005 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, unsigned int group, | 1003 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, unsigned int group, |
1006 | gfp_t flags) | 1004 | gfp_t flags) |
1007 | { | 1005 | { |
1008 | return genlmsg_mcast(skb, pid, group, flags); | 1006 | return genlmsg_mcast(skb, portid, group, flags); |
1009 | } | 1007 | } |
1010 | EXPORT_SYMBOL(genlmsg_multicast_allns); | 1008 | EXPORT_SYMBOL(genlmsg_multicast_allns); |
1011 | 1009 | ||
1012 | void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, | 1010 | void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, u32 group, |
1013 | struct nlmsghdr *nlh, gfp_t flags) | 1011 | struct nlmsghdr *nlh, gfp_t flags) |
1014 | { | 1012 | { |
1015 | struct sock *sk = net->genl_sock; | 1013 | struct sock *sk = net->genl_sock; |
@@ -1018,6 +1016,6 @@ void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, | |||
1018 | if (nlh) | 1016 | if (nlh) |
1019 | report = nlmsg_report(nlh); | 1017 | report = nlmsg_report(nlh); |
1020 | 1018 | ||
1021 | nlmsg_notify(sk, skb, pid, group, report, flags); | 1019 | nlmsg_notify(sk, skb, portid, group, report, flags); |
1022 | } | 1020 | } |
1023 | EXPORT_SYMBOL(genl_notify); | 1021 | EXPORT_SYMBOL(genl_notify); |