aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154/nl-mac.c
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 /net/ieee802154/nl-mac.c
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 'net/ieee802154/nl-mac.c')
-rw-r--r--net/ieee802154/nl-mac.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 28d493032132..ba5c1e002f37 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -39,14 +39,6 @@
39 39
40#include "ieee802154.h" 40#include "ieee802154.h"
41 41
42struct genl_multicast_group ieee802154_coord_mcgrp = {
43 .name = IEEE802154_MCAST_COORD_NAME,
44};
45
46struct genl_multicast_group ieee802154_beacon_mcgrp = {
47 .name = IEEE802154_MCAST_BEACON_NAME,
48};
49
50int ieee802154_nl_assoc_indic(struct net_device *dev, 42int ieee802154_nl_assoc_indic(struct net_device *dev,
51 struct ieee802154_addr *addr, u8 cap) 43 struct ieee802154_addr *addr, u8 cap)
52{ 44{
@@ -72,7 +64,7 @@ int ieee802154_nl_assoc_indic(struct net_device *dev,
72 nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap)) 64 nla_put_u8(msg, IEEE802154_ATTR_CAPABILITY, cap))
73 goto nla_put_failure; 65 goto nla_put_failure;
74 66
75 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 67 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
76 68
77nla_put_failure: 69nla_put_failure:
78 nlmsg_free(msg); 70 nlmsg_free(msg);
@@ -98,7 +90,7 @@ int ieee802154_nl_assoc_confirm(struct net_device *dev, u16 short_addr,
98 nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) || 90 nla_put_u16(msg, IEEE802154_ATTR_SHORT_ADDR, short_addr) ||
99 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 91 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
100 goto nla_put_failure; 92 goto nla_put_failure;
101 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 93 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
102 94
103nla_put_failure: 95nla_put_failure:
104 nlmsg_free(msg); 96 nlmsg_free(msg);
@@ -133,7 +125,7 @@ int ieee802154_nl_disassoc_indic(struct net_device *dev,
133 } 125 }
134 if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason)) 126 if (nla_put_u8(msg, IEEE802154_ATTR_REASON, reason))
135 goto nla_put_failure; 127 goto nla_put_failure;
136 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 128 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
137 129
138nla_put_failure: 130nla_put_failure:
139 nlmsg_free(msg); 131 nlmsg_free(msg);
@@ -157,7 +149,7 @@ int ieee802154_nl_disassoc_confirm(struct net_device *dev, u8 status)
157 dev->dev_addr) || 149 dev->dev_addr) ||
158 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 150 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
159 goto nla_put_failure; 151 goto nla_put_failure;
160 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 152 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
161 153
162nla_put_failure: 154nla_put_failure:
163 nlmsg_free(msg); 155 nlmsg_free(msg);
@@ -183,7 +175,7 @@ int ieee802154_nl_beacon_indic(struct net_device *dev,
183 nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr) || 175 nla_put_u16(msg, IEEE802154_ATTR_COORD_SHORT_ADDR, coord_addr) ||
184 nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid)) 176 nla_put_u16(msg, IEEE802154_ATTR_COORD_PAN_ID, panid))
185 goto nla_put_failure; 177 goto nla_put_failure;
186 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 178 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
187 179
188nla_put_failure: 180nla_put_failure:
189 nlmsg_free(msg); 181 nlmsg_free(msg);
@@ -214,7 +206,7 @@ int ieee802154_nl_scan_confirm(struct net_device *dev,
214 (edl && 206 (edl &&
215 nla_put(msg, IEEE802154_ATTR_ED_LIST, 27, edl))) 207 nla_put(msg, IEEE802154_ATTR_ED_LIST, 27, edl)))
216 goto nla_put_failure; 208 goto nla_put_failure;
217 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 209 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
218 210
219nla_put_failure: 211nla_put_failure:
220 nlmsg_free(msg); 212 nlmsg_free(msg);
@@ -238,7 +230,7 @@ int ieee802154_nl_start_confirm(struct net_device *dev, u8 status)
238 dev->dev_addr) || 230 dev->dev_addr) ||
239 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status)) 231 nla_put_u8(msg, IEEE802154_ATTR_STATUS, status))
240 goto nla_put_failure; 232 goto nla_put_failure;
241 return ieee802154_nl_mcast(msg, ieee802154_coord_mcgrp.id); 233 return ieee802154_nl_mcast(msg, IEEE802154_COORD_MCGRP);
242 234
243nla_put_failure: 235nla_put_failure:
244 nlmsg_free(msg); 236 nlmsg_free(msg);