Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/net80211 Avoid recursive locking via ieee80211_wme...
details: https://anonhg.NetBSD.org/src-all/rev/0987c636a8d8
branches: trunk
changeset: 1027117:0987c636a8d8
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Sun Oct 17 11:29:26 2021 +0200
description:
Avoid recursive locking via ieee80211_wme_initparams.
Split it into ieee80211_wme_initparams and ieee80211_wme_initparams_locked,
and provide info for the call sides which one is needed (in cases where
it is not a static contract).
Parts from and tested by James Browning.
diffstat:
sys/net80211/ieee80211_ioctl.c | 2 +-
sys/net80211/ieee80211_node.c | 41 ++++++++++++++++++++++++++++----------
sys/net80211/ieee80211_node.h | 2 +-
sys/net80211/ieee80211_proto.c | 2 +-
sys/net80211/ieee80211_proto.h | 1 +
sys/net80211/ieee80211_scan_sta.c | 9 ++++---
6 files changed, 39 insertions(+), 18 deletions(-)
diffs (196 lines):
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_ioctl.c
--- a/sys/net80211/ieee80211_ioctl.c Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_ioctl.c Sun Oct 17 11:29:26 2021 +0200
@@ -1737,7 +1737,7 @@
if (lookup.se == NULL)
return ENOENT;
mlmedebug(vap, mac, IEEE80211_MLME_ASSOC, 0);
- if (!ieee80211_sta_join(vap, lookup.se->se_chan, lookup.se))
+ if (!ieee80211_sta_join(vap, lookup.se->se_chan, lookup.se, false))
return EIO; /* XXX unique but could be better */
return 0;
}
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_node.c
--- a/sys/net80211/ieee80211_node.c Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_node.c Sun Oct 17 11:29:26 2021 +0200
@@ -95,7 +95,7 @@
#define IEEE80211_AID_ISSET(_vap, b) \
((_vap)->iv_aid_bitmap[IEEE80211_AID(b) / 32] & (1 << (IEEE80211_AID(b) % 32)))
-static int ieee80211_sta_join1(struct ieee80211_node *);
+static int ieee80211_sta_join1(struct ieee80211_node *, bool);
static struct ieee80211_node *node_alloc(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
@@ -455,7 +455,7 @@
ieee80211_ht_node_init(ni);
}
- (void) ieee80211_sta_join1(ieee80211_ref_node(ni));
+ (void) ieee80211_sta_join1(ieee80211_ref_node(ni), true);
}
/*
@@ -720,7 +720,7 @@
vap->iv_flags&IEEE80211_F_SHSLOT ? "short" : "long",
ic->ic_flags&IEEE80211_F_USEPROT ? ", protection" : ""
);
- return ieee80211_sta_join1(ieee80211_ref_node(ni));
+ return ieee80211_sta_join1(ieee80211_ref_node(ni), false /* ??? */);
}
/*
@@ -871,7 +871,7 @@
* be passed in with a held reference.
*/
static int
-ieee80211_sta_join1(struct ieee80211_node *selbs)
+ieee80211_sta_join1(struct ieee80211_node *selbs, bool ic_is_locked)
{
struct ieee80211vap *vap = selbs->ni_vap;
struct ieee80211com *ic = selbs->ni_ic;
@@ -917,12 +917,19 @@
* mode is locked.
*/
ieee80211_reset_erp(ic);
- ieee80211_wme_initparams(vap);
+ if (ic_is_locked)
+ ieee80211_wme_initparams_locked(vap);
+ else
+ ieee80211_wme_initparams(vap);
if (vap->iv_opmode == IEEE80211_M_STA) {
if (canreassoc) {
/* Reassociate */
- ieee80211_new_state(vap, IEEE80211_S_ASSOC, 1);
+ if (ic_is_locked)
+ ieee80211_new_state_locked(vap,
+ IEEE80211_S_ASSOC, 1);
+ else
+ ieee80211_new_state(vap, IEEE80211_S_ASSOC, 1);
} else {
/*
* Act as if we received a DEAUTH frame in case we
@@ -930,22 +937,34 @@
* us to try to re-authenticate if we are operating
* as a station.
*/
- ieee80211_new_state(vap, IEEE80211_S_AUTH,
- IEEE80211_FC0_SUBTYPE_DEAUTH);
+ if (ic_is_locked)
+ ieee80211_new_state_locked(vap,
+ IEEE80211_S_AUTH,
+ IEEE80211_FC0_SUBTYPE_DEAUTH);
+ else
+ ieee80211_new_state(vap, IEEE80211_S_AUTH,
+ IEEE80211_FC0_SUBTYPE_DEAUTH);
}
} else
- ieee80211_new_state(vap, IEEE80211_S_RUN, -1);
+ if (ic_is_locked)
+ ieee80211_new_state_locked(vap, IEEE80211_S_RUN, -1);
+ else
+ ieee80211_new_state(vap, IEEE80211_S_RUN, -1);
return 1;
}
int
ieee80211_sta_join(struct ieee80211vap *vap, struct ieee80211_channel *chan,
- const struct ieee80211_scan_entry *se)
+ const struct ieee80211_scan_entry *se, bool ic_is_locked)
{
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_node *ni;
int do_ht = 0;
+ if (ic_is_locked) {
+ IEEE80211_LOCK_ASSERT(ic);
+ }
+
ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr);
if (ni == NULL) {
/* XXX msg */
@@ -1084,7 +1103,7 @@
ether_snprintf(temp2, sizeof(temp2), ni->ni_bssid));
#endif
- return ieee80211_sta_join1(ieee80211_ref_node(ni));
+ return ieee80211_sta_join1(ieee80211_ref_node(ni), ic_is_locked);
}
/*
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_node.h
--- a/sys/net80211/ieee80211_node.h Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_node.h Sun Oct 17 11:29:26 2021 +0200
@@ -367,7 +367,7 @@
int ieee80211_ibss_merge(struct ieee80211_node *);
struct ieee80211_scan_entry;
int ieee80211_sta_join(struct ieee80211vap *, struct ieee80211_channel *,
- const struct ieee80211_scan_entry *);
+ const struct ieee80211_scan_entry *, bool);
void ieee80211_sta_leave(struct ieee80211_node *);
void ieee80211_node_deauth(struct ieee80211_node *, int);
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_proto.c
--- a/sys/net80211/ieee80211_proto.c Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_proto.c Sun Oct 17 11:29:26 2021 +0200
@@ -1205,7 +1205,7 @@
wmep->wmep_logcwmax, wmep->wmep_txopLimit);
}
-static void
+void
ieee80211_wme_initparams_locked(struct ieee80211vap *vap)
{
struct ieee80211com *ic = vap->iv_ic;
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_proto.h
--- a/sys/net80211/ieee80211_proto.h Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_proto.h Sun Oct 17 11:29:26 2021 +0200
@@ -306,6 +306,7 @@
};
void ieee80211_wme_initparams(struct ieee80211vap *);
+void ieee80211_wme_initparams_locked(struct ieee80211vap *);
void ieee80211_wme_updateparams(struct ieee80211vap *);
void ieee80211_wme_updateparams_locked(struct ieee80211vap *);
void ieee80211_wme_vap_getparams(struct ieee80211vap *vap,
diff -r 357aa1eab498 -r 0987c636a8d8 sys/net80211/ieee80211_scan_sta.c
--- a/sys/net80211/ieee80211_scan_sta.c Thu Sep 23 18:21:43 2021 +0200
+++ b/sys/net80211/ieee80211_scan_sta.c Sun Oct 17 11:29:26 2021 +0200
@@ -1368,7 +1368,7 @@
chan = selbs->base.se_chan;
if (selbs->se_flags & STA_DEMOTE11B)
chan = demote11b(vap, chan);
- if (!ieee80211_sta_join(vap, chan, &selbs->base))
+ if (!ieee80211_sta_join(vap, chan, &selbs->base, true))
goto notfound;
IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
"%s: terminate scan; return 1\n", __func__);
@@ -1466,7 +1466,8 @@
chan = selbs->base.se_chan;
if (selbs->se_flags & STA_DEMOTE11B)
chan = demote11b(vap, chan);
- (void) ieee80211_sta_join(vap, chan, &selbs->base);
+ (void) ieee80211_sta_join(vap, chan, &selbs->base,
+ false);
}
}
}
@@ -1776,7 +1777,7 @@
chan, vap->iv_flags_ht);
chan = ieee80211_vht_adjust_channel(ic,
chan, vap->iv_flags_vht);
- if (!ieee80211_sta_join(vap, chan, &selbs->base))
+ if (!ieee80211_sta_join(vap, chan, &selbs->base, true))
goto notfound;
return 1; /* terminate scan */
}
@@ -2045,7 +2046,7 @@
chan = selbs->base.se_chan;
if (selbs->se_flags & STA_DEMOTE11B)
chan = demote11b(vap, chan);
- if (!ieee80211_sta_join(vap, chan, &selbs->base))
+ if (!ieee80211_sta_join(vap, chan, &selbs->base, true))
goto notfound;
return 1; /* terminate scan */
}
Home |
Main Index |
Thread Index |
Old Index