From nobody Sun Nov 01 18:10:05 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 4jHjYG2g3pz6xfyn for ; Sun, 01 Nov 2026 18:10:10 +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 4jHjYG0tm2z3G6B for ; Sun, 01 Nov 2026 18:10:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793556610; 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=WOoYHoBbvkHGBD3Fs15FSuV0xQOk7pSr/6viQvrbImE=; b=O6nklMZuMs9uJSAA1vy5CyAH3KwlNr8rwEXNcACEFmClKObcM12+O5G5BmWwslXaqx2TQn gTb8IJHl72Pww/KDxlIizMwDpX6U7A0Bl/XXw9jwrMCMUSsy7W64ljYAWJ8/p4+tLMjpdJ 859dCd54UqgXCWdG4Chz7OGF6lXzaaWzJS8JhG90nEY2BUkwT855hGf+KL7FQo6rmRmrqX U8ABvyPFAYxqZWZYs7T1KVJMurs2+0KkMWV1gvtRB5EAt8qh/DaNoLCg4EsMBXz2UuJ6c6 SwghyjzN4m1um0rGiDgwMc5NDaFKX/OLyLE8aWmZwLob7CUHROGO+puGSHMeFg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793556610; b=r5L3iVzBdxdSjfyF9FvH1+61XqzzhJTgGf81sK6eq85HckcJqrRfdf5PuSMXnasOs5at38 HlcQ+Mhw0elH553w9vY7I5BhepWT+jPXRTqE8cRgMn6uwBtx3QM83mSxlih9sTZBPkkWgk QECwy/oZk+uMpAl48YHQe1b2eXcnSASTQh4BO3FagDLq8Gl/10tTZ075JAHfN8J2RWMyn7 tyjlt4LFxAKkfPrx/bN8kfjE0RqjtFbyLlG+Dzc2hf9HX7wR+gApQ50SvlXP1dlgGpp+KC QCuCJst9hrBBNdcTdy8q2GlP1ho0hrst66UY+flxDqDmi8IMOkZooNEZgijzCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793556610; 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=WOoYHoBbvkHGBD3Fs15FSuV0xQOk7pSr/6viQvrbImE=; b=wwj2iYDbm1ofORhMtUbV5yqfbvs5trWMtCVVIJAXZh77iu4zFknSmNsOLCDFkRH5werSOh iTQfmI0Ln9BX9jBZZB3X0cVopknS9dA/xXrUT4nBqF8CCTlb5H2GT9vNnxartKbXPpzI7B eaSHU6mH3kyH8p/jVuDhi5lHRWz3OLxtwhnR75GkNqGwSPeblMt4SRoVWeSUs+p4WwVyeu J7XmPWzlsW2FznaVL7VCCXhzjf2vqOYi27a460yzjR0gXRDZZmRgoBFsJF6Np26W/5HM1G QveZQ44rnVakNJMNtF+DW8T3CNktrzMtue9jG21vIH4GK36Ak9RgzTi3PVn7/A== 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 4jHjYG0Yxyz18MF for ; Sun, 01 Nov 2026 18:10:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1f3e1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 01 Nov 2026 18:10:05 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vincenzo Maffione Subject: git: 0a12444b2989 - main - pkt-gen: fix UDP checksum when IPv6 address ranges are used List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a12444b2989c38a5d2e358e0f9ef01c665cc268 Auto-Submitted: auto-generated Date: Sun, 01 Nov 2026 18:10:05 +0000 Message-Id: <6ae7807d.1f3e1.2a2fa039@gitrepo.freebsd.org> The branch main has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=0a12444b2989c38a5d2e358e0f9ef01c665cc268 commit 0a12444b2989c38a5d2e358e0f9ef01c665cc268 Author: Vincenzo Maffione AuthorDate: 2026-11-01 18:06:13 +0000 Commit: Vincenzo Maffione CommitDate: 2026-11-01 18:06:13 +0000 pkt-gen: fix UDP checksum when IPv6 address ranges are used update_ip6() left the UDP checksum stale for most packets. Unlike update_ip(), it computed the incremental checksum delta only after the source-address wrap, so every earlier "break" (port increment, address increment, and both random paths) returned with udp_sum still 0 and no correction applied. The trailing delta block also re-read oaddr/naddr after they had been reassigned, so the source and destination deltas could not both be accounted for. Fold each delta in with new_udp_sum() before the corresponding break, mirroring the structure update_ip() already uses, and drop the stale trailing block. IPv4 was not affected. Verified by driving update_addresses() directly and recomputing every checksum from scratch over the real pseudo-header: 128 packets across six range configurations, 12 mismatches before, 0 after. IPv4 passes both before and after. Submitted by: Olivier Cochard-Labbé --- tools/tools/netmap/pkt-gen.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index c17579a142b9..510f6a3db462 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -917,7 +917,7 @@ update_ip6(struct pkt *pkt, struct targ *t) struct glob_arg *g = t->g; struct ip6_hdr ip6; struct udphdr udp; - uint16_t udp_sum; + uint16_t udp_sum = 0; uint16_t oaddr, naddr; uint16_t oport, nport; uint8_t group; @@ -925,7 +925,6 @@ update_ip6(struct pkt *pkt, struct targ *t) memcpy(&ip6, &pkt->ipv6.ip, sizeof(ip6)); memcpy(&udp, &pkt->ipv6.udp, sizeof(udp)); do { - udp_sum = 0; group = g->src_ip.ipv6.sgroup; naddr = oaddr = ntohs(ip6.ip6_src.s6_addr16[group]); nport = oport = ntohs(udp.uh_sport); @@ -934,29 +933,28 @@ update_ip6(struct pkt *pkt, struct targ *t) udp.uh_sport = nrand48(t->seed); naddr = ntohs(ip6.ip6_src.s6_addr16[group]); nport = ntohs(udp.uh_sport); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); break; } if (oport < g->src_ip.port1) { nport = oport + 1; udp.uh_sport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); break; } nport = g->src_ip.port0; udp.uh_sport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); if (oaddr < ntohs(g->src_ip.ipv6.end.s6_addr16[group])) { naddr = oaddr + 1; ip6.ip6_src.s6_addr16[group] = htons(naddr); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); break; } naddr = ntohs(g->src_ip.ipv6.start.s6_addr16[group]); ip6.ip6_src.s6_addr16[group] = htons(naddr); - - /* update checksums if needed */ - if (oaddr != naddr) - udp_sum = cksum_add(~oaddr, naddr); - if (oport != nport) - udp_sum = cksum_add(udp_sum, - cksum_add(~oport, nport)); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); group = g->dst_ip.ipv6.egroup; naddr = oaddr = ntohs(ip6.ip6_dst.s6_addr16[group]); @@ -966,32 +964,32 @@ update_ip6(struct pkt *pkt, struct targ *t) udp.uh_dport = nrand48(t->seed); naddr = ntohs(ip6.ip6_dst.s6_addr16[group]); nport = ntohs(udp.uh_dport); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); + udp_sum = new_udp_sum(udp_sum, oport, nport); break; } if (oport < g->dst_ip.port1) { nport = oport + 1; udp.uh_dport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); break; } nport = g->dst_ip.port0; udp.uh_dport = htons(nport); + udp_sum = new_udp_sum(udp_sum, oport, nport); if (oaddr < ntohs(g->dst_ip.ipv6.end.s6_addr16[group])) { naddr = oaddr + 1; ip6.ip6_dst.s6_addr16[group] = htons(naddr); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); break; } naddr = ntohs(g->dst_ip.ipv6.start.s6_addr16[group]); ip6.ip6_dst.s6_addr16[group] = htons(naddr); + udp_sum = new_udp_sum(udp_sum, oaddr, naddr); } while (0); /* update checksums */ - if (oaddr != naddr) - udp_sum = cksum_add(udp_sum, - cksum_add(~oaddr, naddr)); - if (oport != nport) - udp_sum = cksum_add(udp_sum, - cksum_add(~oport, nport)); if (udp_sum != 0) - udp.uh_sum = ~cksum_add(~udp.uh_sum, udp_sum); + udp.uh_sum = ~cksum_add(~udp.uh_sum, htons(udp_sum)); memcpy(&pkt->ipv6.ip, &ip6, sizeof(ip6)); memcpy(&pkt->ipv6.udp, &udp, sizeof(udp)); }