From nobody Mon Apr 18 09:33:48 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B2CA011E48F1; Mon, 18 Apr 2022 09:33:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KhhZh4bgTz3CxW; Mon, 18 Apr 2022 09:33:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650274428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nx1c9W3GRBxPDgv5NeP/5HQu7LTBM82nsOQZyw3A8a0=; b=wqyyO59AIutZyuZgJmFOXlVPyIirr+UNE+Jg97UceMVQXndWZKy1vwg2L4Rykf8fuTl1ZT ak6uS2On/XXvVMpgeEoNXY5VyIq5gNa27LjtagnhECd4LZgjezGMXrZz/4G5l1lQqRIs0P n0Gha6mHHff+Pj38yQSSvifvvWxGH4DYJkNItn84oKit8QurXyMB/6x3+ppI1oLaCGNCPU Fyll0hZFlgdPVVeIN5B9Ap/UbA7Gc2bVUBnX0cKlG/LcW3/JE0HMK3j2XT8muCEGUz2A9d nXnzuVi30ZA3j+q40cbfghyNDipeQi6KDYctDNt9HgRPn1TwrE092gKWCRom0w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7DC5A1052D; Mon, 18 Apr 2022 09:33:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23I9Xm2m018462; Mon, 18 Apr 2022 09:33:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23I9Xmt7018461; Mon, 18 Apr 2022 09:33:48 GMT (envelope-from git) Date: Mon, 18 Apr 2022 09:33:48 GMT Message-Id: <202204180933.23I9Xmt7018461@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 4b63d8489ecf - stable/13 - LinuxKPI: 802.11: use an sx lock to protect the list of vifs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4b63d8489ecf29e1acc50f1466b22f529db61eee Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650274428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nx1c9W3GRBxPDgv5NeP/5HQu7LTBM82nsOQZyw3A8a0=; b=oEXJz+iMAPzUwtzfpVy23NdtSIMcF3wkK302aTB6IKdcgbZaXtLKRr4Kz6XROWZWZ+UcB2 2l+7kuHrM4y7bq6LMEiZ+tIS4nqcyhbK4ILmJBDBdXl439FUDHDmPy5NZ2D6pZNA+kA78Q KGX9d8hp8QTYxVFGNuefexU8+fDuab8hkxFjAOJmGoCYN7Ip8dupRsH8uTB3yf/s4F+qTx FvNePhHXKv0ATjT+Z5N5vEC1JFKYiRolKi79p5IjubEdImqY+pOy/HSZ1sRZPbcYtKb9em 7tC3+rHjPYR6nG7ZLgUZn9W0AtwsP2UAH7qX6HBGI243pwzlMUv/fIlCqNEwuA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650274428; a=rsa-sha256; cv=none; b=tE6adycc2pi0TBT0RVNP8a5ZczlkVgDPz6Hd6mhxxZcWmoTl/aYYHC7B3IhNpIR9c+QymD JMyq5TnEpKYJFvhlVvROhUdVmXo6CCEUfcmRv/XHKk8MX25KxduHWr4IJruPWfot4w3qBp MccLp0GHhHsOofUkRieozIngV0Y9hb/7I05xvNKYHgxO6Ad2xmPdnbmTlY9R/izOFTI9gD idQuK9OmK4sISsVUW756W/2RALTIBoP5AF3z4vlCt9Jq1r5QvUDCPcJU1haGWMvZikzYL0 RIBvBeTvO1rIDe/kGDwl5cQosNipD6/8xzCA4xGS9uOslczqPvaLQIhoRMmqcg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=4b63d8489ecf29e1acc50f1466b22f529db61eee commit 4b63d8489ecf29e1acc50f1466b22f529db61eee Author: Bjoern A. Zeeb AuthorDate: 2022-04-15 14:22:43 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-04-18 09:32:57 +0000 LinuxKPI: 802.11: use an sx lock to protect the list of vifs Use an sx lock to protect the list of vifs. We could use the linux mutex compat for this but our current implementation may re-acquire the lock recursively so allow this. The change is mainly motivated by the fact that some callers may sleep in the interator function called. Recursiveness is needed because we see find_sta_by_ifaddr() being called from an iterator function from iterate_interfaces(). Sponsored by: The FreeBSD Foundation (cherry picked from commit 8891c45563f8d3b657a876197c66e00e75214909) --- sys/compat/linuxkpi/common/src/linux_80211.c | 22 ++++++++++++---------- sys/compat/linuxkpi/common/src/linux_80211.h | 4 ++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 001040d025ed..d4fe1a182d6e 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -2261,9 +2261,9 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], return (NULL); } - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_INSERT_TAIL(&lhw->lvif_head, lvif, lvif_entry); - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); /* Set bss_info. */ changed = 0; @@ -2329,9 +2329,9 @@ lkpi_ic_vap_delete(struct ieee80211vap *vap) lhw = ic->ic_softc; hw = LHW_TO_HW(lhw); - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_REMOVE(&lhw->lvif_head, lvif, lvif_entry); - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); lkpi_80211_mo_remove_interface(hw, vif); ieee80211_ratectl_deinit(vap); @@ -3240,6 +3240,7 @@ linuxkpi_ieee80211_alloc_hw(size_t priv_len, const struct ieee80211_ops *ops) lhw->ops = ops; mtx_init(&lhw->mtx, "lhw", NULL, MTX_DEF | MTX_RECURSE); + sx_init_flags(&lhw->lvif_sx, "lhw-lvif", SX_RECURSE | SX_DUPOK); TAILQ_INIT(&lhw->lvif_head); /* @@ -3273,6 +3274,7 @@ linuxkpi_ieee80211_iffree(struct ieee80211_hw *hw) lhw->ic = NULL; /* Cleanup more of lhw here or in wiphy_free()? */ + sx_destroy(&lhw->lvif_sx); mtx_destroy(&lhw->mtx); IMPROVE(); } @@ -3497,7 +3499,7 @@ linuxkpi_ieee80211_iterate_interfaces(struct ieee80211_hw *hw, nin_drv = (flags & IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER) != 0; if (atomic) - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { struct ieee80211vap *vap; @@ -3530,7 +3532,7 @@ linuxkpi_ieee80211_iterate_interfaces(struct ieee80211_hw *hw, iterfunc(arg, vif->addr, vif); } if (atomic) - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); } void @@ -3568,7 +3570,7 @@ linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, lhw = HW_TO_LHW(hw); - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { LKPI_80211_LVIF_LOCK(lvif); @@ -3580,7 +3582,7 @@ linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw, } LKPI_80211_LVIF_UNLOCK(lvif); } - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); } int @@ -3974,7 +3976,7 @@ linuxkpi_ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, lhw = wiphy_priv(hw->wiphy); sta = NULL; - LKPI_80211_LHW_LOCK(lhw); + LKPI_80211_LHW_LVIF_LOCK(lhw); TAILQ_FOREACH(lvif, &lhw->lvif_head, lvif_entry) { /* XXX-BZ check our address from the vif. */ @@ -3987,7 +3989,7 @@ linuxkpi_ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, if (sta != NULL) break; } - LKPI_80211_LHW_UNLOCK(lhw); + LKPI_80211_LHW_LVIF_UNLOCK(lhw); if (sta != NULL) { lsta = STA_TO_LSTA(sta); diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index fabc90e07a87..bdcdb3fbf455 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -140,6 +140,7 @@ struct lkpi_hw { /* name it mac80211_sc? */ struct lkpi_radiotap_rx_hdr rtap_rx; TAILQ_HEAD(, lkpi_vif) lvif_head; + struct sx lvif_sx; struct mtx mtx; @@ -179,6 +180,9 @@ struct lkpi_wiphy { #define LKPI_80211_LHW_UNLOCK_ASSERT(_lhw) \ mtx_assert(&(_lhw)->mtx, MA_NOTOWNED) +#define LKPI_80211_LHW_LVIF_LOCK(_lhw) sx_xlock(&(_lhw)->lvif_sx) +#define LKPI_80211_LHW_LVIF_UNLOCK(_lhw) sx_xunlock(&(_lhw)->lvif_sx) + #define LKPI_80211_LVIF_LOCK(_lvif) mtx_lock(&(_lvif)->mtx) #define LKPI_80211_LVIF_UNLOCK(_lvif) mtx_unlock(&(_lvif)->mtx)