From nobody Wed Sep 10 19:52:28 2025 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 4cMWYm3ZlZz66nTJ; Wed, 10 Sep 2025 19:52: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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cMWYm1cJgz3tvg; Wed, 10 Sep 2025 19:52:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757533948; 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=hHcilwX7gokDODBHiErPe92OAKOEeu5wonwd6Rh5BoE=; b=ieesT0Zq3s7IRrCI6hwYn5Zi9Gxj1QeMHHfYEeRb6VmtFFMaxwFwMGQ23nAIzrMk+lueHi 2zsLo4ZPqItPirhcnV3vbq7yENTYbSGoM2OeMFrC22P5B2tQLTM1VjG9svx/mitQmzaBG6 VL5kvNgyBbyoueo6l5IB199YDqCHN4Pnucg3fEVDhus0J5iDS5AISh1kMhHx1pFK2QmYZ8 nC6mUFHejOoWb8QGElo3qVI1FvGCPtH1Atl89C2CvG4k9rOtfvrVXikjTVnj/qDOWInni5 B4P6BYnJtMQbWY3bRr1OLAtkJRDGMGvYLCv+CZqMxZMIhN0pMSyPXSIXsiC0gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757533948; 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=hHcilwX7gokDODBHiErPe92OAKOEeu5wonwd6Rh5BoE=; b=jYVxi/LCeX6wnp4ubuU22dXV/FJaMdu6UwqgVu80k1F4xilU5ugPG3E3yLjK3S6o0TV9JY 4Wm4ZLcsxlDOw2lwmdcErj7FYVvKdBVejs7WX2tymSOXV4HBv5T/1N8EMH5iTiVVF5Bcyp WZS0Gt/f/W7pRWDYI26mkeg02n1BAbxFcU5uzTs9cQDD6TDQcpY8SPNAB8TXUdXK+YbvAQ p01mnEepT61CQ8InGrsNlK1YQPIgyR+xvgp/8RSkcADG8ExpvoWhd0SeLGjwaz6wheaasT Tyo9gzvty2I1+01K0x2rbAeg3f1JAZSdqj37Lx+68fVYzPB1HlHx6ntJMbsq6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757533948; a=rsa-sha256; cv=none; b=sLg+Hpr5pw0B564RM/KWQjp9zzNrURvuODmrUJYOE9Exxi3kMV7PmwvJxu314ysKa6tSUm cbNkYXAiigk3ehzFSdPsfltucRlet83dL5LFbxuHUz0mOT3p8JekqCOL7gEWAuB62Biffq Q90JzQNAn2nn8URD+dg7Zwr1IdUKKnB4ucpDJdnICwAoK+63Pa8dECdC048RQ0JCFhMq+8 eWAlN0frdJ7YBHlVks1iyRZCGJXWzq4JycCg5ZlucN1dsHcNuArEoJQhky843RQUTnWu11 JI4nWTPvS1T8xURw5visj9+iBD0aHENGH7xCFF2wcTUlVE1gyevljXt4wjv9NQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cMWYm1D9dzcL9; Wed, 10 Sep 2025 19:52:28 +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 58AJqSXX095403; Wed, 10 Sep 2025 19:52:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58AJqSJU095399; Wed, 10 Sep 2025 19:52:28 GMT (envelope-from git) Date: Wed, 10 Sep 2025 19:52:28 GMT Message-Id: <202509101952.58AJqSJU095399@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: 53e44c59d13e - main - pf tests: test state killing by source and destination address 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: 53e44c59d13ed0dd5dc5563b1109df8d6dd63325 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=53e44c59d13ed0dd5dc5563b1109df8d6dd63325 commit 53e44c59d13ed0dd5dc5563b1109df8d6dd63325 Author: Kristof Provost AuthorDate: 2025-08-20 14:16:54 +0000 Commit: Kristof Provost CommitDate: 2025-09-10 19:51:40 +0000 pf tests: test state killing by source and destination address Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/killstate.sh | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 0d98db822535..ffb01df57908 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -105,6 +105,68 @@ v4_cleanup() pft_cleanup } +atf_test_case "src_dst" "cleanup" +src_dst_head() +{ + atf_set descr 'Test killing a state with source and destination specified' + atf_set require.user root +} + +src_dst_body() +{ + pft_init + + epair=$(vnet_mkepair) + ifconfig ${epair}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair}b + jexec alcatraz ifconfig ${epair}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz "block all" \ + "pass in proto icmp" \ + "set skip on lo" + + # Sanity check & establish state + atf_check -s exit:0 -o ignore ${common_dir}/pft_ping.py \ + --sendif ${epair}a \ + --to 192.0.2.2 \ + --replyif ${epair}a + + # Change rules to now deny the ICMP traffic + pft_set_rules noflush alcatraz "block all" + if ! find_state; + then + atf_fail "Setting new rules removed the state." + fi + + # Killing with the wrong source IP doesn't affect our state + jexec alcatraz pfctl -k 192.0.2.3 -k 192.0.2.2 + if ! find_state; + then + atf_fail "Killing with the wrong source IP removed our state." + fi + + # Killing with the wrong destination IP doesn't affect our state + jexec alcatraz pfctl -k 192.0.2.1 -k 192.0.2.3 + if ! find_state; + then + atf_fail "Killing with the wrong destination IP removed our state." + fi + + # But it does with the correct one + jexec alcatraz pfctl -k 192.0.2.1 -k 192.0.2.2 + if find_state; + then + atf_fail "Killing with the correct IPs did not remove our state." + fi +} + +src_dst_cleanup() +{ + pft_cleanup +} + atf_test_case "v6" "cleanup" v6_head() { @@ -698,6 +760,7 @@ nat_cleanup() atf_init_test_cases() { atf_add_test_case "v4" + atf_add_test_case "src_dst" atf_add_test_case "v6" atf_add_test_case "label" atf_add_test_case "multilabel"