From nobody Wed Nov 06 18:02:59 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 4XkCjb2dWcz1GnmF; Wed, 06 Nov 2024 18:02:59 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XkCjb1w80z4k0p; Wed, 6 Nov 2024 18:02:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730916179; 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=7hT2HwKvYjj7gQXIID3cesUgxz3Vh5T6kmOXcK4mZaY=; b=adljFiHqBT9lco+x3G/0WZhtIYTurUINAnk+2sa/s39QPRCpCZkcqksGMbqoNoGln9Lb1Y pT4RD6rRQBQLp1ioKoW4igfu8LWSY0Vzedg6Kb7wwLISx3Fb0wi2WP2Gn9EAvcD7mTYB1z KdDzJTQ2Mfv/TLYG7yvY/7B66CuY8o3ESHp9dmYqJMEQBCvAw+/uIakjQTDL62MYWPMm2d hO7ZTa8Xrwwb+GtU/W7NZlA7EYWEkyQkTe3zCRhx5azLN5IW2IuL5CSGFdJTIgX8C30JSV DuHvLEHqwID1hxQqFnydlipZ2WBo8nD4DzyKJyx+d6MnprYAQCDvBq9rJe9LoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730916179; 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=7hT2HwKvYjj7gQXIID3cesUgxz3Vh5T6kmOXcK4mZaY=; b=fiK6DyYnO9gLntNTCmkCIb+qM/8dvBjQDk804PPhTWwFcnICeHisKGySHXowYW7IZhYibM 4X6x0Q9C8gNBWSeWSsxw3yIw5f8VKXEoDMuYKTpF7OlOXhO9YmCVcfT8dcuTyOzEhdVGMv oo9Bybv/B2fx+6BbUpwngK5IAiFcvJZWLwicIP2krqr/qHZopTRmEHfu63ARzbKeiH6zsx MtmcUIL6zUSXA6b6uVYW1PBDZ8XBnrEMY48b4VnGe35XqnuixinOoktN9e03gxKrbNcfGO 8/4GsjhFfANlcj8+ibpHtcDjwekJ7haJzHU9rGBQJXhE2n0SoMfSkF3kYo4xqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730916179; a=rsa-sha256; cv=none; b=fC4vv7Bo/6HPuJIj199BLlV6TREU5GGze+/7oM8LkYEQ3aWkzctk8s+AcOkFBJ3Ju1PsjR VNOggTCn6IF8idPNZbq6PKCgI6zsTi/NRJvjsK1wfUQV+3H3yX1fhXkvTOCX/DMABATBRD QuRXQsbvsca/Q+2cFfSZkDPI2plLvx3KkUaSlzy90G96pdxR4HHOyNRsjKopFxvSeazclU WPRWZR4WFLDlu0c7oTd4dtLM+tuIZwl4jauRmA14KIWSrIWpssCc8r/Ylvhnr5Ggm0nSca M8aEVG8W+KF4cMEoXww8jvCTxP2tVD0KcAKmH/xZWie35XtYNFx5NXnVfNdb1w== 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 4XkCjb16gjz19W0; Wed, 6 Nov 2024 18:02:59 +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 4A6I2xpD059242; Wed, 6 Nov 2024 18:02:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A6I2x1c059239; Wed, 6 Nov 2024 18:02:59 GMT (envelope-from git) Date: Wed, 6 Nov 2024 18:02:59 GMT Message-Id: <202411061802.4A6I2x1c059239@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: a4e64fcd6808 - main - pf tests: test kill and clear source nodes paths 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: a4e64fcd6808f638ce938ed028716a5c87b75dae Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a4e64fcd6808f638ce938ed028716a5c87b75dae commit a4e64fcd6808f638ce938ed028716a5c87b75dae Author: Kristof Provost AuthorDate: 2024-11-06 14:28:31 +0000 Commit: Kristof Provost CommitDate: 2024-11-06 18:02:03 +0000 pf tests: test kill and clear source nodes paths Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/src_track.sh | 70 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/tests/sys/netpfil/pf/src_track.sh b/tests/sys/netpfil/pf/src_track.sh index 2038393a240e..9d0ca690d344 100755 --- a/tests/sys/netpfil/pf/src_track.sh +++ b/tests/sys/netpfil/pf/src_track.sh @@ -52,7 +52,19 @@ source_track_body() "pass out keep state (source-track)" ping -c 3 192.0.2.1 - jexec alcatraz pfctl -s all -v + atf_check -s exit:0 -o match:'192.0.2.2 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS + + # Flush all source nodes + jexec alcatraz pfctl -FS + + # We can't find the previous source node any more + atf_check -s exit:0 -o not-match:'192.0.2.2 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS + + # But we still have the state + atf_check -s exit:0 -o match:'all icmp 192.0.2.1:8 <- 192.0.2.2:.*' \ + jexec alcatraz pfctl -ss } source_track_cleanup() @@ -60,6 +72,61 @@ source_track_cleanup() pft_cleanup } +atf_test_case "kill" "cleanup" +kill_head() +{ + atf_set descr 'Test killing source nodes' + atf_set require.user root +} + +kill_body() +{ + pft_init + + epair=$(vnet_mkepair) + vnet_mkjail alcatraz ${epair}b + + ifconfig ${epair}a 192.0.2.2/24 up + ifconfig ${epair}a inet alias 192.0.2.3/24 up + jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up + + # Enable pf! + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "pass in keep state (source-track)" \ + "pass out keep state (source-track)" + + # Establish two sources + atf_check -s exit:0 -o ignore \ + ping -c 1 -S 192.0.2.2 192.0.2.1 + atf_check -s exit:0 -o ignore \ + ping -c 1 -S 192.0.2.3 192.0.2.1 + + # Check that both source nodes exist + atf_check -s exit:0 -o match:'192.0.2.2 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS + atf_check -s exit:0 -o match:'192.0.2.3 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS + + +jexec alcatraz pfctl -sS + + # Kill the 192.0.2.2 source + jexec alcatraz pfctl -K 192.0.2.2 + + # The other source still exists + atf_check -s exit:0 -o match:'192.0.2.3 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS + + # But not the one we killed + atf_check -s exit:0 -o not-match:'192.0.2.2 -> 0.0.0.0 \( states 1,.*' \ + jexec alcatraz pfctl -sS +} + +kill_cleanup() +{ + pft_cleanup +} max_src_conn_rule_head() { @@ -188,6 +255,7 @@ max_src_states_rule_cleanup() atf_init_test_cases() { atf_add_test_case "source_track" + atf_add_test_case "kill" atf_add_test_case "max_src_conn_rule" atf_add_test_case "max_src_states_rule" }