Skip to content

Commit 2b470c3

Browse files
bcopelandjmberg-intel
authored andcommitted
mac80211: remove ignore_plink_timer flag
The mesh_plink code is doing some interesting things with the ignore_plink_timer flag. It seems the original intent was to handle this race: cpu 0 cpu 1 ----- ----- start timer handler for state X acquire sta_lock change state from X to Y mod_timer() / del_timer() release sta_lock acquire sta_lock execute state Y timer too soon However, using the mod_timer()/del_timer() return values to detect these cases is broken. As a result, timers get ignored unnecessarily, and stations can get stuck in the peering state machine. Instead, we can detect the case by looking at the timer expiration. In the case of del_timer, just ignore the timers in the following (LISTEN/ESTAB) states since they won't have timers anyway. Signed-off-by: Bob Copeland <me@bobcopeland.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 5ac2e35 commit 2b470c3

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

‎net/mac80211/mesh_plink.c‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,30 @@ static void mesh_plink_timer(unsigned long data)
551551
return;
552552

553553
spin_lock_bh(&sta->lock);
554-
if (sta->ignore_plink_timer) {
555-
sta->ignore_plink_timer = false;
554+
555+
/* If a timer fires just before a state transition on another CPU,
556+
* we may have already extended the timeout and changed state by the
557+
* time we've acquired the lock and arrived here. In that case,
558+
* skip this timer and wait for the new one.
559+
*/
560+
if (time_before(jiffies, sta->plink_timer.expires)) {
561+
mpl_dbg(sta->sdata,
562+
"Ignoring timer for %pM in state %s (timer adjusted)",
563+
sta->sta.addr, mplstates[sta->plink_state]);
556564
spin_unlock_bh(&sta->lock);
557565
return;
558566
}
567+
568+
/* del_timer() and handler may race when entering these states */
569+
if (sta->plink_state == NL80211_PLINK_LISTEN ||
570+
sta->plink_state == NL80211_PLINK_ESTAB) {
571+
mpl_dbg(sta->sdata,
572+
"Ignoring timer for %pM in state %s (timer deleted)",
573+
sta->sta.addr, mplstates[sta->plink_state]);
574+
spin_unlock_bh(&sta->lock);
575+
return;
576+
}
577+
559578
mpl_dbg(sta->sdata,
560579
"Mesh plink timer for %pM fired on state %s\n",
561580
sta->sta.addr, mplstates[sta->plink_state]);
@@ -773,9 +792,7 @@ static u32 mesh_plink_fsm(struct ieee80211_sub_if_data *sdata,
773792
break;
774793
case CNF_ACPT:
775794
sta->plink_state = NL80211_PLINK_CNF_RCVD;
776-
if (!mod_plink_timer(sta,
777-
mshcfg->dot11MeshConfirmTimeout))
778-
sta->ignore_plink_timer = true;
795+
mod_plink_timer(sta, mshcfg->dot11MeshConfirmTimeout);
779796
break;
780797
default:
781798
break;
@@ -834,8 +851,7 @@ static u32 mesh_plink_fsm(struct ieee80211_sub_if_data *sdata,
834851
case NL80211_PLINK_HOLDING:
835852
switch (event) {
836853
case CLS_ACPT:
837-
if (del_timer(&sta->plink_timer))
838-
sta->ignore_plink_timer = 1;
854+
del_timer(&sta->plink_timer);
839855
mesh_plink_fsm_restart(sta);
840856
break;
841857
case OPN_ACPT:

‎net/mac80211/sta_info.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ struct ieee80211_tx_latency_stat {
306306
* @plid: Peer link ID
307307
* @reason: Cancel reason on PLINK_HOLDING state
308308
* @plink_retries: Retries in establishment
309-
* @ignore_plink_timer: ignore the peer-link timer (used internally)
310309
* @plink_state: peer link state
311310
* @plink_timeout: timeout of peer link
312311
* @plink_timer: peer link watch timer
@@ -421,7 +420,6 @@ struct sta_info {
421420
u16 plid;
422421
u16 reason;
423422
u8 plink_retries;
424-
bool ignore_plink_timer;
425423
enum nl80211_plink_state plink_state;
426424
u32 plink_timeout;
427425
struct timer_list plink_timer;

0 commit comments

Comments
 (0)