diff options
author | David S. Miller <davem@davemloft.net> | 2013-11-19 21:39:42 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-11-19 21:39:42 (GMT) |
commit | 091e0662ee2c37867ad918ce7b6ddd17f0e090e2 (patch) | |
tree | e5a066d8f83d8822d448421019a4503f361295f9 /net/ieee802154/netlink.c | |
parent | dbde497966804e63a38fdedc1e3815e77097efc2 (diff) | |
parent | 2a94fe48f32ccf7321450a2cc07f2b724a444e5b (diff) | |
download | linux-fsl-qoriq-091e0662ee2c37867ad918ce7b6ddd17f0e090e2.tar.xz |
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/ieee802154/netlink.c')
-rw-r--r-- | net/ieee802154/netlink.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index 3ffcdbb..43f1b2b 100644 --- a/net/ieee802154/netlink.c +++ b/net/ieee802154/netlink.c @@ -70,7 +70,7 @@ int ieee802154_nl_mcast(struct sk_buff *msg, unsigned int group) if (genlmsg_end(msg, hdr) < 0) goto out; - return genlmsg_multicast(msg, 0, group, GFP_ATOMIC); + return genlmsg_multicast(&nl802154_family, msg, 0, group, GFP_ATOMIC); out: nlmsg_free(msg); return -ENOBUFS; @@ -125,26 +125,17 @@ static const struct genl_ops ieee8021154_ops[] = { ieee802154_dump_iface), }; +static const struct genl_multicast_group ieee802154_mcgrps[] = { + [IEEE802154_COORD_MCGRP] = { .name = IEEE802154_MCAST_COORD_NAME, }, + [IEEE802154_BEACON_MCGRP] = { .name = IEEE802154_MCAST_BEACON_NAME, }, +}; + + int __init ieee802154_nl_init(void) { - int rc; - - rc = genl_register_family_with_ops(&nl802154_family, ieee8021154_ops, - ARRAY_SIZE(ieee8021154_ops)); - if (rc) - return rc; - - rc = genl_register_mc_group(&nl802154_family, &ieee802154_coord_mcgrp); - if (rc) - goto fail; - - rc = genl_register_mc_group(&nl802154_family, &ieee802154_beacon_mcgrp); - if (rc) - goto fail; - return 0; -fail: - genl_unregister_family(&nl802154_family); - return rc; + return genl_register_family_with_ops_groups(&nl802154_family, + ieee8021154_ops, + ieee802154_mcgrps); } void __exit ieee802154_nl_exit(void) |