aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/team
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-11-19 09:19:39 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-19 16:39:06 -0500
commit2a94fe48f32ccf7321450a2cc07f2b724a444e5b (patch)
treee5a066d8f83d8822d448421019a4503f361295f9 /drivers/net/team
parent68eb55031da7c967d954e5f9415cd05f4abdb692 (diff)
genetlink: make multicast groups const, prevent abuse
Register generic netlink multicast groups as an array with the family and give them contiguous group IDs. Then instead of passing the global group ID to the various functions that send messages, pass the ID relative to the family - for most families that's just 0 because the only have one group. This avoids the list_head and ID in each group, adding a new field for the mcast group ID offset to the family. At the same time, this allows us to prevent abusing groups again like the quota and dropmon code did, since we can now check that a family only uses a group it owns. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/team')
-rw-r--r--drivers/net/team/team.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 2721e29935a6..0715de50b3dc 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2670,16 +2670,15 @@ static const struct genl_ops team_nl_ops[] = {
2670 }, 2670 },
2671}; 2671};
2672 2672
2673static struct genl_multicast_group team_change_event_mcgrp = { 2673static const struct genl_multicast_group team_nl_mcgrps[] = {
2674 .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, 2674 { .name = TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME, },
2675}; 2675};
2676 2676
2677static int team_nl_send_multicast(struct sk_buff *skb, 2677static int team_nl_send_multicast(struct sk_buff *skb,
2678 struct team *team, u32 portid) 2678 struct team *team, u32 portid)
2679{ 2679{
2680 return genlmsg_multicast_netns(&team_nl_family, dev_net(team->dev), 2680 return genlmsg_multicast_netns(&team_nl_family, dev_net(team->dev),
2681 skb, 0, team_change_event_mcgrp.id, 2681 skb, 0, 0, GFP_KERNEL);
2682 GFP_KERNEL);
2683} 2682}
2684 2683
2685static int team_nl_send_event_options_get(struct team *team, 2684static int team_nl_send_event_options_get(struct team *team,
@@ -2698,22 +2697,8 @@ static int team_nl_send_event_port_get(struct team *team,
2698 2697
2699static int team_nl_init(void) 2698static int team_nl_init(void)
2700{ 2699{
2701 int err; 2700 return genl_register_family_with_ops_groups(&team_nl_family, team_nl_ops,
2702 2701 team_nl_mcgrps);
2703 err = genl_register_family_with_ops(&team_nl_family, team_nl_ops);
2704 if (err)
2705 return err;
2706
2707 err = genl_register_mc_group(&team_nl_family, &team_change_event_mcgrp);
2708 if (err)
2709 goto err_change_event_grp_reg;
2710
2711 return 0;
2712
2713err_change_event_grp_reg:
2714 genl_unregister_family(&team_nl_family);
2715
2716 return err;
2717} 2702}
2718 2703
2719static void team_nl_fini(void) 2704static void team_nl_fini(void)