History

cfg80211: return private regdom for self-managed devices

If a device has self-managed regulatory, insist on returning the wiphy specific regdomain if a wiphy-idx is specified. The global regdomain is meaningless for such devices. Also add an attribute for self-managed devices, so usermode can distinguish them as such.

Arik Nemtsov committed 11 years ago

Commit 1bdd7161 parent b0d7aa52 files · +34 −0Browse files

Unified · Split

2 files
  1. include/uapi/linux/nl80211.h +10 −0
  2. net/wireless/nl80211.c +24 −0
include/uapi/linux/nl80211.h+10−0
@@ -261,6 +261,9 @@ · 260 unmodified lines
261261 * the regulatory core to help with compliance. A dump version of this API
262262 * is now available which will returns the global regdomain as well as
263263 * all private regdomains of present wiphys (for those that have it).
264+ * If a wiphy is self-managed (%NL80211_ATTR_WIPHY_SELF_MANAGED_REG), then
265+ * its private regdomain is the only valid one for it. The regulatory
266+ * core is not used to help with compliance in this case.
264267 * @NL80211_CMD_SET_REG: Set current regulatory domain. CRDA sends this command
265268 * after being queried by the kernel. CRDA replies by sending a regulatory
266269 * domain structure which consists of %NL80211_ATTR_REG_ALPHA set to our
@@ -1702,6 +1705,11 @@ enum nl80211_commands { · 1435 unmodified lines
17021705 *
17031706 * @NL80211_ATTR_MAC_MASK: MAC address mask
17041707 *
1708+ * @NL80211_ATTR_WIPHY_SELF_MANAGED_REG: flag attribute indicating this device
1709+ * is self-managing its regulatory information and any regulatory domain
1710+ * obtained from it is coming from the device's wiphy and not the global
1711+ * cfg80211 regdomain.
1712+ *
17051713 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
17061714 * @NL80211_ATTR_MAX: highest attribute number currently defined
17071715 * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -2059,6 +2067,8 @@ enum nl80211_attrs { · 351 unmodified lines
20592067
20602068 NL80211_ATTR_MAC_MASK,
20612069
2070+ NL80211_ATTR_WIPHY_SELF_MANAGED_REG,
2071+
20622072 /* add attributes here, update the policy in nl80211.c */
20632073
20642074 __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c+24−0
@@ -396,6 +396,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { · 395 unmodified lines
396396 [NL80211_ATTR_ADMITTED_TIME] = { .type = NLA_U16 },
397397 [NL80211_ATTR_SMPS_MODE] = { .type = NLA_U8 },
398398 [NL80211_ATTR_MAC_MASK] = { .len = ETH_ALEN },
399+ [NL80211_ATTR_WIPHY_SELF_MANAGED_REG] = { .type = NLA_FLAG },
399400 };
400401
401402 /* policy for the key attributes */
@@ -1701,6 +1702,10 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, · 1299 unmodified lines
17011702 rdev->wiphy.max_num_csa_counters))
17021703 goto nla_put_failure;
17031704
1705+ if (rdev->wiphy.regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED &&
1706+ nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
1707+ goto nla_put_failure;
1708+
17041709 /* done */
17051710 state->split_start = 0;
17061711 break;
@@ -5406,6 +5411,8 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info) · 3699 unmodified lines
54065411 goto put_failure;
54075412
54085413 if (info->attrs[NL80211_ATTR_WIPHY]) {
5414+ bool self_managed;
5415+
54095416 rdev = cfg80211_get_dev_from_info(genl_info_net(info), info);
54105417 if (IS_ERR(rdev)) {
54115418 nlmsg_free(msg);
@@ -5413,8 +5420,16 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info) · 1 unmodified line
54135420 }
54145421
54155422 wiphy = &rdev->wiphy;
5423+ self_managed = wiphy->regulatory_flags &
5424+ REGULATORY_WIPHY_SELF_MANAGED;
54165425 regdom = get_wiphy_regdom(wiphy);
54175426
5427+ /* a self-managed-reg device must have a private regdom */
5428+ if (WARN_ON(!regdom && self_managed)) {
5429+ nlmsg_free(msg);
5430+ return -EINVAL;
5431+ }
5432+
54185433 if (regdom &&
54195434 nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)))
54205435 goto nla_put_failure;
@@ -5471,6 +5486,10 @@ static int nl80211_send_regdom(struct sk_buff *msg, struct netlink_callback *cb, · 50 unmodified lines
54715486 nla_put_u32(msg, NL80211_ATTR_WIPHY, get_wiphy_idx(wiphy)))
54725487 goto nla_put_failure;
54735488
5489+ if (wiphy && wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED &&
5490+ nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
5491+ goto nla_put_failure;
5492+
54745493 return genlmsg_end(msg, hdr);
54755494
54765495 nla_put_failure:
@@ -11076,6 +11095,11 @@ static bool nl80211_reg_change_event_fill(struct sk_buff *msg, · 5599 unmodified lines
1107611095 if (wiphy &&
1107711096 nla_put_u32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx))
1107811097 goto nla_put_failure;
11098+
11099+ if (wiphy &&
11100+ wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED &&
11101+ nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
11102+ goto nla_put_failure;
1107911103 }
1108011104
1108111105 return true;