From nobody Mon Apr 14 14:07:41 2025 X-Original-To: dev-commits-src-main@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 4Zbpyj41t7z5ssc3; Mon, 14 Apr 2025 14:07:41 +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 4Zbpyj252yz3QZw; Mon, 14 Apr 2025 14:07:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744639661; 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=Z8Zvween5FsShiOwNce46yn8ih26iVZf6aIf0oBEjBg=; b=xEpCm/lkxioKf8eU1M8cDEK4K8pD8FtsAwL62DKaFBxNPFoUY9DbBfYMaQNfHaIlIQGM6r Zu+GsUJNEaPeee318J1nB3Xv4BfTVVmBle3FMkacvdq1LVN4isFB/g3KUhaPxzjaWxRamt FtDOpwHhXll+6upqiHJcvgNPM72X0c3e9R9awHJgNStgvfR3ZyC5TOV4Phmmswq67b5UVZ FZWkJnaS7taH0DhGaCtKIs9V1S6lKHCtS58zKcN2PQ6BtqPGp0ouaztY+AHbJ+iZSVeqDJ qvLLb1xj2Y84DXeyu3YU95w0Km+dD5wBc41EDUHeaVvMoZ2hmooXm5BtJ90Bwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744639661; a=rsa-sha256; cv=none; b=GV2H130Ak6O8LBeWCNmH7V6KAR+MswGxmVIiIkuge8fby3Gghh7nu8NjkQvekjTgsxDiiK vnpVnEpygklYUV+x0qqYBAiRDdu24rGZ0R3j260yMw/dS1OuVCcV6lvtq/upImsyUsynkF gM+8lEh+nICJDGMx9SwoSlFsWQ+4OD7/+QkLIOEmYujeqwFj6VZvxB8ApkvNLHwQwEwHka IdzR4R9KsF4WV9uzkwgyXSv25OCNF/6DGXkJm8qa7Xset/0S7GP1jbp7j+JYWgfP1UsMVC /7UEr0880i9HI5M1L424k/a6VtECQNPkmwJOB+FtzLCAam0Vs2pra7KaUc/fSQ== 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=1744639661; 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=Z8Zvween5FsShiOwNce46yn8ih26iVZf6aIf0oBEjBg=; b=SDSlU0fbE5hHC3ltIbxoE4tOIyG7QvAKMovBziNmHbDrFcjQb1v8QgYC5NC29bwfSdabHk sF1T5gqVEl1ddHEmJ0cBecMvN5klfffCcEZ6xwJuuXtxUFU6rw2Efnkm5DeuBacKNahWTs Fy6A9oYkwXA7FOY+ydJ7nmA7Snjx2Af8JH+4WknQV/N86ge6x2fc54xsGryGeZFnmLFl2w /2k3ZEG1np3/9dBu1T5DYfi43ZvOpoNtwzBrsZrlic+yw0SlqrA7NEmdXGUkBa2LSyXCId xyn0GewcYVJGKpMn9T9FJmga9iRmyU4w3ndxPHID/bOwavRXn56/d7FdfuOevQ== 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 4Zbpyj1TzKzrfn; Mon, 14 Apr 2025 14:07:41 +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 53EE7fjh032451; Mon, 14 Apr 2025 14:07:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53EE7fH5032449; Mon, 14 Apr 2025 14:07:41 GMT (envelope-from git) Date: Mon, 14 Apr 2025 14:07:41 GMT Message-Id: <202504141407.53EE7fH5032449@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: c013f810ecb6 - main - LinuxKPI: 802.11: better dealing with errors in RX path List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: c013f810ecb615289c2bd69a10f4317a3a867d50 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c013f810ecb615289c2bd69a10f4317a3a867d50 commit c013f810ecb615289c2bd69a10f4317a3a867d50 Author: Bjoern A. Zeeb AuthorDate: 2025-04-13 20:53:36 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-14 14:06:50 +0000 LinuxKPI: 802.11: better dealing with errors in RX path In case we fail to allocate the mbuf or mtag in the RX path or fail for other reasons report it as ic_ierrors for better diagnostics and more correct statistics. Also do what the comment had indicated and mandate that mtag allocation succeeds or otherwise drop the packet. There may be room for future improvements in a follow-up commit here. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/compat/linuxkpi/common/src/linux_80211.c | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index fbbaf860c233..34b2a3a2f8f9 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -6447,8 +6447,12 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, uint8_t rssi; bool is_beacon; + lhw = HW_TO_LHW(hw); + ic = lhw->ic; + if (skb->len < 2) { /* Need 80211 stats here. */ + counter_u64_add(ic->ic_ierrors, 1); IMPROVE(); goto err; } @@ -6458,8 +6462,10 @@ linuxkpi_ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, * have an mbuf backing the skb data then? */ m = m_get2(skb->len, M_NOWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) + if (m == NULL) { + counter_u64_add(ic->ic_ierrors, 1); goto err; + } m_copyback(m, 0, skb->tail - skb->data, skb->data); shinfo = skb_shinfo(skb); @@ -6524,9 +6530,6 @@ no_trace_beacons: rssi = 0; lkpi_convert_rx_status(hw, rx_status, &rx_stats, &rssi); - lhw = HW_TO_LHW(hw); - ic = lhw->ic; - ok = ieee80211_add_rx_params(m, &rx_stats); if (ok == 0) { m_freem(m); @@ -6629,28 +6632,28 @@ skip_device_ts: } #endif - /* - * Attach meta-information to the mbuf for the deferred RX path. - * Currently this is best-effort. Should we need to be hard, - * drop the frame and goto err; - */ + /* Attach meta-information to the mbuf for the deferred RX path. */ if (ni != NULL) { struct m_tag *mtag; struct lkpi_80211_tag_rxni *rxni; mtag = m_tag_alloc(MTAG_ABI_LKPI80211, LKPI80211_TAG_RXNI, sizeof(*rxni), IEEE80211_M_NOWAIT); - if (mtag != NULL) { - rxni = (struct lkpi_80211_tag_rxni *)(mtag + 1); - rxni->ni = ni; /* We hold a reference. */ - m_tag_prepend(m, mtag); + if (mtag == NULL) { + m_freem(m); + counter_u64_add(ic->ic_ierrors, 1); + goto err; } + rxni = (struct lkpi_80211_tag_rxni *)(mtag + 1); + rxni->ni = ni; /* We hold a reference. */ + m_tag_prepend(m, mtag); } LKPI_80211_LHW_RXQ_LOCK(lhw); if (lhw->rxq_stopped) { LKPI_80211_LHW_RXQ_UNLOCK(lhw); m_freem(m); + counter_u64_add(ic->ic_ierrors, 1); goto err; }