From nobody Sun Nov 01 18:10:05 2026 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 4jHjY9388fz6xg4Z for ; Sun, 01 Nov 2026 18:10:05 +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 4jHjY92VKnz3GGr for ; Sun, 01 Nov 2026 18:10:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793556605; 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=INDnroYo+kz1jLyVTvScvwnH20JyNQJC9LTFAqaPMG9EBlcoBfWNVbZ1MrSwl+njKSi35w Ky8id3LkFeCr6NhDwCQmgIbThk/4T3flo6tMZw9RfhrmtNW+riXv+E/5hz3WmRXgcl/xGQ 11Q+IlskWixcHNbCVVEruqG2Rh9kFnHgg+AuVckFoFnrijktruXKowhIkWWMjEWsvPtQhT 2SQw/myzdTgfQbXXNxD3+mEeUr/Pd8ZNCxWvdlc6r9fye1TTkPtMf66WciC0gziuj6ctnv jxQ0751DKYAAL4oBvellW9Fc27FtUV+6rwUuWzNoahVJnQ2tYxZiI9MkSKGbqQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793556605; b=kiAL0S7+o97TQm+bIbIjIGiTy3IotXnD96zxWWMU/ByU7rvL5kCvxjTFj2lBCxghM4lbwK iPmA4Zl9Cl2M92Vu+vD+tnMKMMwyLpCpCVmzQbPXps59XAgiXTiFyyKsOtb1K5Dr4/LSPE 33l9NwhZm0Tu3r0ubitz+xQ3y6o+mQTbgPZarD6TDstJKh85Z+0ZYY1UZRtg4Lj3siN3Wa ukJR8otHHlSryKKFkUCnDYs2e2EBLRfDYAGMS6NDQHIONjUTFzhjAGjaKjeXbeRty+egw7 ebB0/EJhdu6Na17paJ6VlwzWMp/12UvfCRE9PJBgr7aGfQ2zYnOyOpfR+IpAfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793556605; 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=IzC/lN5Jv3R1sx3zWa64tGUkRSU9p/gR19iTRa7GkfLMd3FHYqafpPzYdSIsOk7HKFz6C8 EluBYK3yUB6gxW/ECt1Mg5USkhMafIjeHUhpuv4SU8ZqQeErDhThzCYxSCBxG0iOzMpPdB QLZaIBuDALDinFoXr0kyu1ydgONcE4fhXri6ysuPOSpIi+N3qnsFb4ohYVSnjkWI/kqFel Tlc3Byn3prtYakIo2zNCmBJF8eG+uHVges5gMPzJ3f/xIBt2oWMExYJ+o1NTx9hR66bflp ZlRVVc9eSFbwkjG3LL7Y+W7XShZpExNb8c/EOFDIvkpRYkZ6o5PP/7AffO8wWg== 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 4jHjY91t63z17my for ; Sun, 01 Nov 2026 18:10:05 +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-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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)); }