From nobody Mon Nov 23 14:38:02 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 4jY7pM281Mz6w5ym for ; Mon, 23 Nov 2026 14:38:03 +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 4jY7pL6gCFz4lqC for ; Mon, 23 Nov 2026 14:38:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795444682; 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=edEuZYY83aVLhrHopESHRiKkIoDatqK3HFbZ9HpdyBU=; b=q4OK2oiL0I+p2nUo41uf63XLWUPITn1tJlhKaAhqdCZAmksvN6bn+Bw0UTO6s9AvaKRZuq t02sGboPUj9P4ueXBAfVUr2UDEgW6+cGWTLw0PGL+Z6a7pYjLxwp+tJ/SSop/dxmkyGTpy G0xTgRr4rGpHNHuaA6mlo/hZmqE8jttegm506CMaxgBAfFp6YXplDEBD7n+s+GFL1uozTX EQEEu55V/DrW+HqY334A0XoNojuLCBiq55rqvnn9XN22ViBy36mgviv+uWrxezhGugmW66 c/e/wnE8/AyiZcRdEp83EoyoNUC93awYsuh7DxFs+BmoOv0RzL6XN3OEgdnxyQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795444682; b=i0bQpIvrDbgZb3yokf+R6DhboMY76e4UeMiuXsaTfGUc7yxf4LCY8g+xI+hpAtnzIzBYTD IZHMJiEWEtGWpkNoZ4eSG1RZ9vWNbCF9uEEwZzolZeCDdGKIHOZeVlq7EzDVk6rt6bNG5e 7pyb1uZ30FZpYZhmiXtODqOMLPdHjiMXTDn0yO2rpBkPwBVqCltypPVbjCFOxFxU8HpAvl JLiOvlA9bYuP52k0t1kKhnYNWLiwP8/WzHHKrvQIF2q9HxowSaSXxgUECqCZb3cIjjbGk3 Z1LgYgFqa16hIC6Ck2uMPwlHj6/EskzLLmG7sdiAc0oEbR2pujIXZuMda2MlXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795444682; 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=edEuZYY83aVLhrHopESHRiKkIoDatqK3HFbZ9HpdyBU=; b=vQKmhGaWG1EbrgsevSwssJo/Uwle8y19bMBwl1YANAUA3WdklLEapddZNvSXZoKpnW311C +BVMflnW9E4zBgEv1RanOEB1yv5W8rSjzVGQi2tC/IGPohqomYSNH68RdiqG1Ky4DpGl9m 0kWtlpJQXSoCoy6b0XjsYFFi4WfTd722pwDWAXf5YdBsK8UeRVq3NWN98yZLQXvvJm8yo4 OIhBdGJz6wO1EtOpnfVLmEDQOZn0MBQrZSCG6aF3VxI5O1FbT4f7eXA4XxVgI9UkdzgQ8n dMGD7DPW1u7IxF3Egoi31fYcE63v8dtD75ifMG7Uwpu0MWdCJ8V8snErF2wKpA== 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 4jY7pL61zXzvDD for ; Mon, 23 Nov 2026 14:38:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id fe1e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 23 Nov 2026 14:38:02 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: 3cd5f1b307ad - main - netipsec: Process a nested IPsec header on IPv6 input 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: 3cd5f1b307ad497d409e1a98bddf28702b579a47 Auto-Submitted: auto-generated Date: Mon, 23 Nov 2026 14:38:02 +0000 Message-Id: <6b044fca.fe1e.5df30d74@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=3cd5f1b307ad497d409e1a98bddf28702b579a47 commit 3cd5f1b307ad497d409e1a98bddf28702b579a47 Author: R. Christian McDonald AuthorDate: 2026-11-23 14:36:01 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-23 14:37:57 +0000 netipsec: Process a nested IPsec header on IPv6 input After a transport mode SA has processed an inbound IPv6 packet, ipsec6_common_input_cb() walks the remaining header chain itself and calls ip6_protox[] for each next header. AH, ESP and IPComp have had no entry in ip6_protox[] since the projects/ipsec merge; ip6_input() reaches them through IPSEC_INPUT() instead. The callback did not, so when the next header was another IPsec header the packet went to rip6_input() and was never decapsulated. The receiving side of a bundle such as ESP beneath a transport mode AH, or ESP with IPComp, did not work over IPv6. Hand such a header back to ipsec_common_input() from the loop. Look up the offset of the preceding next header field with ip6_get_prevhdr(), since extension headers may sit between the two IPsec headers. The bundle cases of the flowlabel test had to ignore the result of ping because of this. Have them check it, and give the second target, which no host owned, an address on hostB. Reported by: llm-postcr Reviewed by: ae, kib Fixes: fcf596178b5f ("Merge projects/ipsec into head/.") MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D61805 --- sys/netipsec/ipsec_input.c | 13 ++++++++++++- tests/sys/netipsec/tunnel/flowlabel.sh | 18 +++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c index e54f65a50f83..43e01a3e9895 100644 --- a/sys/netipsec/ipsec_input.c +++ b/sys/netipsec/ipsec_input.c @@ -787,11 +787,22 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, error = EINVAL; goto bad; } + /* + * AH, ESP and IPComp are not in ip6_protox[]; as in + * ip6_input(), a further IPsec header of a bundle has to be + * handed back to IPsec here. + */ + if (nxt == IPPROTO_AH || nxt == IPPROTO_ESP || + nxt == IPPROTO_IPCOMP) { + error = ipsec_common_input(m, skip, + ip6_get_prevhdr(m, skip), AF_INET6, nxt); + break; + } nxt = ip6_protox[nxt](&m, &skip, nxt); } NET_EPOCH_EXIT(et); key_freesav(&sav); - return (0); + return (error); bad: NET_EPOCH_EXIT(et); ipsec_sahtree_runlock(sahtree_tracker); diff --git a/tests/sys/netipsec/tunnel/flowlabel.sh b/tests/sys/netipsec/tunnel/flowlabel.sh index 7afd1c8cc21e..349da885ae90 100755 --- a/tests/sys/netipsec/tunnel/flowlabel.sh +++ b/tests/sys/netipsec/tunnel/flowlabel.sh @@ -34,9 +34,7 @@ fl_setkey() # fl_run COUNT TARGET...: ping each target from hostA while capturing COUNT # packets that match fl_filter on ipsecA's public interface, by default ESP -# or AH in both directions. A test that expects no replies sets -# fl_ping_status=ignore. -fl_ping_status=exit:0 +# or AH in both directions. fl_filter="ip6 and (esp or ah)" fl_run() { @@ -57,7 +55,7 @@ fl_run() i=$((i + 1)) done for target in "$@"; do - atf_check -s ${fl_ping_status} -o ignore \ + atf_check -s exit:0 -o ignore \ jexec hostA ping -c 5 -i 0.2 ${target} done timeout 5 sh -c "while kill -0 ${tdpid} 2>/dev/null; do sleep 0.2; done" @@ -202,14 +200,17 @@ sa_flowid_off_cleanup() # mode "any"). The outer header must carry the label of the AH SA on every # packet, not that of the tunnel SA which built it. AH leaves the ESP # header readable, so the capture shows which tunnel SA each packet took. -# Only the outbound packets carry AH, so only they are captured: when this -# was written, ipsec6_common_input_cb() handed the ESP header beneath a -# transport mode AH to the raw IPv6 input, so ipsecB did not decapsulate -# the packets and did not reply. +# Only the outbound packets carry AH, so only they are captured. The +# replies show that ipsecB removed both headers of the bundle. fl_bundle() { ahmode=${1:+-m $1} fl_lab 4 + # A second address on hostB, reached by the second policy. + atf_check -s exit:0 jexec hostB \ + ifconfig ${epair_LAN_B}a alias 203.0.113.129/32 + atf_check -s exit:0 -o ignore jexec ipsecB \ + route add 203.0.113.129/32 203.0.113.1 ( printf "flush;\nspdflush;\n" printf "spdadd 192.0.2.0/24 203.0.113.0/25 any -P out ipsec esp/tunnel/${GW_A}-${GW_B}/unique:1 ah/transport//require;\n" @@ -231,7 +232,6 @@ fl_bundle() printf "add ${GW_B} ${GW_A} esp 0x1003 -m tunnel -E aes-gcm-16 \"${KEY}\";\n" ) > ${TMPDIR}/ipsec.ipsecB.conf atf_check -s exit:0 -o ignore jexec ipsecB setkey -f ${TMPDIR}/ipsec.ipsecB.conf - fl_ping_status=ignore fl_filter="ip6 and ah" fl_run 10 203.0.113.1 203.0.113.129 fl_check 0x1002 828ed