aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/genetlink.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 16:38:27 -0400
commitaecdc33e111b2c447b622e287c6003726daa1426 (patch)
tree3e7657eae4b785e1a1fb5dfb225dbae0b2f0cfc6 /net/netlink/genetlink.c
parenta20acf99f75e49271381d65db097c9763060a1e8 (diff)
parenta3a6cab5ea10cca64d036851fe0d932448f2fe4f (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller: 1) GRE now works over ipv6, from Dmitry Kozlov. 2) Make SCTP more network namespace aware, from Eric Biederman. 3) TEAM driver now works with non-ethernet devices, from Jiri Pirko. 4) Make openvswitch network namespace aware, from Pravin B Shelar. 5) IPV6 NAT implementation, from Patrick McHardy. 6) Server side support for TCP Fast Open, from Jerry Chu and others. 7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel Borkmann. 8) Increate the loopback default MTU to 64K, from Eric Dumazet. 9) Use a per-task rather than per-socket page fragment allocator for outgoing networking traffic. This benefits processes that have very many mostly idle sockets, which is quite common. From Eric Dumazet. 10) Use up to 32K for page fragment allocations, with fallbacks to smaller sizes when higher order page allocations fail. Benefits are a) less segments for driver to process b) less calls to page allocator c) less waste of space. From Eric Dumazet. 11) Allow GRO to be used on GRE tunnels, from Eric Dumazet. 12) VXLAN device driver, one way to handle VLAN issues such as the limitation of 4096 VLAN IDs yet still have some level of isolation. From Stephen Hemminger. 13) As usual there is a large boatload of driver changes, with the scale perhaps tilted towards the wireless side this time around. Fix up various fairly trivial conflicts, mostly caused by the user namespace changes. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits) hyperv: Add buffer for extended info after the RNDIS response message. hyperv: Report actual status in receive completion packet hyperv: Remove extra allocated space for recv_pkt_list elements hyperv: Fix page buffer handling in rndis_filter_send_request() hyperv: Fix the missing return value in rndis_filter_set_packet_filter() hyperv: Fix the max_xfer_size in RNDIS initialization vxlan: put UDP socket in correct namespace vxlan: Depend on CONFIG_INET sfc: Fix the reported priorities of different filter types sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP sfc: Fix loopback self-test with separate_tx_channels=1 sfc: Fix MCDI structure field lookup sfc: Add parentheses around use of bitfield macro arguments sfc: Fix null function pointer in efx_sriov_channel_type vxlan: virtual extensible lan igmp: export symbol ip_mc_leave_group netlink: add attributes to fdb interface tg3: unconditionally select HWMON support when tg3 is enabled. Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT" gre: fix sparse warning ...
Diffstat (limited to 'net/netlink/genetlink.c')
-rw-r--r--net/netlink/genetlink.c48
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 */
512void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, 512void *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
629static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, 629static 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
704static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, 704static 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
775static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, 775static 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
794static struct sk_buff *ctrl_build_mcgrp_msg(struct genl_multicast_group *grp, 794static 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
974subsys_initcall(genl_init); 972subsys_initcall(genl_init);
975 973
976static int genlmsg_mcast(struct sk_buff *skb, u32 pid, unsigned long group, 974static 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
1005int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, unsigned int group, 1003int 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}
1010EXPORT_SYMBOL(genlmsg_multicast_allns); 1008EXPORT_SYMBOL(genlmsg_multicast_allns);
1011 1009
1012void genl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group, 1010void 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}
1023EXPORT_SYMBOL(genl_notify); 1021EXPORT_SYMBOL(genl_notify);