summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2019-11-06 13:55:45 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2019-11-06 13:55:45 +0000
commit61ab6665518399ce799940570f58e3dbbfc654e2 (patch)
tree2253b8f9d014ebc020fb68678b2ace428b8b149d
parent6e1c78e76908146800e0e242e140a1672222dcb0 (diff)
Raise net80211's "beacon miss" threshold to avoid frequent re-connects
to APs that are relatively far away and suffer some packet loss. The former threshold was 7 beacons (about 700 ms). This raises the threshold to 30 beacons (about 3 seconds). Should still be good enough for detecting APs that have disappeared, and makes wifi networks provided by the University of Bucharest more reliable in the p2k19 hackroom. While here, make 'ifconfig iwm0/iwn0 debug' print an obvious message when we believe that the AP has disappeared. Problem reported and fix tested by landry@ / pirofti@ ok mpi@ sthen@
-rw-r--r--sys/dev/pci/if_iwm.c6
-rw-r--r--sys/dev/pci/if_iwn.c11
-rw-r--r--sys/net80211/ieee80211.c4
-rw-r--r--sys/net80211/ieee80211_proto.c9
-rw-r--r--sys/net80211/ieee80211_var.h15
5 files changed, 35 insertions, 10 deletions
diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c
index e07312ca52c..f845cbd7b57 100644
--- a/sys/dev/pci/if_iwm.c
+++ b/sys/dev/pci/if_iwm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwm.c,v 1.276 2019/11/04 13:43:09 stsp Exp $ */
+/* $OpenBSD: if_iwm.c,v 1.277 2019/11/06 13:55:43 stsp Exp $ */
/*
* Copyright (c) 2014, 2016 genua gmbh <info@genua.de>
@@ -3810,6 +3810,10 @@ iwm_rx_bmiss(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
missed = le32toh(mbn->consec_missed_beacons_since_last_rx);
if (missed > ic->ic_bmissthres && ic->ic_mgt_timer == 0) {
+ if (ic->ic_if.if_flags & IFF_DEBUG)
+ printf("%s: receiving no beacons from %s; checking if "
+ "this AP is still responding to probe requests\n",
+ DEVNAME(sc), ether_sprintf(ic->ic_bss->ni_macaddr));
/*
* Rather than go directly to scan state, try to send a
* directed probe request first. If that fails then the
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index 133d67bef5d..8b405460ed1 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.219 2019/10/09 09:21:45 tobhe Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.220 2019/11/06 13:55:43 stsp Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -2819,9 +2819,16 @@ iwn_notif_intr(struct iwn_softc *sc)
* state machine will drop us into scanning after timing
* out waiting for a probe response.
*/
- if (missed > ic->ic_bmissthres && !ic->ic_mgt_timer)
+ if (missed > ic->ic_bmissthres && !ic->ic_mgt_timer) {
+ if (ic->ic_if.if_flags & IFF_DEBUG)
+ printf("%s: receiving no beacons from "
+ "%s; checking if this AP is still "
+ "responding to probe requests\n",
+ sc->sc_dev.dv_xname, ether_sprintf(
+ ic->ic_bss->ni_macaddr));
IEEE80211_SEND_MGMT(ic, ic->ic_bss,
IEEE80211_FC0_SUBTYPE_PROBE_REQ, 0);
+ }
break;
}
case IWN_UC_READY:
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index ace97a38cc4..bf2b2858f03 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211.c,v 1.78 2019/09/02 12:50:12 stsp Exp $ */
+/* $OpenBSD: ieee80211.c,v 1.79 2019/11/06 13:55:44 stsp Exp $ */
/* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */
/*-
@@ -181,7 +181,7 @@ ieee80211_ifattach(struct ifnet *ifp)
if (ic->ic_lintval == 0)
ic->ic_lintval = 100; /* default sleep */
- ic->ic_bmissthres = 7; /* default 7 beacons */
+ ic->ic_bmissthres = IEEE80211_BEACON_MISS_THRES;
ic->ic_dtim_period = 1; /* all TIMs are DTIMs */
ieee80211_node_attach(ifp);
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index d00d1b631f2..b44405af414 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_proto.c,v 1.95 2019/09/02 12:54:21 stsp Exp $ */
+/* $OpenBSD: ieee80211_proto.c,v 1.96 2019/11/06 13:55:44 stsp Exp $ */
/* $NetBSD: ieee80211_proto.c,v 1.8 2004/04/30 23:58:20 dyoung Exp $ */
/*-
@@ -909,10 +909,11 @@ ieee80211_set_beacon_miss_threshold(struct ieee80211com *ic)
/*
* Scale the missed beacon counter threshold to the AP's actual
- * beacon interval. Give the AP at least 700 ms to time out and
- * round up to ensure that at least one beacon may be missed.
+ * beacon interval.
*/
- int btimeout = MIN(7 * ic->ic_bss->ni_intval, 700);
+ int btimeout = MIN(IEEE80211_BEACON_MISS_THRES * ic->ic_bss->ni_intval,
+ IEEE80211_BEACON_MISS_THRES * (IEEE80211_DUR_TU / 10));
+ /* Ensure that at least one beacon may be missed. */
btimeout = MAX(btimeout, 2 * ic->ic_bss->ni_intval);
if (ic->ic_bss->ni_intval > 0) /* don't crash if interval is bogus */
ic->ic_bmissthres = btimeout / ic->ic_bss->ni_intval;
diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h
index b493ff0a536..d5560e75f48 100644
--- a/sys/net80211/ieee80211_var.h
+++ b/sys/net80211/ieee80211_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_var.h,v 1.98 2019/10/31 11:03:43 stsp Exp $ */
+/* $OpenBSD: ieee80211_var.h,v 1.99 2019/11/06 13:55:44 stsp Exp $ */
/* $NetBSD: ieee80211_var.h,v 1.7 2004/05/06 03:07:10 dyoung Exp $ */
/*-
@@ -64,6 +64,19 @@
#define IEEE80211_BGSCAN_FAIL_MAX 512 /* units of 500 msec */
+/*
+ * Missed beacon threshold: An access point has disappeared if this amount
+ * of consecutive beacons have been missed.
+ * This value needs to be high enough to avoid frequent re-connects to APs
+ * which suffer from occasional packet loss, and low enough to avoid a long
+ * delay before we start scanning when an AP has actually disappeared.
+ *
+ * The beacon interval is variable, but generally in the order of 100ms.
+ * So 30 beacons implies a grace period of about 3 seconds before we start
+ * searching for a new AP.
+ */
+#define IEEE80211_BEACON_MISS_THRES 30 /* units of beacons */
+
enum ieee80211_phytype {
IEEE80211_T_DS, /* direct sequence spread spectrum */
IEEE80211_T_OFDM, /* frequency division multiplexing */