From 5f8ede55b16b0bbd3fc48143025ff3e69f67e60e Mon Sep 17 00:00:00 2001 From: stsp Date: Thu, 15 Apr 2021 18:14:45 +0000 Subject: [PATCH] Make athn(4) set the channel when hostap or monitor modes enter RUN state. Fixes a problem where the hardware would end up using a different channel than the one selected by net80211. Found while investigating issues reported by trondd testing my athn RA patch. ok deraadt@ --- sys/dev/ic/athn.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/dev/ic/athn.c b/sys/dev/ic/athn.c index d20bb5615c2..3570b8d389a 100644 --- a/sys/dev/ic/athn.c +++ b/sys/dev/ic/athn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: athn.c,v 1.109 2020/07/10 13:22:19 patrick Exp $ */ +/* $OpenBSD: athn.c,v 1.110 2021/04/15 18:14:45 stsp Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini @@ -2660,9 +2660,19 @@ athn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) break; case IEEE80211_S_RUN: athn_set_led(sc, 1); - - if (ic->ic_opmode == IEEE80211_M_MONITOR) +#ifndef IEEE80211_STA_ONLY + if (ic->ic_opmode == IEEE80211_M_HOSTAP) { + error = athn_switch_chan(sc, ic->ic_bss->ni_chan, NULL); + if (error != 0) + return (error); + } else +#endif + if (ic->ic_opmode == IEEE80211_M_MONITOR) { + error = athn_switch_chan(sc, ic->ic_ibss_chan, NULL); + if (error != 0) + return (error); break; + } /* Fake a join to initialize the Tx rate. */ athn_newassoc(ic, ic->ic_bss, 1); -- 2.20.1