From nobody Wed Nov 18 21:20:28 2026 X-Original-To: dev-commits-src-all@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 4jVDz13kTVz71Hpn for ; Wed, 18 Nov 2026 21:20:29 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jVDz1123dz4FxC for ; Wed, 18 Nov 2026 21:20:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795036829; 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=9Liqr4XTbGCH8ocxR2FZKr+ILfD1AG25ZNGLYGVwizc=; b=O7Zn5FEFXLwg3NP5aFyFP8hePukv3Cytx2+JcuYsVQcO3iWUlFB+fwwwiKPnlZXRTS8Pzr d1P57Hj3tWT9tBvDrIOn/rLoCd7N46xkzkd3/L7lGEm4U9GYA6uVeWhF1XdK7CwBBDaD/f VEOwfwSNcRQDHA5Ch7RLzfEsHYm25n5hVLOhsuDRIFf56Q6rvkySmVNNuRZFLyflBG4g8r LPiM9IzCtKBprMAdankPvEIW4loOjMowmY0Yg0Y8wVDU6a6LPcn0YgTU40FMIp5thfJD4M No+3og7H6PVr9FTk7R80jGEN00VC3WUC8hwrWBjz6iv5P+J36adKgabYWVdyug== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795036829; b=aDMrS9E7FVc0W/eCrE93x7ermnDTizpTDDMjJtlU09NcGJilLEoSIsoEDytg2/w09otXWa /TuiF9O6y5hZmOiHJPCRDd/kvCK6ncAC1JiZmdnkil0htTQ5fHobkZl5hGMtSQw5m5PuIq Px9CswwfTUhoZhzgv27Svrd6SXr+jEC5Tx3czeIWmN0V2HDdI2cy58idAf9duYkxbtAOqF dq74VN3vgItbTNh0nGay+bpzvaGLwD4zaC9uOH6sAaVrSiq6BRvrrs6YtPncZDcWbPhj/p q6RQ7sFTUr+S6e0o2pWuI0qckPnx43xKjFFc1uQzjes2nt7AbGQG0f+G0LR82g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795036829; 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=9Liqr4XTbGCH8ocxR2FZKr+ILfD1AG25ZNGLYGVwizc=; b=hQxozw4PEC8tc8FRY8Y/SMsoXgBHAfPJ4bWKtlACeKIS/5sEmCmpru9Nng8VDnlggg4kCX rHz9zOuQitunAZ37g01ZSTi6sMCVOk1KEEIG47S6YV6GR2rMzMZBLjuP1sJdhKDk6731vK iBK1ZmB5LXxfJHfw/RvJj7Ruu8YdmAXwhlslH3mpp9f8K3hRQPlocEL59h1W9vpOF7Usi2 iXgXfMknT46HhgayvBTfgo+Ibpj90fSGnZ8s7bN39qXZ23CSUrBc78lQhCBFlA80+q7+96 xdONgKZqQxJ9iwhK4+0UhHUUCkvr1LthHjNLgFmjgZSXuA40M2Z2lOtI0IKdug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jVDz05jcCzV3X for ; Wed, 18 Nov 2026 21:20:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2473 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 21:20:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: b74577a2eaa2 - main - if_epair: Hash the IP header, not the Ethernet header, for fanout List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b74577a2eaa281676f82d4914dc8d5ae54711ed5 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 21:20:28 +0000 Message-Id: <6afe169c.2473.586d27f5@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=b74577a2eaa281676f82d4914dc8d5ae54711ed5 commit b74577a2eaa281676f82d4914dc8d5ae54711ed5 Author: R. Christian McDonald AuthorDate: 2026-11-18 21:17:00 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-18 21:19:34 +0000 if_epair: Hash the IP header, not the Ethernet header, for fanout With RSS, epair_select_queue() hashes a packet that carries no RSS hash with rss_soft_m2cpuid_v4() or rss_soft_m2cpuid_v6(), which read the IP header at the start of the mbuf. On transmit the mbuf starts with the Ethernet header, so the hash covered the MAC addresses, the EtherType and the first bytes of the IP header, the IPv4 total length and identification among them. The packets of one flow were spread over the queues by their IP ID and delivered out of order, and the value was stored in the mbuf as an RSS hash for the receiving side to use. Step over the Ethernet header, and over inline 802.1Q or 802.1ad tags, while the software hash runs. A tag is inline when vlan(4) or a bridge member runs without VLAN_HWTAGGING, always for 802.1ad, and for the inner tag of stacked vlans; those frames previously went to the first queue unhashed. Frames with more than two tags still do. Hash with rss_mbuf_software_hash_v4() and rss_mbuf_software_hash_v6() and map the hash with rss_getbucket(), as the hardware hash path does, instead of calling the netisr CPU selectors rss_soft_m2cpuid_v4() and rss_soft_m2cpuid_v6(): those return NETISR_CPUID_NONE, (u_int)-1, for a packet they cannot hash, and that value modulo the queue count picked an arbitrary queue rather than the first one. Reviewed by: kp Fixes: 24f0bfbad57b ("if_epair: implement fanout") MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D61037 --- sys/net/if_epair.c | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c index 5b00da381918..9f6b63f58f94 100644 --- a/sys/net/if_epair.c +++ b/sys/net/if_epair.c @@ -202,35 +202,67 @@ epair_tx_start_deferred(void *arg, int pending) static struct epair_queue * epair_select_queue(struct epair_softc *sc, struct mbuf *m) { - uint32_t bucket; + uint32_t bucket = 0; #ifdef RSS struct ether_header *eh; - int ret; + uint32_t hash, hashtype; + uint16_t etype; + int i, off, ret; ret = rss_m2bucket(m, &bucket); if (ret) { - /* Actually hash the packet. */ + /* + * Actually hash the packet. The software hash reads the IP + * header at the start of the mbuf, so step over the Ethernet + * header, and over any inline 802.1Q or 802.1ad tags, while + * it runs. Frames we cannot parse go to the first queue. + */ + off = ETHER_HDR_LEN; + if (m->m_len < off) + goto done; eh = mtod(m, struct ether_header *); + etype = ntohs(eh->ether_type); + for (i = 0; i < 2 && (etype == ETHERTYPE_VLAN || + etype == ETHERTYPE_QINQ); i++) { + if (m->m_len < off + ETHER_VLAN_ENCAP_LEN) + goto done; + memcpy(&etype, mtod(m, char *) + off + + sizeof(uint16_t), sizeof(etype)); + etype = ntohs(etype); + off += ETHER_VLAN_ENCAP_LEN; + } - switch (ntohs(eh->ether_type)) { + m->m_data += off; + m->m_len -= off; + m->m_pkthdr.len -= off; + switch (etype) { #ifdef INET case ETHERTYPE_IP: - rss_soft_m2cpuid_v4(m, 0, &bucket); + ret = rss_mbuf_software_hash_v4(m, + RSS_HASH_PKT_INGRESS, &hash, &hashtype); break; #endif #ifdef INET6 case ETHERTYPE_IPV6: - rss_soft_m2cpuid_v6(m, 0, &bucket); + ret = rss_mbuf_software_hash_v6(m, + RSS_HASH_PKT_INGRESS, &hash, &hashtype); break; #endif default: - bucket = 0; + ret = -1; break; } + m->m_data -= off; + m->m_len += off; + m->m_pkthdr.len += off; + if (ret == 0) { + m->m_pkthdr.flowid = hash; + M_HASHTYPE_SET(m, hashtype); + bucket = rss_getbucket(hash); + } } +done: bucket %= sc->num_queues; -#else - bucket = 0; #endif return (&sc->queues[bucket]); }