From nobody Mon Sep 18 19:11:31 2023 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 4RqDtC40Mvz4td20; Mon, 18 Sep 2023 19:11:31 +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 4RqDtC3RNBz4Gjy; Mon, 18 Sep 2023 19:11:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695064291; 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=Ia+VkntUAFuSfeT3uG9fgnbjwdDBjgswQL/k+/s4yck=; b=KP/MI+J398ogK8z6TdEEbD4QkGteyODr1oy4M+zg+0Qg8VTpWE8Ahp2h5JDxd53OqFy0FP wTx9okK8iCHNXbXXpnxKX7EBOlVQyd4nHHMKX3oRcykS5QEuEjKAkZmgGHqMKRDEJvxV9l +8rdqHMEnUsogT996vqzTOP4RIhkOnatHJcbIWUQO00Mrsu3acNIvJEvvOzugXrarkHXkf q8G6M8lswuIOE6lTw4aHHULh1W3DMgrUYI7txlMKzk/ZsVJK0wHesD3KN+QYMmjgYTOL4H 3JmhgM34AiKaW0SfZL88g/cm+9WJoUtZiofYJKRhM2MX3vBhgKkJZNnpXqvJhA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695064291; a=rsa-sha256; cv=none; b=Wwe946nBIsqjsG3G74G/WEYf1oZKwJ3eqYpq9lgQm8vbISkUcgMXA8aq2HLTIaV8QoXOwA y0S7yT8rYsrgzgdBn9BimYbD1blwZECw7agMg1rqXRY3gf96EXKQgqexv8FTXVnoq4GcvY ehhU+42d3Tut5eOruLQjAYzK4Whs+7TxVGCjlA8kNjpvPAaxw7B4oaPDXv6YgtZK1xvN0m wW5uADKO0TRP1+hw/aqP+IaioCMM+M5gzOaOdB4VgYH//QawY/v9Duq1+F0nX+Mk4kfCJs a6FCQkHKAneWAKz6vTkPqFRNY1i3e84qHt1ih/8G1yLawnhEa/jJnJpaabuA9g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695064291; 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=Ia+VkntUAFuSfeT3uG9fgnbjwdDBjgswQL/k+/s4yck=; b=Ub60xn6nt1Kp1do5SnIBvCCkDf4eJIcV8tGbzHRG22INLM4fCyAJXqai/qdZ0PTTJoaaE/ p1cgWBjQCiQKh0aA+qneD2cmz1u0aQop7WDXBVsGOP8uuvAGF7PCFnwEJ3zCBz5i3qz8Pb Ze3YiNHeQq7INPNiVtJp8ktH0N1pkZxrArcUa+g2bgmRImxv3HIpWZAClucS+ySoUtrxB7 iI8/FssVcS4QTrgfCFGdrHDvkSJo9nctJn2E/UYe4jlvj/iFbu1eg/B0bBL1omdmx47GbM 4/VdDXGo4Ho4lDFjY/Ls/aEn8FS+eUjmhevQQeKXBFFiToWW0VGCLv6f1tawKg== 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 4RqDtC2Lj5zjK5; Mon, 18 Sep 2023 19:11:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38IJBVSg072919; Mon, 18 Sep 2023 19:11:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38IJBVSZ072916; Mon, 18 Sep 2023 19:11:31 GMT (envelope-from git) Date: Mon, 18 Sep 2023 19:11:31 GMT Message-Id: <202309181911.38IJBVSZ072916@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Navdeep Parhar Subject: git: 38da3db5f9e3 - stable/14 - cxgbe(4): Fix tracing with netlink enabled kernels. 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: np X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 38da3db5f9e3e9bc9eba30a2c560bfe660ce95ec Auto-Submitted: auto-generated The branch stable/14 has been updated by np: URL: https://cgit.FreeBSD.org/src/commit/?id=38da3db5f9e3e9bc9eba30a2c560bfe660ce95ec commit 38da3db5f9e3e9bc9eba30a2c560bfe660ce95ec Author: Navdeep Parhar AuthorDate: 2023-09-09 19:39:15 +0000 Commit: Navdeep Parhar CommitDate: 2023-09-18 18:57:51 +0000 cxgbe(4): Fix tracing with netlink enabled kernels. 1. The tracing ifnet's name must match the nexus name. One way to do this is to not use a unit number. 2. Do not hold the tracer lock around ether_ifattach or ether_ifdetach. netlink calls back into the driver (see stack below) and that leads to illegal lock recursion. tracer_ioctl if_ioctl get_operstate_ether get_operstate dump_iface rtnl_handle_ifevent rtnl_handle_ifattach if_attach_internal if_attach ether_ifattach t4_cloner_create MFC after: 3 days Sponsored by: Chelsio Communications (cherry picked from commit e203cb393fe0b963dd585d0576dcc6a47a28c386) --- sys/dev/cxgbe/t4_tracer.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/sys/dev/cxgbe/t4_tracer.c b/sys/dev/cxgbe/t4_tracer.c index 4190aa627b14..d9b336c4b64a 100644 --- a/sys/dev/cxgbe/t4_tracer.c +++ b/sys/dev/cxgbe/t4_tracer.c @@ -138,7 +138,7 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) struct match_rr mrr; struct adapter *sc; if_t ifp; - int rc, unit; + int rc; const uint8_t lla[ETHER_ADDR_LEN] = {0, 0, 0, 0, 0, 0}; mrr.name = name; @@ -166,21 +166,14 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) goto done; } - - unit = -1; - rc = ifc_alloc_unit(ifc, &unit); - if (rc != 0) - goto done; - ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - ifc_free_unit(ifc, unit); rc = ENOMEM; goto done; } - /* Note that if_xname is not . */ - if_initname(ifp, name, unit); + /* Note that if_xname is identical to the nexus nameunit */ + if_initname(ifp, name, -1); if_setdname(ifp, t4_cloner_name); if_setinitfn(ifp, tracer_init); if_setflags(ifp, IFF_SIMPLEX | IFF_DRV_RUNNING); @@ -192,12 +185,14 @@ t4_cloner_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) tracer_media_status); ifmedia_add(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE, 0, NULL); ifmedia_set(&sc->media, IFM_ETHER | IFM_FDX | IFM_NONE); + sx_xunlock(&t4_trace_lock); ether_ifattach(ifp, lla); - + sx_xlock(&t4_trace_lock); mtx_lock(&sc->ifp_lock); if_setsoftc(ifp, sc); sc->ifp = ifp; mtx_unlock(&sc->ifp_lock); + rc = 0; done: sx_xunlock(&t4_trace_lock); end_synchronized_op(sc, 0); @@ -208,7 +203,6 @@ static int t4_cloner_destroy(struct if_clone *ifc, if_t ifp) { struct adapter *sc; - int unit = if_getdunit(ifp); sx_xlock(&t4_trace_lock); sc = if_getsoftc(ifp); @@ -219,10 +213,9 @@ t4_cloner_destroy(struct if_clone *ifc, if_t ifp) mtx_unlock(&sc->ifp_lock); ifmedia_removeall(&sc->media); } + sx_xunlock(&t4_trace_lock); ether_ifdetach(ifp); if_free(ifp); - ifc_free_unit(ifc, unit); - sx_xunlock(&t4_trace_lock); return (0); }