From 907480c0ee9b9b19d6be11473b2aa9ac42d336e2 Mon Sep 17 00:00:00 2001 From: Stuart Henderson Date: Fri, 12 Sep 2014 16:02:41 +0000 Subject: Remove cached 802.11 nodes in IEEE80211_STA_CACHE state (these are nodes which have been seen but which haven't otherwise interacted with us), fixing a problem where old cached nodes are seen when doing a scan. From Marcin Piotr Pawlowski, feedback stsp@ ok kspillner@ dcoppa@ --- sys/net80211/ieee80211_ioctl.c | 6 ++++-- sys/net80211/ieee80211_node.c | 17 ++++++++++++++++- sys/net80211/ieee80211_node.h | 3 ++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index 9e94783ab4f..45b2022e724 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_ioctl.c,v 1.35 2014/07/10 14:32:28 stsp Exp $ */ +/* $OpenBSD: ieee80211_ioctl.c,v 1.36 2014/09/12 16:02:40 sthen Exp $ */ /* $NetBSD: ieee80211_ioctl.c,v 1.15 2004/05/06 02:58:16 dyoung Exp $ */ /*- @@ -649,8 +649,10 @@ ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (ic->ic_scan_lock & IEEE80211_SCAN_LOCKED) ic->ic_scan_lock |= IEEE80211_SCAN_RESUME; ic->ic_scan_lock |= IEEE80211_SCAN_REQUEST; - if (ic->ic_state != IEEE80211_S_SCAN) + if (ic->ic_state != IEEE80211_S_SCAN) { + ieee80211_clean_cached(ic); ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); + } } /* Let the userspace process wait for completion */ error = tsleep(&ic->ic_scan_lock, PCATCH, "80211scan", diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 5829d0e33bb..192eb90c417 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.c,v 1.82 2014/08/08 15:16:39 jasper Exp $ */ +/* $OpenBSD: ieee80211_node.c,v 1.83 2014/09/12 16:02:40 sthen Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /*- @@ -1134,6 +1134,21 @@ ieee80211_free_allnodes(struct ieee80211com *ic) ieee80211_node_cleanup(ic, ic->ic_bss); /* for station mode */ } +void +ieee80211_clean_cached(struct ieee80211com *ic) +{ + struct ieee80211_node *ni, *next_ni; + int s; + + s = splnet(); + for (ni = RB_MIN(ieee80211_tree, &ic->ic_tree); + ni != NULL; ni = next_ni) { + next_ni = RB_NEXT(ieee80211_tree, &ic->ic_tree, ni); + if (ni->ni_state == IEEE80211_STA_CACHE) + ieee80211_free_node(ic, ni); + } + splx(s); +} /* * Timeout inactive nodes. * diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index 20e2d52f424..2d6016ff6a3 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.h,v 1.45 2014/03/20 13:19:06 mpi Exp $ */ +/* $OpenBSD: ieee80211_node.h,v 1.46 2014/09/12 16:02:40 sthen Exp $ */ /* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */ /*- @@ -325,6 +325,7 @@ extern void ieee80211_free_allnodes(struct ieee80211com *); typedef void ieee80211_iter_func(void *, struct ieee80211_node *); extern void ieee80211_iterate_nodes(struct ieee80211com *ic, ieee80211_iter_func *, void *); +extern void ieee80211_clean_cached(struct ieee80211com *ic); extern void ieee80211_clean_nodes(struct ieee80211com *, int); extern int ieee80211_setup_rates(struct ieee80211com *, struct ieee80211_node *, const u_int8_t *, const u_int8_t *, int); -- cgit v1.2.3