From nobody Thu Sep 19 20:21:27 2024 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 4X8n3X1hVrz5XL3y; Thu, 19 Sep 2024 20:21:28 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X8n3W5xN5z4Ws9; Thu, 19 Sep 2024 20:21:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726777287; 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=BZbmRm6om2OZbiewhovFt4NShjxHnfSvsidOwrmB0jw=; b=DXebetSsyXR3SUJYoBvS7BB1MUx92ubM++Vcb5hGi4KuQP/FnmJ7zY3gyGs8+068ax7uw5 L1PVJvNSdJUzGEbWGYW1k7wpiZj9jKsi9KeSq6tRT+GqIjFNLiUcs1yt/J68Ggs6wRjGzx UFvDBWyt6luF//cP3N6wYLjJueLmkYkFIjQo3JJSYcqHblHMLsOXCdxh61Hd1+3N6JViDK arYyQUe1bCXBEFER6Goa6d6l2CE8bZswDEgEoFRTrqBa0iYblq9IX+ZrwwF6I1IZbRHoL6 YJ4GXXnyaobt//aiOSWUNiy595RtyFi7OdLOmPeRD2DQvJXHAbxAbE4EuCSTPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726777287; a=rsa-sha256; cv=none; b=to4MtuTav5KddnxosvrdtBTZxYthl0bERd5iCn5K1DIUbOUoDMKsAUocPrk4Dtg+muuN2v jvDoYFzuQbaEamMgEvc4WdEnNhe5zCV7/baw0EnE+XncmZHTV/wFdehCbqC94jUiRCNoA9 JmXblf3PzyybAL4QFB/spBZ8cN7NI/SGDU8UlA0dej7V8sL9fBi3VYXeYbVQWFEzGKf6Yj APkP/rAYcqjUinsJV0CHPtJHbEBrmmaq8D0Amk6cXh3Za8TajW+oQNSzTRqFwFCILCD20j a222Lf0mFxCcDJ3Sl/NwOG0sxf52+lT1L1Ru8v6LXfLI3I5cz2ZCokpQMW6xsw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726777287; 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=BZbmRm6om2OZbiewhovFt4NShjxHnfSvsidOwrmB0jw=; b=aPaujbFiqAhZ4Qm78iLr2gdK8MwDN0G2EdsgHremcv5+ibOMn/exeCnf/qBBGCSl9VbE0G ihuDMN41xlwt+ng34hmFFq7FHqf1KPAS8Weu24cNIdiKxRK1f9iVikuwmz7m6zXb3KJ+Cb gFLZcYCyniNHGrDuBRBwdUhQwYdJ5b0KCMdBeBIQkA8YkpNl21JFJralBLYkRzKzodnLi2 QiTrA3q8ZbFnd5Gw1sQTVtilB/qRz7optd4p2TPyT5YAJHF6AhwNJKQf7MFaFFbxmyLnzP 5XOwbojk8q/i0PTMLrvPIhi7tGMU9ultYF8cbkOe5MUaSq/fyD9z2szngoGpKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X8n3W5QqWzL8G; Thu, 19 Sep 2024 20:21:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48JKLR64046815; Thu, 19 Sep 2024 20:21:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48JKLRm1046812; Thu, 19 Sep 2024 20:21:27 GMT (envelope-from git) Date: Thu, 19 Sep 2024 20:21:27 GMT Message-Id: <202409192021.48JKLRm1046812@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 9746c1e28877 - main - pf tests: ensure we don't NAT to link-local addresses List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9746c1e28877ffb5fd9dc60bb6524df9fa1b6918 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=9746c1e28877ffb5fd9dc60bb6524df9fa1b6918 commit 9746c1e28877ffb5fd9dc60bb6524df9fa1b6918 Author: Kristof Provost AuthorDate: 2024-09-05 15:23:57 +0000 Commit: Kristof Provost CommitDate: 2024-09-19 20:20:15 +0000 pf tests: ensure we don't NAT to link-local addresses Reviewed by: zlei Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46595 --- tests/sys/netpfil/pf/nat.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/sys/netpfil/pf/nat.sh b/tests/sys/netpfil/pf/nat.sh index aaa49805c772..19dd39fe5848 100644 --- a/tests/sys/netpfil/pf/nat.sh +++ b/tests/sys/netpfil/pf/nat.sh @@ -250,9 +250,61 @@ nested_anchor_cleanup() pft_cleanup } +atf_test_case "nat6_nolinklocal" "cleanup" +nat6_nolinklocal_head() +{ + atf_set descr 'Ensure we do not use link-local addresses' + atf_set require.user root +} + +nat6_nolinklocal_body() +{ + pft_init + + epair_nat=$(vnet_mkepair) + epair_echo=$(vnet_mkepair) + + vnet_mkjail nat ${epair_nat}b ${epair_echo}a + vnet_mkjail echo ${epair_echo}b + + ifconfig ${epair_nat}a inet6 2001:db8::2/64 no_dad up + route add -6 -net 2001:db8:1::/64 2001:db8::1 + + jexec nat ifconfig ${epair_nat}b inet6 2001:db8::1/64 no_dad up + jexec nat ifconfig ${epair_echo}a inet6 2001:db8:1::1/64 no_dad up + jexec nat sysctl net.inet6.ip6.forwarding=1 + + jexec echo ifconfig ${epair_echo}b inet6 2001:db8:1::2/64 no_dad up + # Ensure we can't reply to link-local pings + jexec echo pfctl -e + pft_set_rules echo \ + "pass" \ + "block in inet6 proto icmp6 from fe80::/10 to any icmp6-type echoreq" + + jexec nat pfctl -e + pft_set_rules nat \ + "nat pass on ${epair_echo}a inet6 from 2001:db8::/64 to any -> (${epair_echo}a)" \ + "pass" + + # Sanity check + atf_check -s exit:0 -o ignore \ + ping -6 -c 1 2001:db8::1 + for i in `seq 0 10` + do + atf_check -s exit:0 -o ignore \ + ping -6 -c 1 2001:db8:1::2 + done +} + +nat6_nolinklocal_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "exhaust" atf_add_test_case "nested_anchor" atf_add_test_case "endpoint_independent" + atf_add_test_case "nat6_nolinklocal" }