diff options
author | David S. Miller <davem@davemloft.net> | 2013-11-19 16:39:42 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-19 16:39:42 -0500 |
commit | 091e0662ee2c37867ad918ce7b6ddd17f0e090e2 (patch) | |
tree | e5a066d8f83d8822d448421019a4503f361295f9 /net/wimax/stack.c | |
parent | dbde497966804e63a38fdedc1e3815e77097efc2 (diff) | |
parent | 2a94fe48f32ccf7321450a2cc07f2b724a444e5b (diff) |
Merge branch 'genetlink_mcast'
Johannes Berg says:
====================
genetlink: clean up multicast group APIs
The generic netlink multicast group registration doesn't have to
be dynamic, and can thus be simplified just like I did with the
ops. This removes some complexity in registration code.
Additionally, two users of generic netlink already use multicast
groups in a wrong way, add workarounds for those two to keep the
userspace API working, but at the same time make them not clash
with other users of multicast groups as might happen now.
While making it all a bit easier, also prevent such abuse by adding
checks to the APIs so each family can only use the groups it owns.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/wimax/stack.c')
-rw-r--r-- | net/wimax/stack.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/net/wimax/stack.c b/net/wimax/stack.c index 47170c9495f1..ef2191b969a7 100644 --- a/net/wimax/stack.c +++ b/net/wimax/stack.c | |||
@@ -116,8 +116,9 @@ struct sk_buff *wimax_gnl_re_state_change_alloc( | |||
116 | dev_err(dev, "RE_STCH: can't create message\n"); | 116 | dev_err(dev, "RE_STCH: can't create message\n"); |
117 | goto error_new; | 117 | goto error_new; |
118 | } | 118 | } |
119 | data = genlmsg_put(report_skb, 0, wimax_gnl_mcg.id, &wimax_gnl_family, | 119 | /* FIXME: sending a group ID as the seq is wrong */ |
120 | 0, WIMAX_GNL_RE_STATE_CHANGE); | 120 | data = genlmsg_put(report_skb, 0, wimax_gnl_family.mcgrp_offset, |
121 | &wimax_gnl_family, 0, WIMAX_GNL_RE_STATE_CHANGE); | ||
121 | if (data == NULL) { | 122 | if (data == NULL) { |
122 | dev_err(dev, "RE_STCH: can't put data into message\n"); | 123 | dev_err(dev, "RE_STCH: can't put data into message\n"); |
123 | goto error_put; | 124 | goto error_put; |
@@ -177,7 +178,7 @@ int wimax_gnl_re_state_change_send( | |||
177 | goto out; | 178 | goto out; |
178 | } | 179 | } |
179 | genlmsg_end(report_skb, header); | 180 | genlmsg_end(report_skb, header); |
180 | genlmsg_multicast(report_skb, 0, wimax_gnl_mcg.id, GFP_KERNEL); | 181 | genlmsg_multicast(&wimax_gnl_family, report_skb, 0, 0, GFP_KERNEL); |
181 | out: | 182 | out: |
182 | d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n", | 183 | d_fnend(3, dev, "(wimax_dev %p report_skb %p) = %d\n", |
183 | wimax_dev, report_skb, result); | 184 | wimax_dev, report_skb, result); |
@@ -579,8 +580,8 @@ struct genl_family wimax_gnl_family = { | |||
579 | .maxattr = WIMAX_GNL_ATTR_MAX, | 580 | .maxattr = WIMAX_GNL_ATTR_MAX, |
580 | }; | 581 | }; |
581 | 582 | ||
582 | struct genl_multicast_group wimax_gnl_mcg = { | 583 | static const struct genl_multicast_group wimax_gnl_mcgrps[] = { |
583 | .name = "msg", | 584 | { .name = "msg", }, |
584 | }; | 585 | }; |
585 | 586 | ||
586 | 587 | ||
@@ -597,21 +598,18 @@ int __init wimax_subsys_init(void) | |||
597 | 598 | ||
598 | snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name), | 599 | snprintf(wimax_gnl_family.name, sizeof(wimax_gnl_family.name), |
599 | "WiMAX"); | 600 | "WiMAX"); |
600 | result = genl_register_family_with_ops(&wimax_gnl_family, wimax_gnl_ops, | 601 | result = genl_register_family_with_ops_groups(&wimax_gnl_family, |
601 | ARRAY_SIZE(wimax_gnl_ops)); | 602 | wimax_gnl_ops, |
603 | wimax_gnl_mcgrps); | ||
602 | if (unlikely(result < 0)) { | 604 | if (unlikely(result < 0)) { |
603 | printk(KERN_ERR "cannot register generic netlink family: %d\n", | 605 | printk(KERN_ERR "cannot register generic netlink family: %d\n", |
604 | result); | 606 | result); |
605 | goto error_register_family; | 607 | goto error_register_family; |
606 | } | 608 | } |
607 | 609 | ||
608 | result = genl_register_mc_group(&wimax_gnl_family, &wimax_gnl_mcg); | ||
609 | if (result < 0) | ||
610 | goto error_mc_group; | ||
611 | d_fnend(4, NULL, "() = 0\n"); | 610 | d_fnend(4, NULL, "() = 0\n"); |
612 | return 0; | 611 | return 0; |
613 | 612 | ||
614 | error_mc_group: | ||
615 | genl_unregister_family(&wimax_gnl_family); | 613 | genl_unregister_family(&wimax_gnl_family); |
616 | error_register_family: | 614 | error_register_family: |
617 | d_fnend(4, NULL, "() = %d\n", result); | 615 | d_fnend(4, NULL, "() = %d\n", result); |