From nobody Fri May 09 22:16:25 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 4ZvNd63c5Bz5wCpv; Fri, 09 May 2025 22:16:26 +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 4ZvNd60KKSz3RQc; Fri, 09 May 2025 22:16:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746828986; 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=uwrgmZiIal5fRdhAURu8TP0XqA34h1z/8XyZBZ/ry+0=; b=F0clK4nSuSCSJeJVBi/Exz/wyF3VXznlO9OfA79/aZNYaphQiDsFOeybLNWm4pNtb9imib pGtR5fPbIkCY4PD9eidKug/qnHCaNEe0LGJUBxap9Q8HDcNl+wBYpM+NFNvEIkcbK2RGEr vDAMTgbtU2EMDpTtJN8oC3T0Uq7wnCSUNI9jY7NXygwUUEwPVsmho/WJTKcXeMvZH9G78Q 87Z2XEZiX1+JHEGK1o9+q1qjTicBdNKwfbjfwIcTXoU5MZL8ZZ3ihBDBTlz5yw5iYYl+s1 77L87ha14xqQu7Vyy1GpU+6fMyj1Fpd2TrP2V9QI/A3zVx916TxEQJnV1FviaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746828986; 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=uwrgmZiIal5fRdhAURu8TP0XqA34h1z/8XyZBZ/ry+0=; b=f91JarPQ4QhsIKz/AfdqYs5b7GXYCtONbBDK6kODldEoqCH6uUkvvl3BY9k2bvVka/ptK1 NlDY3SyYx1s9rVH0n0n/tPMlXB/qs54+bRkrRFfRUwLCKlMrDIYbWEJEWAMytdIwZN0YpF KUJmX+q9jJ04dqLwCidz5wj6g0yCSm7NRCjL4izwHJCz8x5lxHdxXXUyWZjcu3k6RhTLJD hf/hnekyfAl4TZgrAnfqj6X/GdQGanYd7O2fmgwrr0bqj5GDY0Lf1y4kz3WcWOBN8zhxmY /nkxBBTpFridS0C5qYRZwgpRL5OxZH00W1qH8mcNIKelUiagpHG52NxWoNeHJQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746828986; a=rsa-sha256; cv=none; b=HdVZ+1fiXnY/D0FL5cBItZXafJBZZZD9OuLly0a0qlHNP8Mw2N/BTB8paI7sgG3URHWIjR KbQokUcMHzRZC3pUJM05njbthdgobpcjERX+wnLK27mVavQrNS7q9gs/KOAZxyv8pmXliz rmXN5r6wW8R2J+Et97cNVjVXNd06anYr9YVWaFwM3ZsoChkpqOI96jE7RqAH0jtVNmGZwC UitrGRhjeMAxLMltLDXTollNPnFwKaMqoDZCPeVga9Whdr5tpNh4SWXZ63VpDeyLFP20wG fC5NQKsQn8viaHRY6qvcCk27tPKtdc2Nyva0AlvyBoouwPSMkZmi2wdb71tNQA== 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 4ZvNd53zPCz40c; Fri, 09 May 2025 22:16:25 +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 549MGPBu063153; Fri, 9 May 2025 22:16:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 549MGPlM063150; Fri, 9 May 2025 22:16:25 GMT (envelope-from git) Date: Fri, 9 May 2025 22:16:25 GMT Message-Id: <202505092216.549MGPlM063150@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: 6b78da357ddc - main - pf tests: test killing states by key 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: 6b78da357ddc22a1cfda217948e70d7d26c98828 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6b78da357ddc22a1cfda217948e70d7d26c98828 commit 6b78da357ddc22a1cfda217948e70d7d26c98828 Author: Kristof Provost AuthorDate: 2025-05-09 15:25:35 +0000 Commit: Kristof Provost CommitDate: 2025-05-09 20:49:30 +0000 pf tests: test killing states by key Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/killstate.sh | 56 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/sys/netpfil/pf/killstate.sh b/tests/sys/netpfil/pf/killstate.sh index 5d8e040d3cbb..59db93276d58 100644 --- a/tests/sys/netpfil/pf/killstate.sh +++ b/tests/sys/netpfil/pf/killstate.sh @@ -574,6 +574,61 @@ id_cleanup() pft_cleanup } +atf_test_case "key" "cleanup" +key_head() +{ + atf_set descr 'Test killing states by their key' + atf_set require.user root +} + +key_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 tcp" \ + "pass in proto icmp" + + # 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 + + # Get the state key + key=$(jexec alcatraz pfctl -ss -vvv | awk '/icmp/ { print($2 " " $3 " " $4 " " $5); }') + bad_key=$(echo ${key} | sed 's/icmp/tcp/') + + # Kill the wrong key + atf_check -s exit:0 -e "match:killed 0 states" \ + jexec alcatraz pfctl -k key -k "${bad_key}" + if ! find_state; + then + atf_fail "Killing a different ID removed the state." + fi + + # Kill the correct key + atf_check -s exit:0 -e "match:killed 1 states" \ + jexec alcatraz pfctl -k key -k "${key}" + if find_state; + then + atf_fail "Killing the state did not remove it." + fi +} + +key_cleanup() +{ + pft_cleanup +} + atf_test_case "nat" "cleanup" nat_head() { @@ -653,5 +708,6 @@ atf_init_test_cases() atf_add_test_case "match" atf_add_test_case "interface" atf_add_test_case "id" + atf_add_test_case "key" atf_add_test_case "nat" }