From nobody Thu Sep 19 20:21:20 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 4X8n3P42D5z5XKmx; Thu, 19 Sep 2024 20:21:21 +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 4X8n3P1PZrz4X6n; Thu, 19 Sep 2024 20:21:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726777281; 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=6CsIAHbfiqeOOZuB46xsHmkNVvVkcYxbVd2d9mB6aRU=; b=VHbAx6150f1SjvkaZ0WXnaecFnQq5+sf7VqyXT3JcWfOvbwC6ZWoB/9W6JUKqvcDw6BfVa WbkUuXmDP8pyNA2KHFbTQovSO7H4nRkmtbB8u5pMSg/b73X7Q1NbAtnNQQrDxWPXpplBMK Z/8wo7S99lUenx83KwDAsNYiKCikhnGHdDsCZO7ypjjyUsnrDX0b/VLR/SxtTvw11aq4Kl 32l5lmOcR6eF10o2CVy+PB4d9ayhzbd0skstG6tgVudVoEuCrmCAPWtN6gK4zIBjHem2OQ FieJr6RQxS0OD9vx4E3nK6BzG+KrD7PfprUs8fjrtxDyAzRxCy1/8dnXd7Xsyg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726777281; a=rsa-sha256; cv=none; b=YGkr0VpHdFtnFa7naVM7FSNCAJZwJtXkRVxLKgYYss2QN3GXmSTzzAIrK14FzYMnOGaFfz RfM/zYz4phb3uuUQeqz17AvqohfvWqcMe6RmS0IcKaBIfoI7WjYpCdOA360hdgJ3CaKpYj PxI/UyvI1qrXvAH3K0JS82wN/dQs6/ds/+wbOiSpo8h7KAZT5kD1qsDbT/dBhYqbIBPp0F Ju5cXGPBfx+gxl+KQ4wjlkLXEdutcLWlPVa3xceq/dYoli7It865j1Mr9s4n7V3hOTq5J9 KNfQTMCfUzRU65uf4WrEti4/S+6rml2KgstCagJDsLsmkugJ/LySK4dkN87yUg== 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=1726777281; 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=6CsIAHbfiqeOOZuB46xsHmkNVvVkcYxbVd2d9mB6aRU=; b=OulmBvRGEB5ZPvzVN2qIH/mDBvQ3lBEvG4hT1qBlXXNiPKp4sdBb2GY6Iy16GVLJr70uh2 BzwDnbatWgDRPfwPlTO6pwB7e1n5SqGydWUBC0GuBoKLa7GO2YPGhM39zfWxaEWm8G7fES Iqv/wLoN50gSWXpWeNS6poN7/yBThPtbTMvoW5LSzgnqfTEegrCjM+wN4FMUb+hz17BpaK xF0aOHuA2ZbA0Z/wEul+W1gcl1f1VbTw4LL6pnV4m1TnupLEcYdhzGijwR20YKcHD97S0d 7Jp71lHqKtFhPn1uqMAWSJ/1+u3zmvrGN5Ty1hficrH9GwY82KHGT2jecb66FQ== 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 4X8n3P0dntzKsY; Thu, 19 Sep 2024 20:21:21 +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 48JKLKGj046500; Thu, 19 Sep 2024 20:21:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48JKLKRn046497; Thu, 19 Sep 2024 20:21:20 GMT (envelope-from git) Date: Thu, 19 Sep 2024 20:21:20 GMT Message-Id: <202409192021.48JKLKRn046497@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: 7309c551a56e - main - pf tests: test the new log(matches) feature 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: 7309c551a56edeb2e3d35639ecb20b5a70885924 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7309c551a56edeb2e3d35639ecb20b5a70885924 commit 7309c551a56edeb2e3d35639ecb20b5a70885924 Author: Kristof Provost AuthorDate: 2024-09-03 15:59:44 +0000 Commit: Kristof Provost CommitDate: 2024-09-19 20:20:13 +0000 pf tests: test the new log(matches) feature Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46589 --- sbin/pfctl/tests/files/pf1023.in | 3 ++ sbin/pfctl/tests/files/pf1023.ok | 3 ++ sbin/pfctl/tests/pfctl_test_list.inc | 1 + tests/sys/netpfil/pf/pflog.sh | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/sbin/pfctl/tests/files/pf1023.in b/sbin/pfctl/tests/files/pf1023.in new file mode 100644 index 000000000000..4855ae0f339e --- /dev/null +++ b/sbin/pfctl/tests/files/pf1023.in @@ -0,0 +1,3 @@ +match log(matches) inet proto tcp +match log(matches) inet from 192.0.2.0/24 +pass diff --git a/sbin/pfctl/tests/files/pf1023.ok b/sbin/pfctl/tests/files/pf1023.ok new file mode 100644 index 000000000000..63fa40113ecf --- /dev/null +++ b/sbin/pfctl/tests/files/pf1023.ok @@ -0,0 +1,3 @@ +match log (matches) inet proto tcp all +match log (matches) inet from 192.0.2.0/24 to any +pass all flags S/SA keep state diff --git a/sbin/pfctl/tests/pfctl_test_list.inc b/sbin/pfctl/tests/pfctl_test_list.inc index 0ab336ec100d..413599252f64 100644 --- a/sbin/pfctl/tests/pfctl_test_list.inc +++ b/sbin/pfctl/tests/pfctl_test_list.inc @@ -131,3 +131,4 @@ PFCTL_TEST(1019, "Test pflow option") PFCTL_TEST(1020, "Test hashmark and semicolon comment") PFCTL_TEST(1021, "Endpoint-independent") PFCTL_TEST(1022, "Test received-on") +PFCTL_TEST(1023, "Test match log(matches)") diff --git a/tests/sys/netpfil/pf/pflog.sh b/tests/sys/netpfil/pf/pflog.sh index 75b7c5c217bb..f5a1241cb5a8 100644 --- a/tests/sys/netpfil/pf/pflog.sh +++ b/tests/sys/netpfil/pf/pflog.sh @@ -79,7 +79,61 @@ malformed_cleanup() pft_cleanup } +atf_test_case "matches" "cleanup" +matches_head() +{ + atf_set descr 'Test the pflog matches keyword' + atf_set require.user root +} + +matches_body() +{ + pflog_init + + epair=$(vnet_mkepair) + + vnet_mkjail alcatraz ${epair}a + jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up + + ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + jexec alcatraz pfctl -e + jexec alcatraz ifconfig pflog0 up + pft_set_rules alcatraz \ + "match log(matches) inet proto icmp" \ + "match log(matches) inet from 192.0.2.2" \ + "pass" + + jexec alcatraz tcpdump -n -e -ttt --immediate-mode -l -U -i pflog0 >> ${PWD}/pflog.txt & + sleep 1 # Wait for tcpdump to start + + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + echo "Rules" + jexec alcatraz pfctl -sr -vv + echo "States" + jexec alcatraz pfctl -ss -vv + echo "Log" + cat ${PWD}/pflog.txt + + atf_check -o match:".*rule 0/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \ + cat pflog.txt + atf_check -o match:".*rule 1/0\(match\): match in on ${epair}a: 192.0.2.2 > 192.0.2.1: ICMP echo request.*" \ + cat pflog.txt +} + +matches_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "malformed" + atf_add_test_case "matches" }