aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-01-24 04:53:53 -0500
committerJohannes Berg <johannes.berg@intel.com>2014-02-04 15:58:12 -0500
commitea73cbce4e1fd93113301532ad98041b119bc85a (patch)
tree40f4fc8b5966ab5b15dfe38ad154ce4b9267685b /net/wireless
parent9fa37a3d6604fcdd1372bc0d2d724c3371ecb7f9 (diff)
nl80211: fix scheduled scan RSSI matchset attribute confusion
The scheduled scan matchsets were intended to be a list of filters, with the found BSS having to pass at least one of them to be passed to the host. When the RSSI attribute was added, however, this was broken and currently wpa_supplicant adds that attribute in its own matchset; however, it doesn't intend that to mean that anything that passes the RSSI filter should be passed to the host, instead it wants it to mean that everything needs to also have higher RSSI. This is semantically problematic because we have a list of filters like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which one should be OR'ed and which one AND'ed. To fix this, move the RSSI filter attribute into each matchset. As we need to stay backward compatible, treat a matchset with only the RSSI attribute as a "default RSSI filter" for all other matchsets, but only if there are other matchsets (an RSSI-only matchset by itself is still desirable.) To make driver implementation easier, keep a global min_rssi_thold for the entire request as well. The only affected driver is ath6kl. I found this when I looked into the code after Raja Mani submitted a patch fixing the n_match_sets calculation to disregard the RSSI, but that patch didn't address the semantic issue. Reported-by: Raja Mani <rmani@qti.qualcomm.com> Acked-by: Luciano Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c70
1 files changed, 61 insertions, 9 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 043bfbd58b56..20be186f7f77 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5467,6 +5467,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5467 enum ieee80211_band band; 5467 enum ieee80211_band band;
5468 size_t ie_len; 5468 size_t ie_len;
5469 struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1]; 5469 struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
5470 s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
5470 5471
5471 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) || 5472 if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
5472 !rdev->ops->sched_scan_start) 5473 !rdev->ops->sched_scan_start)
@@ -5501,11 +5502,40 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5501 if (n_ssids > wiphy->max_sched_scan_ssids) 5502 if (n_ssids > wiphy->max_sched_scan_ssids)
5502 return -EINVAL; 5503 return -EINVAL;
5503 5504
5504 if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) 5505 /*
5506 * First, count the number of 'real' matchsets. Due to an issue with
5507 * the old implementation, matchsets containing only the RSSI attribute
5508 * (NL80211_SCHED_SCAN_MATCH_ATTR_RSSI) are considered as the 'default'
5509 * RSSI for all matchsets, rather than their own matchset for reporting
5510 * all APs with a strong RSSI. This is needed to be compatible with
5511 * older userspace that treated a matchset with only the RSSI as the
5512 * global RSSI for all other matchsets - if there are other matchsets.
5513 */
5514 if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
5505 nla_for_each_nested(attr, 5515 nla_for_each_nested(attr,
5506 info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH], 5516 info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
5507 tmp) 5517 tmp) {
5508 n_match_sets++; 5518 struct nlattr *rssi;
5519
5520 err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
5521 nla_data(attr), nla_len(attr),
5522 nl80211_match_policy);
5523 if (err)
5524 return err;
5525 /* add other standalone attributes here */
5526 if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]) {
5527 n_match_sets++;
5528 continue;
5529 }
5530 rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
5531 if (rssi)
5532 default_match_rssi = nla_get_s32(rssi);
5533 }
5534 }
5535
5536 /* However, if there's no other matchset, add the RSSI one */
5537 if (!n_match_sets && default_match_rssi != NL80211_SCAN_RSSI_THOLD_OFF)
5538 n_match_sets = 1;
5509 5539
5510 if (n_match_sets > wiphy->max_match_sets) 5540 if (n_match_sets > wiphy->max_match_sets)
5511 return -EINVAL; 5541 return -EINVAL;
@@ -5633,6 +5663,15 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5633 goto out_free; 5663 goto out_free;
5634 ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]; 5664 ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
5635 if (ssid) { 5665 if (ssid) {
5666 if (WARN_ON(i >= n_match_sets)) {
5667 /* this indicates a programming error,
5668 * the loop above should have verified
5669 * things properly
5670 */
5671 err = -EINVAL;
5672 goto out_free;
5673 }
5674
5636 if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) { 5675 if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
5637 err = -EINVAL; 5676 err = -EINVAL;
5638 goto out_free; 5677 goto out_free;
@@ -5641,15 +5680,28 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
5641 nla_data(ssid), nla_len(ssid)); 5680 nla_data(ssid), nla_len(ssid));
5642 request->match_sets[i].ssid.ssid_len = 5681 request->match_sets[i].ssid.ssid_len =
5643 nla_len(ssid); 5682 nla_len(ssid);
5683 /* special attribute - old implemenation w/a */
5684 request->match_sets[i].rssi_thold =
5685 default_match_rssi;
5686 rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
5687 if (rssi)
5688 request->match_sets[i].rssi_thold =
5689 nla_get_s32(rssi);
5644 } 5690 }
5645 rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
5646 if (rssi)
5647 request->rssi_thold = nla_get_u32(rssi);
5648 else
5649 request->rssi_thold =
5650 NL80211_SCAN_RSSI_THOLD_OFF;
5651 i++; 5691 i++;
5652 } 5692 }
5693
5694 /* there was no other matchset, so the RSSI one is alone */
5695 if (i == 0)
5696 request->match_sets[0].rssi_thold = default_match_rssi;
5697
5698 request->min_rssi_thold = INT_MAX;
5699 for (i = 0; i < n_match_sets; i++)
5700 request->min_rssi_thold =
5701 min(request->match_sets[i].rssi_thold,
5702 request->min_rssi_thold);
5703 } else {
5704 request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF;
5653 } 5705 }
5654 5706
5655 if (info->attrs[NL80211_ATTR_IE]) { 5707 if (info->attrs[NL80211_ATTR_IE]) {