developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 1 | diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h |
| 2 | --- a/include/net/cfg80211.h |
| 3 | +++ b/include/net/cfg80211.h |
| 4 | @@ -1158,6 +1158,7 @@ struct cfg80211_fils_discovery { |
| 5 | u32 max_interval; |
| 6 | size_t tmpl_len; |
| 7 | const u8 *tmpl; |
| 8 | + u8 disable; |
| 9 | }; |
| 10 | |
| 11 | /** |
| 12 | diff --git a/include/net/mac80211.h b/include/net/mac80211.h |
| 13 | --- a/include/net/mac80211.h |
| 14 | +++ b/include/net/mac80211.h |
| 15 | @@ -505,6 +505,7 @@ struct ieee80211_ftm_responder_params { |
| 16 | struct ieee80211_fils_discovery { |
| 17 | u32 min_interval; |
| 18 | u32 max_interval; |
| 19 | + u8 disable; |
| 20 | }; |
| 21 | |
| 22 | /** |
| 23 | diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h |
| 24 | --- a/include/uapi/linux/nl80211.h |
| 25 | +++ b/include/uapi/linux/nl80211.h |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 26 | @@ -7242,6 +7242,7 @@ enum nl80211_fils_discovery_attributes { |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 27 | NL80211_FILS_DISCOVERY_ATTR_INT_MIN, |
| 28 | NL80211_FILS_DISCOVERY_ATTR_INT_MAX, |
| 29 | NL80211_FILS_DISCOVERY_ATTR_TMPL, |
| 30 | + NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE, |
| 31 | |
| 32 | /* keep last */ |
| 33 | __NL80211_FILS_DISCOVERY_ATTR_LAST, |
| 34 | diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c |
| 35 | --- a/net/mac80211/cfg.c |
| 36 | +++ b/net/mac80211/cfg.c |
| 37 | @@ -906,6 +906,7 @@ static int ieee80211_set_fils_discovery( |
| 38 | fd = &sdata->vif.bss_conf.fils_discovery; |
| 39 | fd->min_interval = params->min_interval; |
| 40 | fd->max_interval = params->max_interval; |
| 41 | + fd->disable = params->disable; |
| 42 | |
| 43 | old = sdata_dereference(sdata->u.ap.fils_discovery, sdata); |
| 44 | new = kzalloc(sizeof(*new) + params->tmpl_len, GFP_KERNEL); |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 45 | @@ -1316,6 +1317,9 @@ static int ieee80211_change_beacon(struc |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 46 | { |
| 47 | struct ieee80211_sub_if_data *sdata; |
| 48 | struct beacon_data *old; |
| 49 | + struct cfg80211_ap_settings *ap_params; |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 50 | + struct ieee80211_supported_band *sband; |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 51 | + u32 changed; |
| 52 | int err; |
| 53 | |
| 54 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 55 | @@ -1334,7 +1338,33 @@ static int ieee80211_change_beacon(struc |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 56 | err = ieee80211_assign_beacon(sdata, params, NULL, NULL); |
| 57 | if (err < 0) |
| 58 | return err; |
| 59 | - ieee80211_bss_info_change_notify(sdata, err); |
| 60 | + |
| 61 | + changed = err; |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 62 | + |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 63 | + sband = ieee80211_get_sband(sdata); |
| 64 | + if (!sband) |
| 65 | + return -EINVAL; |
| 66 | + |
| 67 | + if (sband->band == NL80211_BAND_6GHZ) { |
| 68 | + ap_params = container_of(params, struct cfg80211_ap_settings, beacon); |
| 69 | + |
| 70 | + if(ap_params->unsol_bcast_probe_resp.interval) { |
| 71 | + err = ieee80211_set_unsol_bcast_probe_resp(sdata, |
| 72 | + &ap_params->unsol_bcast_probe_resp); |
| 73 | + if (err < 0) |
| 74 | + return err; |
| 75 | + changed |= BSS_CHANGED_UNSOL_BCAST_PROBE_RESP; |
| 76 | + } else { |
| 77 | + err = ieee80211_set_fils_discovery(sdata, |
| 78 | + &ap_params->fils_discovery); |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 79 | + |
developer | 55bf715 | 2022-07-18 12:08:07 +0800 | [diff] [blame] | 80 | + if (err < 0) |
| 81 | + return err; |
| 82 | + changed |= BSS_CHANGED_FILS_DISCOVERY; |
| 83 | + } |
developer | 7d2399a | 2022-05-13 17:59:07 +0800 | [diff] [blame] | 84 | + } |
| 85 | + |
| 86 | + ieee80211_bss_info_change_notify(sdata, changed); |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c |
| 91 | --- a/net/wireless/nl80211.c |
| 92 | +++ b/net/wireless/nl80211.c |
| 93 | @@ -421,6 +421,7 @@ nl80211_fils_discovery_policy[NL80211_FI |
| 94 | [NL80211_FILS_DISCOVERY_ATTR_TMPL] = { .type = NLA_BINARY, |
| 95 | .len = IEEE80211_MAX_DATA_LEN }, |
| 96 | #endif |
| 97 | + [NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE] = NLA_POLICY_MAX(NLA_U32, 20), |
| 98 | }; |
| 99 | |
| 100 | static const struct nla_policy |
| 101 | @@ -5349,6 +5350,8 @@ static int nl80211_parse_fils_discovery( |
| 102 | fd->tmpl = nla_data(tb[NL80211_FILS_DISCOVERY_ATTR_TMPL]); |
| 103 | fd->min_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MIN]); |
| 104 | fd->max_interval = nla_get_u32(tb[NL80211_FILS_DISCOVERY_ATTR_INT_MAX]); |
| 105 | + fd->disable = !(fd->max_interval || |
| 106 | + nla_get_u32(tb[NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_INTE])); |
| 107 | |
| 108 | return 0; |
| 109 | } |
| 110 | @@ -5754,7 +5757,8 @@ static int nl80211_set_beacon(struct sk_ |
| 111 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
| 112 | struct net_device *dev = info->user_ptr[1]; |
| 113 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 114 | - struct cfg80211_beacon_data params; |
| 115 | + struct cfg80211_ap_settings ap_params; |
| 116 | + struct cfg80211_beacon_data *params; |
| 117 | int err; |
| 118 | |
| 119 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && |
| 120 | @@ -5767,16 +5771,35 @@ static int nl80211_set_beacon(struct sk_ |
| 121 | if (!wdev->beacon_interval) |
| 122 | return -EINVAL; |
| 123 | |
| 124 | - err = nl80211_parse_beacon(rdev, info->attrs, ¶ms); |
| 125 | + memset(&ap_params, 0, sizeof(ap_params)); |
| 126 | + params = &ap_params.beacon; |
| 127 | + |
| 128 | + err = nl80211_parse_beacon(rdev, info->attrs, params); |
| 129 | if (err) |
| 130 | goto out; |
| 131 | |
| 132 | + if (info->attrs[NL80211_ATTR_FILS_DISCOVERY]) { |
| 133 | + err = nl80211_parse_fils_discovery(rdev, |
| 134 | + info->attrs[NL80211_ATTR_FILS_DISCOVERY], |
| 135 | + &ap_params); |
| 136 | + if (err) |
| 137 | + goto out; |
| 138 | + } |
| 139 | + |
| 140 | + if (info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP]) { |
| 141 | + err = nl80211_parse_unsol_bcast_probe_resp(rdev, |
| 142 | + info->attrs[NL80211_ATTR_UNSOL_BCAST_PROBE_RESP], |
| 143 | + &ap_params); |
| 144 | + if (err) |
| 145 | + goto out; |
| 146 | + } |
| 147 | + |
| 148 | wdev_lock(wdev); |
| 149 | - err = rdev_change_beacon(rdev, dev, ¶ms); |
| 150 | + err = rdev_change_beacon(rdev, dev, params); |
| 151 | wdev_unlock(wdev); |
| 152 | |
| 153 | out: |
| 154 | - kfree(params.mbssid_ies); |
| 155 | + kfree(params->mbssid_ies); |
| 156 | return err; |
| 157 | } |
| 158 | |