From nobody Thu Oct 28 08:50:42 2021 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 74A52181FBE1; Thu, 28 Oct 2021 08:50:43 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HfzmL4HCCz4xK2; Thu, 28 Oct 2021 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 479EC20C0D; Thu, 28 Oct 2021 08:50:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19S8ogu1079811; Thu, 28 Oct 2021 08:50:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19S8oggf079810; Thu, 28 Oct 2021 08:50:42 GMT (envelope-from git) Date: Thu, 28 Oct 2021 08:50:42 GMT Message-Id: <202110280850.19S8oggf079810@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: 4ee0f6d87452 - main - netpfil tests: dummynet+NAT test for pf 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 4ee0f6d87452d156a588ea23b016203dcc7ec6ad Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4ee0f6d87452d156a588ea23b016203dcc7ec6ad commit 4ee0f6d87452d156a588ea23b016203dcc7ec6ad Author: Kristof Provost AuthorDate: 2021-10-26 08:56:30 +0000 Commit: Kristof Provost CommitDate: 2021-10-28 08:41:17 +0000 netpfil tests: dummynet+NAT test for pf Ensure that NAT still works as expected when combined with dummynet. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32666 --- tests/sys/netpfil/common/dummynet.sh | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/sys/netpfil/common/dummynet.sh b/tests/sys/netpfil/common/dummynet.sh index 644b36516b5a..448bb79a46f9 100644 --- a/tests/sys/netpfil/common/dummynet.sh +++ b/tests/sys/netpfil/common/dummynet.sh @@ -329,6 +329,50 @@ queue_v6_cleanup() firewall_cleanup $1 } +nat_head() +{ + atf_set descr 'Basic dummynet + NAT test' + atf_set require.user root +} + +nat_body() +{ + fw=$1 + firewall_init $fw + dummynet_init $fw + nat_init $fw + + epair=$(vnet_mkepair) + epair_two=$(vnet_mkepair) + + ifconfig ${epair}a 192.0.2.2/24 up + route add -net 198.51.100.0/24 192.0.2.1 + + vnet_mkjail gw ${epair}b ${epair_two}a + jexec gw ifconfig ${epair}b 192.0.2.1/24 up + jexec gw ifconfig ${epair_two}a 198.51.100.1/24 up + jexec gw sysctl net.inet.ip.forwarding=1 + + vnet_mkjail srv ${epair_two}b + jexec srv ifconfig ${epair_two}b 198.51.100.2/24 up + + jexec gw dnctl pipe 1 config bw 300Byte/s + + firewall_config gw $fw \ + "pf" \ + "nat on ${epair_two}a inet from 192.0.2.0/24 to any -> (${epair_two}a)" \ + "pass dnpipe 1" + + # We've deliberately not set a route to 192.0.2.0/24 on srv, so the + # only way it can respond to this is if NAT is applied correctly. + atf_check -s exit:0 -o ignore ping -c 1 198.51.100.2 +} + +nat_cleanup() +{ + firewall_cleanup $1 +} + setup_tests \ pipe \ ipfw \ @@ -341,4 +385,6 @@ setup_tests \ pf \ queue_v6 \ ipfw \ + pf \ + nat \ pf