From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, Tim Kourt <tim.a.kourt@linux.intel.com>
Subject: [PATCH] cfg80211: Fix support for flushing old scan results
Date: Fri, 11 May 2018 09:48:35 -0700 [thread overview]
Message-ID: <20180511164835.40161-1-tim.a.kourt@linux.intel.com> (raw)
__cfg80211_bss_expire function was incorrectly used to flush the BSS
entries from the previous scan results, causing NL80211_SCAN_FLAG_FLUSH
flag to have no effect.
This patch is addressing the described issue by changing the semantics
of the function (__cfg80211_bss_expire) parameter from a confusing
expire_time (jiffies - IEEE80211_SCAN_RESULT_EXPIRE) to a simple
time_to_live interval and encapsulating the needed calculations inside
of the function. The rest of the function usages were changed accordingly.
Note: This patch enables flushing of the non-hidden BSSs.
Signed-off-by: Tim Kourt <tim.a.kourt@linux.intel.com>
---
net/wireless/scan.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index d36c3eb..d459457 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -71,7 +71,7 @@ module_param(bss_entries_limit, int, 0644);
MODULE_PARM_DESC(bss_entries_limit,
"limit to number of scan BSS entries (per wiphy, default 1000)");
-#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)
+#define IEEE80211_SCAN_RESULT_TIME_TO_LIVE (30 * HZ)
static void bss_free(struct cfg80211_internal_bss *bss)
{
@@ -160,7 +160,7 @@ static bool __cfg80211_unlink_bss(struct cfg80211_registered_device *rdev,
}
static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev,
- unsigned long expire_time)
+ unsigned long time_to_live)
{
struct cfg80211_internal_bss *bss, *tmp;
bool expired = false;
@@ -170,7 +170,8 @@ static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev,
list_for_each_entry_safe(bss, tmp, &rdev->bss_list, list) {
if (atomic_read(&bss->hold))
continue;
- if (!time_after(expire_time, bss->ts))
+
+ if (!time_after(jiffies, bss->ts + time_to_live))
continue;
if (__cfg80211_unlink_bss(rdev, bss))
@@ -181,6 +182,11 @@ static void __cfg80211_bss_expire(struct cfg80211_registered_device *rdev,
rdev->bss_generation++;
}
+static void __cfg80211_bss_expire_all(struct cfg80211_registered_device *rdev)
+{
+ __cfg80211_bss_expire(rdev, 0);
+}
+
static bool cfg80211_bss_expire_oldest(struct cfg80211_registered_device *rdev)
{
struct cfg80211_internal_bss *bss, *oldest = NULL;
@@ -251,7 +257,7 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
request->flags & NL80211_SCAN_FLAG_FLUSH) {
/* flush entries from previous scans */
spin_lock_bh(&rdev->bss_lock);
- __cfg80211_bss_expire(rdev, request->scan_start);
+ __cfg80211_bss_expire_all(rdev);
spin_unlock_bh(&rdev->bss_lock);
}
@@ -380,7 +386,7 @@ void cfg80211_sched_scan_results_wk(struct work_struct *work)
if (req->flags & NL80211_SCAN_FLAG_FLUSH) {
/* flush entries from previous scans */
spin_lock_bh(&rdev->bss_lock);
- __cfg80211_bss_expire(rdev, req->scan_start);
+ __cfg80211_bss_expire_all(rdev);
spin_unlock_bh(&rdev->bss_lock);
req->scan_start = jiffies;
}
@@ -477,7 +483,7 @@ void cfg80211_bss_age(struct cfg80211_registered_device *rdev,
void cfg80211_bss_expire(struct cfg80211_registered_device *rdev)
{
- __cfg80211_bss_expire(rdev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
+ __cfg80211_bss_expire(rdev, IEEE80211_SCAN_RESULT_TIME_TO_LIVE);
}
const u8 *cfg80211_find_ie_match(u8 eid, const u8 *ies, int len,
@@ -738,7 +744,8 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy,
if (!is_valid_ether_addr(bss->pub.bssid))
continue;
/* Don't get expired BSS structs */
- if (time_after(now, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE) &&
+ if (time_after(now, bss->ts +
+ IEEE80211_SCAN_RESULT_TIME_TO_LIVE) &&
!atomic_read(&bss->hold))
continue;
if (is_bss(&bss->pub, bssid, ssid, ssid_len)) {
--
2.9.4
next reply other threads:[~2018-05-11 16:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-11 16:48 Tim Kourt [this message]
2018-05-18 8:13 ` [PATCH] cfg80211: Fix support for flushing old scan results Johannes Berg
2018-05-18 16:47 ` Denis Kenzior
2018-05-18 18:54 ` Arend van Spriel
2018-05-18 19:00 ` Denis Kenzior
2018-05-22 7:24 ` Arend van Spriel
2018-05-22 14:48 ` Denis Kenzior
2018-05-22 14:50 ` Johannes Berg
2018-05-22 14:51 ` Johannes Berg
2018-05-22 15:03 ` Denis Kenzior
2018-05-22 8:12 ` Johannes Berg
2018-05-22 14:50 ` Denis Kenzior
2018-05-22 20:12 ` Johannes Berg
2018-05-22 20:37 ` Denis Kenzior
2018-05-22 20:40 ` Johannes Berg
2018-05-22 20:49 ` Denis Kenzior
2018-05-22 20:52 ` Johannes Berg
2018-05-22 21:00 ` Denis Kenzior
2018-05-22 21:11 ` Johannes Berg
2018-05-22 21:25 ` Denis Kenzior
2018-05-22 21:28 ` Johannes Berg
2018-05-22 21:45 ` Denis Kenzior
2018-05-23 7:08 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180511164835.40161-1-tim.a.kourt@linux.intel.com \
--to=tim.a.kourt@linux.intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).