From nobody Wed Mar 02 16:01:02 2022 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 540B219E14BA; Wed, 2 Mar 2022 16:01: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 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 4K7zPD3KsYz3NTZ; Wed, 2 Mar 2022 16:01:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236864; 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=NFmVb2pRWwIxX6+CDw4hb7BMrb93IHDP34/NH5ClJRQ=; b=MwS4dwRjaKQ+KAX53ySi4X0aj7h/ySP8jcZDEp+5GifAB+5v26K4QIy9CZ+dhF2QRUzScN nYMSFj9QibvgsHppKtUpXKlj6A5J2JCh9CBvwxkkbSEnkpF1sKjM6PPXej2MBF7BTRkSjv 3whcXcmvXPOiX4lWFeKJ6xTFNga4Ko1+dARABTqaR0ZJmQeux2+gSlP/uEQwH1R658smew ql5kWfcisVvBVyqNMmuD2JyHRdxvFCiany/NpSMxuQsy6CWNVavL4z2Fk7No6olKykS4wT I1SZ1E1TUtI6xqHXaSKlXOYe/N35JmvqumM3WjgomsLdWMnRXJ8pXJ0dHlBmNg== 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 12A4B261D2; Wed, 2 Mar 2022 16:01:03 +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 222G12hp091433; Wed, 2 Mar 2022 16:01:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 222G12XO091432; Wed, 2 Mar 2022 16:01:02 GMT (envelope-from git) Date: Wed, 2 Mar 2022 16:01:02 GMT Message-Id: <202203021601.222G12XO091432@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: d1702bd1c3a7 - main - pf tests: basic test for ether anchors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: d1702bd1c3a732c6b8ba85a91c3af64a059439a4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646236864; 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=NFmVb2pRWwIxX6+CDw4hb7BMrb93IHDP34/NH5ClJRQ=; b=Sv0N9P3DXiNDjr+1j1Xn4xfe4jZMwg2KdSj4KJKjzApDUxhnrPFhm10xINqstoO74c0jIc v1+gz+YBc+MYpHbf0QEl5f1q8lTOytkDcPWsW4ldrMrCsEtrruKQ1sgWZuoIXI9MpFJPwN ihRyQ55hrnQoE4V/RJXj3gU90oopZWhxnRfCTZeyCKecI2LFtk+CSJX2LmPeg76lc3s59I gsL/MH21lONfSj6ZUWSrUAQdN4btPKl0x8IgPR5FlfQBCAb4z7nnapp1cWcHYL0JdIDk2S R/Z4dMAFnxSaAesEsBQv1HjBEvAZYxZNF+OKkok/KCF52tOYhDop8SnXeqvFeQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646236864; a=rsa-sha256; cv=none; b=oLiIZC8iyBp/z17HspoNlwb5/dRr15JUFtyqpcguWrabOwNVDZC91IJCWICxOyZidpIsCR QPf53nVn9MTyPQTHLL6lSWHiL9IHcpYtHDLdV7nb4+tMeVzZO/2wMjCB3yV5Ddi1qOtfJK o0NcPEmz48Kgi5cXYVIjRwVH2/fsBknenhE31Yu7g6NoshvbmGGm1Uj+2lME4LJGWdAdnJ ZcuVwfEu9yyOPc2ZgIv+H5YhjSMQ3p5R8fiySCfdaed8r0pHAF3HBHRq3MJDRO2S6AXRNg 6CqJO2OvKrUrmI8PgUuvymmfD7vx6F/tp+Vm6v6FCxswuIry77NGjBN2Uu2xow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d1702bd1c3a732c6b8ba85a91c3af64a059439a4 commit d1702bd1c3a732c6b8ba85a91c3af64a059439a4 Author: Kristof Provost AuthorDate: 2021-10-12 09:27:55 +0000 Commit: Kristof Provost CommitDate: 2022-03-02 16:00:07 +0000 pf tests: basic test for ether anchors Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32483 --- tests/sys/netpfil/pf/ether.sh | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/sys/netpfil/pf/ether.sh b/tests/sys/netpfil/pf/ether.sh index 8ca8d3fbf0c8..998badad91f1 100644 --- a/tests/sys/netpfil/pf/ether.sh +++ b/tests/sys/netpfil/pf/ether.sh @@ -339,6 +339,65 @@ dummynet_cleanup() pft_cleanup } +atf_test_case "anchor" "cleanup" +anchor_head() +{ + atf_set descr 'Test ether anchors' + atf_set require.user root +} + +anchor_body() +{ + pft_init + + epair=$(vnet_mkepair) + epair_a_mac=$(ifconfig ${epair}a ether | awk '/ether/ { print $2; }') + + vnet_mkjail alcatraz ${epair}b + + ifconfig ${epair}a 192.0.2.1/24 up + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "ether anchor \"foo\" in on lo0 {" \ + "ether block" \ + "}" + + # That only filters on lo0, so we should still be able to pass traffic + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + pft_set_rules alcatraz \ + "ether block in" \ + "ether anchor \"foo\" in on ${epair}b {" \ + "ether pass" \ + "}" + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 + + pft_set_rules alcatraz \ + "ether pass" \ + "ether anchor \"bar\" in on ${epair}b {" \ + "ether block" \ + "}" + atf_check -s exit:2 -o ignore ping -c 1 -t 2 192.0.2.2 + + pft_set_rules alcatraz \ + "ether block in" \ + "ether anchor \"baz\" on ${epair}b {" \ + "ether pass in from 01:02:03:04:05:06" \ + "}" \ + "ether pass in from ${epair_a_mac}" + atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2 +} + +anchor_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "mac" @@ -346,4 +405,5 @@ atf_init_test_cases() atf_add_test_case "direction" atf_add_test_case "captive" atf_add_test_case "dummynet" + atf_add_test_case "anchor" }