From nobody Wed Nov 18 21:38:04 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 4jVFMK2lCbz71KDp for ; Wed, 18 Nov 2026 21:38: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 4jVFMK1mVQz4KL4 for ; Wed, 18 Nov 2026 21:38:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795037885; 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=2NZoQKTElS03cgyT2QTDz6iIAsTI10PrtNGxiQA6Ivc=; b=vQPk9VUt2blsWq8QB4pDZ/UhF4GFojMYOswSUHKyWZQMKsbiMwJuDDi+r90EmEG3Y5o8pB 9kNzatA5P65VFYx7/ZXDAVAt9rn4E2SN8Nb88Ov/XFx7zDxcyOrBFOtq0L8uqRxpxB18Ln 0SAH4vsP8xJ6HRk39RsYIdYWLX9DAjc8cD5RK3R1Fe4DxIkNptQ0B9FLZ3AZooZjW9PBu5 H/31uWmWZFmaegPnXfaUo23j8mN19rw7LByldaDGoqB9IgndEOCij7n1+piWBysBU5++oF +G1IwtygAVHrBxAKFD4uQfvyvQSQlYSv9FIChvyYz4OBAxvqt5DmmdlcApE3+w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795037885; b=SGDoGt+sgdTbn6FEWPQ+raN/4WMEoOpL6wH7B2p+goMV6DWjWzsZChKEWLdQqZrUFSBo91 F9xYTDtAiDa8PHFMNuZjrY36LCW0OJMRWwhRb/DtHdortp4QE2Dh2XrOHSek/lCWjqyQG+ tpVvCL46Srz167Svi/s+4buUYlFPYEW7Ji3UZt0aOCqC6VucTMqojGz4e7jMwBeM4GhFdQ k0oE6qiGoxeU9WUDCGOdOZmN+TphfbxUWvZNZMn4i1w7y/5ZcaBzd1ziba+quOnTsP/qDY 93TUIwO7AV1C36lzWUZprvMQNwQgvLMKLjTAkDL7KCEaOGoYPaUuHvOBkapl5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795037885; 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=2NZoQKTElS03cgyT2QTDz6iIAsTI10PrtNGxiQA6Ivc=; b=VCHbqMvguFdQjy/IU0Nqd0ptJmJ8I2jXdyOx5+kaEZMHO18XSmmndGb1UQlcyVXCPwOleK eeTgWCJFLmAzk8r2Fd8ZIWNfV3CDP1iANK9quzYwFe671nOtQcpvCR82GX4YANv/O9dySP m/oJ2AZP7QxwRZFLZmF9nfb0ZJ3ZJBIpFoTCMMHhJYBDx6q9AKvizN2AuuRjS4u+qLI49g 0C6ox46L0JeRRGPF/BWrnLm767YCVcPGaL7jgKez+KAsF1HbdSTf2RHjfTzSgval64tPhg v2SSs2KKGGjl9A8VliYgWeqY4u6bR8jMnHK7aWX0LQQiyc04B+uWwz2XkhYpTQ== 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 4jVFMK0cxLzVwX for ; Wed, 18 Nov 2026 21:38:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 398a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 21:38:04 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: fb9969ca61ca - main - netinet6: Keep a pfil-chosen next hop in ip6_tryforward() 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: fb9969ca61cae271240879390c1b6dde1b4c97bf Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 21:38:04 +0000 Message-Id: <6afe1abc.398a.3a460102@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=fb9969ca61cae271240879390c1b6dde1b4c97bf commit fb9969ca61cae271240879390c1b6dde1b4c97bf Author: R. Christian McDonald AuthorDate: 2026-11-18 21:36:32 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-18 21:36:32 +0000 netinet6: Keep a pfil-chosen next hop in ip6_tryforward() When an inbound pfil hook chooses the next hop (ipfw fwd), ip6_tryforward() looks up the route to it. After the outbound hooks it decides whether they changed the destination by comparing the packet's destination with the address it looked up, which is that next hop. The two differ, so it looks up the route to the packet's destination again and the fwd rule is lost. ipfw always installs an outbound hook, so every packet such a rule matches goes the wrong way while net.inet6.ip6.redirect is 0. Compare with the destination as it was before the outbound hooks, as ip6_forward() does. Reviewed by: pouria Fixes: 5a1842a2 ("Add ip6_tryforward() - a run to completion ...") MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D61038 --- sys/netinet6/ip6_fastfwd.c | 4 +++- tests/sys/netpfil/ipfw/fwd.sh | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/sys/netinet6/ip6_fastfwd.c b/sys/netinet6/ip6_fastfwd.c index 4e60e18a8067..6256631c78f3 100644 --- a/sys/netinet6/ip6_fastfwd.c +++ b/sys/netinet6/ip6_fastfwd.c @@ -95,6 +95,7 @@ struct mbuf* ip6_tryforward(struct mbuf *m) { struct sockaddr_in6 dst; + struct in6_addr odst; struct nhop_object *nh; struct m_tag *fwd_tag; struct ip6_hdr *ip6; @@ -218,6 +219,7 @@ passin: /* * Outgoing packet firewall processing. */ + odst = ip6->ip6_dst; if (pfil_mbuf_fwd(V_inet6_pfil_head, &m, nh->nh_ifp, NULL) != PFIL_PASS) goto dropout; @@ -258,7 +260,7 @@ passin: fwd_tag = NULL; if (fwd_tag != NULL || - !IN6_ARE_ADDR_EQUAL(&dst.sin6_addr, &ip6->ip6_dst)) { + !IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst)) { if (fwd_tag != NULL) { bcopy((fwd_tag + 1), &dst, sizeof(dst)); m->m_flags &= ~M_IP6_NEXTHOP; diff --git a/tests/sys/netpfil/ipfw/fwd.sh b/tests/sys/netpfil/ipfw/fwd.sh index b7aa37795706..fc97c922e17d 100755 --- a/tests/sys/netpfil/ipfw/fwd.sh +++ b/tests/sys/netpfil/ipfw/fwd.sh @@ -64,7 +64,63 @@ local_cleanup() firewall_cleanup $1 } +atf_test_case "nexthop_v6" "cleanup" +nexthop_v6_head() +{ + atf_set descr 'Test that an inbound IPv6 fwd rule chooses the next hop' + atf_set require.user root +} + +nexthop_v6_body() +{ + firewall_init "ipfw" + + epair_c=$(vnet_mkepair) + epair_1=$(vnet_mkepair) + epair_2=$(vnet_mkepair) + + vnet_mkjail rtr ${epair_c}b ${epair_1}a ${epair_2}a + vnet_mkjail srv1 ${epair_1}b + vnet_mkjail srv2 ${epair_2}b + + atf_check ifconfig ${epair_c}a inet6 2001:db8:1::2/64 up no_dad \ + -ifdisabled + atf_check -o ignore route add -6 2001:db8:4::/64 2001:db8:1::1 + + atf_check ifconfig -j rtr ${epair_c}b inet6 2001:db8:1::1/64 up no_dad + atf_check ifconfig -j rtr ${epair_1}a inet6 2001:db8:2::1/64 up no_dad + atf_check ifconfig -j rtr ${epair_2}a inet6 2001:db8:3::1/64 up no_dad + atf_check -o ignore sysctl -j rtr net.inet6.ip6.forwarding=1 + atf_check -o ignore route -j rtr add -6 2001:db8:4::/64 2001:db8:2::2 + + # 2001:db8:4::1 lives on srv2, but the route points to srv1. + atf_check ifconfig -j srv1 ${epair_1}b inet6 2001:db8:2::2/64 up no_dad + atf_check ifconfig -j srv2 ${epair_2}b inet6 2001:db8:3::2/64 up no_dad + atf_check ifconfig -j srv2 lo0 inet6 2001:db8:4::1/128 up + atf_check -o ignore route -j srv2 add -6 default 2001:db8:3::1 + + firewall_config rtr ipfw ipfw \ + "ipfw add 20 allow all from any to any" + atf_check -s exit:2 -o ignore ping -6 -c 1 -W 1 2001:db8:4::1 + + firewall_config rtr ipfw ipfw \ + "ipfw add 10 fwd 2001:db8:3::2 ip6 from any to 2001:db8:4::1 in via ${epair_c}b" \ + "ipfw add 20 allow all from any to any" + + for redirect in 0 1; do + atf_check -o ignore \ + sysctl -j rtr net.inet6.ip6.redirect=${redirect} + atf_check -o ignore ping -6 -c 1 -W 1 2001:db8:4::1 + done +} + +nexthop_v6_cleanup() +{ + firewall_cleanup $1 +} + atf_init_test_cases() { atf_add_test_case "local" + atf_add_test_case "nexthop_v6" }