From nobody Fri Apr 18 14:37:26 2025 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 4ZfHRB48Lfz5stTj; Fri, 18 Apr 2025 14:37:26 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZfHRB272Sz3Kx0; Fri, 18 Apr 2025 14:37:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744987046; 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=N2X9Zv/t4wJo4VmAGSWK0XRcA0XCetXeNG2t4bH/Qgw=; b=xA+Eg+HdimY+KNCIAEmbADVsjuYg3I8OPqn+J7wAr1pTyuAaCEICXrPMRB+zYUOWVwMN4x lOZJxZPBqFU9ZnxBZzWiKe4fh3It2oeCf1MYBQg7+3fK5udFqxYlacsL3TmMGmoqyG9Vry LJyHTKP/BZyxrLuE5gjJfv7fRqTE5cZ7fSEij3/90Z+MvgsVxr3BVtMn2aQXImabRlvHLZ yYk9Hok0GfxLYbAqhZOIuuKKMZLkTOCgDVu88e1Zs5LSN5NZdoENiIfLHJ12tiQb9mZMdf 5emNRi8wK1USojOGavfEFkGftXhDARXDaNxoIJZ+k011SuYNssV+NGEFzSHWsQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744987046; a=rsa-sha256; cv=none; b=FLV4SJS6RrdQqQtPCR15s/SQ631ZFW96R2eyrqDu5muDl+EKV2myTYS60uA/9rJyUWS3do 9khnsPKTABalOHh4wLJkwhU0IXweRsU8ChwDqW5oEayQpmy/KKg6Yx9SdjB2ZU4goLhsGG oup4WmziHD+R10vffclBrgygvX93Xz/vrNepTHk7w+7I6Z6/lIYcorOCRXk1zyftlDUoei 5+l0cLjw3GfRfD+ivYOFJ5ZA4iR4Nrf4WieOp4AHRy6uYSPDD9R7WqDvi7mhMq0Kk+uGst 5AC+a07kwHORiEhJUMj55xKaUUJp+36Mtb58ZZV8x/5sv2xYZDomFadMG0To2Q== 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=1744987046; 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=N2X9Zv/t4wJo4VmAGSWK0XRcA0XCetXeNG2t4bH/Qgw=; b=WOz1OgmPMnbUXJY8VlrPoZC7v6LaTHGC0PAgIXywiYLEixehzq8ajFe5FTYDTP4EqTmFxo zTy6WjDaI2HyAabMLtMXGy7gdqhu9jst+EqVj7V26MNEwZjZFj8tCMSgd/8ztNRQfVHJ8C mqM5NvOFy9vZi5zb6rhmjbDDmPge0D7Im2/HEEhAh2ZqEmpXHbsm4dqNRwij0h4Pa4zEvA wdnIgyjCkEuEujRan9DbqUI0sV6X3qs4zqZrtiY670jEXXEyHqXMgmew84EzUibv+6AgEy 09/j3lfLK0KUmkl6wNc4OXdlQ2CW1O08hiSwIIBrJsZCrD7ic/aDsmm3KCpMOg== 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 4ZfHRB1ZkLzdxy; Fri, 18 Apr 2025 14:37:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53IEbQp8092245; Fri, 18 Apr 2025 14:37:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53IEbQu2092243; Fri, 18 Apr 2025 14:37:26 GMT (envelope-from git) Date: Fri, 18 Apr 2025 14:37:26 GMT Message-Id: <202504181437.53IEbQu2092243@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: 636bb42e6c55 - stable/14 - LinuxKPI: 802.11: deal with the error paths for lkpi_xmit() 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: 636bb42e6c5556beb8a79541cf0d60c0832450c9 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=636bb42e6c5556beb8a79541cf0d60c0832450c9 commit 636bb42e6c5556beb8a79541cf0d60c0832450c9 Author: Bjoern A. Zeeb AuthorDate: 2025-04-13 16:59:56 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-18 14:36:02 +0000 LinuxKPI: 802.11: deal with the error paths for lkpi_xmit() Rename lkpi_ic_raw_xmit() to lkpi_xmit() as we need a wrapper to add an extra argument as (*ic_raw_xmit) and (*ic_transmit) have different invariants. Based on the caller free the mbuf in the error case or not to satisfy the requirements of the caller. For more information see the comment in the code. Sponsored by: The FreeBSD Foundation (cherry picked from commit 9a45c3ca850110c5871742fadbf7355c1085c725) --- sys/compat/linuxkpi/common/src/linux_80211.c | 44 ++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index a5f22046b55c..19ad12d73d12 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -4514,9 +4514,20 @@ lkpi_ic_node_free(struct ieee80211_node *ni) lhw->ic_node_free(ni); } +/* + * lkpi_xmit() called from both the (*ic_raw_xmit) as well as the (*ic_transmit) + * call path. + * Unfortunately they have slightly different invariants. See + * ieee80211_raw_output() and ieee80211_parent_xmitpkt(). + * Both take care of the ni reference in case of error, and otherwise during + * the callback after transmit. + * The difference is that in case of error (*ic_raw_xmit) needs us to release + * the mbuf, while (*ic_transmit) will free the mbuf itself. + */ static int -lkpi_ic_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, - const struct ieee80211_bpf_params *params __unused) +lkpi_xmit(struct ieee80211_node *ni, struct mbuf *m, + const struct ieee80211_bpf_params *params __unused, + bool freem) { struct lkpi_sta *lsta; @@ -4533,16 +4544,24 @@ lkpi_ic_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, if (!lsta->txq_ready) { #endif LKPI_80211_LSTA_TXQ_UNLOCK(lsta); - /* - * Free the mbuf (do NOT release ni ref for the m_pkthdr.rcvif! - * ieee80211_raw_output() does that in case of error). - */ - m_free(m); + if (freem) + m_free(m); return (ENETDOWN); } /* Queue the packet and enqueue the task to handle it. */ - mbufq_enqueue(&lsta->txq, m); + error = mbufq_enqueue(&lsta->txq, m); + if (error != 0) { + LKPI_80211_LSTA_TXQ_UNLOCK(lsta); + if (freem) + m_free(m); +#ifdef LINUXKPI_DEBUG_80211 + if (linuxkpi_debug_80211 & D80211_TRACE_TX) + ic_printf(ni->ni_ic, "%s: mbufq_enqueue failed: %d\n", + __func__, error); +#endif + return (ENETDOWN); + } taskqueue_enqueue(taskqueue_thread, &lsta->txq_task); LKPI_80211_LSTA_TXQ_UNLOCK(lsta); @@ -4556,6 +4575,13 @@ lkpi_ic_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, return (0); } +static int +lkpi_ic_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, + const struct ieee80211_bpf_params *params __unused) +{ + return (lkpi_xmit(ni, m, NULL, true)); +} + #ifdef LKPI_80211_HW_CRYPTO static int lkpi_hw_crypto_prepare(struct lkpi_sta *lsta, struct ieee80211_key *k, @@ -4914,7 +4940,7 @@ lkpi_ic_transmit(struct ieee80211com *ic, struct mbuf *m) struct ieee80211_node *ni; ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - return (lkpi_ic_raw_xmit(ni, m, NULL)); + return (lkpi_xmit(ni, m, NULL, false)); } #ifdef LKPI_80211_HT