From nobody Mon Mar 3 16:08:30 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 4Z63dW2B6Kz5pjb7; Mon, 03 Mar 2025 16:08:31 +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 4Z63dW09hHz3xMc; Mon, 03 Mar 2025 16:08:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741018111; 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=JqofZa+NGiJnPY13sionM9SdJT1e9cOrFxVRF1Jm5z4=; b=JM0t8Y8IaewgWUctTvMMUDfphDoc9jF3lQb8sxkSpFUltD2c/PyW6OedL/cOcudysXW3mO aozIkK3bmQpILgVCgNE+3rL+uyjksNPN/aVs1u3ZdNdA2Ciu/HO7tu7MAxhSDJX6Q4FUqY WPsD3vB1DPd1LMFgPdlEsF+zyMhBQTE1hdMnbNNcyU9/JPH/3cGYPMXznIPWQa2j8Ic4DI FXJAj3hMvJtGRY0WyNDMWnTnmX8tP9inPm6a0VIAp7IZpRO4dT3rV08m1LgIT3WeWpoFA/ NN32Og1ulPSMQyOHPPbopMSU8mvkiYYIUE1vbmXTNzxhIPuxSDJerFg6ePSnfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1741018111; a=rsa-sha256; cv=none; b=v6hNRRYmZfF2T7BXV21m7W00iHYFm2B4aa7mpBJag+tsyzjM3Pd5TyoSlXHLRPxbmBvj0m /3EcPkl5evU2QLWyLZvHNUxdANpNpHEsQ39+FgBELR8TPTaO80aVPW91LRxEvRvppF1QCI 12OxBPkSrq+zEK1YinGRJ5GGHEe2Fs05p51CLZP2fLxUzRB+UeJ97r7VetAIBdhZizGkM0 35KKonEU2sgDR3P7QbTo3/dGZFIs0pkactU92R+8bz8GUrqcwrraLF2Cm3rFwL8sJBYeuC 1ea7T8cm7WASPltbGPLIyEXw/ioTSVhouTEcSpFy8Ghu1GwYqoFTjAF7Y3WulA== 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=1741018111; 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=JqofZa+NGiJnPY13sionM9SdJT1e9cOrFxVRF1Jm5z4=; b=I+KS2+EAfz+kwpnCcoOBhLGcG9GrTj4Ug3p2Qw9NUrt/dr/ZdXvebXu+Jh/vQwJeq3GYNc 5lW5152z1hkq2GRZPVpR2tU5DV3Ka6p+EI6IUA96x4PhKpKORdxjWu0cuwi4f8ywS2iwFQ Qcm7yoTHzxybpoAVlP7fYXWKqhnQWC7fBdSOLR58SBuXncf77UKTmSMTH7BfK4sWE6CmoY uCDcJ68paIW/S27ApfUn3km9WH3Y+7P0Q4PVGo4x2lwwf07huq8Yt0a1zAX36OVllTrJ/f iEYBNof8T6ESHuBLgmZglfRalMmPenUPmlLydddPKpHq7ag/yDERW9EeXBRS1g== 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 4Z63dV6tPSzvXw; Mon, 03 Mar 2025 16:08:30 +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 523G8UIA090719; Mon, 3 Mar 2025 16:08:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 523G8UDR090716; Mon, 3 Mar 2025 16:08:30 GMT (envelope-from git) Date: Mon, 3 Mar 2025 16:08:30 GMT Message-Id: <202503031608.523G8UDR090716@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: f32a25504461 - main - pf tests: test source-hash and random on empty table or interface without 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: f32a255044616604a3a038840feab785c005d10d Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f32a255044616604a3a038840feab785c005d10d commit f32a255044616604a3a038840feab785c005d10d Author: Kristof Provost AuthorDate: 2025-03-03 09:38:39 +0000 Commit: Kristof Provost CommitDate: 2025-03-03 16:07:17 +0000 pf tests: test source-hash and random on empty table or interface without address Attempt to provoke the crashes fixed by the previous commit. Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/nat.sh | 141 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/tests/sys/netpfil/pf/nat.sh b/tests/sys/netpfil/pf/nat.sh index 19dd39fe5848..f7026feb5078 100644 --- a/tests/sys/netpfil/pf/nat.sh +++ b/tests/sys/netpfil/pf/nat.sh @@ -301,10 +301,151 @@ nat6_nolinklocal_cleanup() pft_cleanup } +empty_table_common() +{ + option=$1 + + pft_init + + epair_wan=$(vnet_mkepair) + epair_lan=$(vnet_mkepair) + + vnet_mkjail srv ${epair_wan}a + jexec srv ifconfig ${epair_wan}a 192.0.2.2/24 up + + vnet_mkjail rtr ${epair_wan}b ${epair_lan}a + jexec rtr ifconfig ${epair_wan}b 192.0.2.1/24 up + jexec rtr ifconfig ${epair_lan}a 198.51.100.1/24 up + jexec rtr sysctl net.inet.ip.forwarding=1 + + ifconfig ${epair_lan}b 198.51.100.2/24 up + route add default 198.51.100.1 + + jexec rtr pfctl -e + pft_set_rules rtr \ + "table " \ + "nat on ${epair_wan}b inet from 198.51.100.0/24 -> ${option}" \ + "pass" + + # Sanity checks + atf_check -s exit:0 -o ignore \ + jexec rtr ping -c 1 192.0.2.2 + atf_check -s exit:0 -o ignore \ + ping -c 1 198.51.100.1 + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + # Provoke divide by zero + ping -c 1 192.0.2.2 + true +} + +atf_test_case "empty_table_source_hash" "cleanup" +empty_table_source_hash_head() +{ + atf_set descr 'Test source-hash on an emtpy table' + atf_set require.user root +} + +empty_table_source_hash_body() +{ + empty_table_common "source-hash" +} + +empty_table_source_hash_cleanup() +{ + pft_cleanup +} + +atf_test_case "empty_table_random" "cleanup" +empty_table_random_head() +{ + atf_set descr 'Test random on an emtpy table' + atf_set require.user root +} + +empty_table_random_body() +{ + empty_table_common "random" +} + +empty_table_random_cleanup() +{ + pft_cleanup +} + +no_addrs_common() +{ + option=$1 + + pft_init + + epair_wan=$(vnet_mkepair) + epair_lan=$(vnet_mkepair) + + vnet_mkjail srv ${epair_wan}a + jexec srv ifconfig ${epair_wan}a 192.0.2.2/24 up + + vnet_mkjail rtr ${epair_wan}b ${epair_lan}a + jexec rtr route add -net 192.0.2.0/24 -iface ${epair_wan}b + jexec rtr ifconfig ${epair_lan}a 198.51.100.1/24 up + jexec rtr sysctl net.inet.ip.forwarding=1 + + ifconfig ${epair_lan}b 198.51.100.2/24 up + route add default 198.51.100.1 + + jexec rtr pfctl -e + pft_set_rules rtr \ + "nat on ${epair_wan}b inet from 198.51.100.0/24 -> (${epair_wan}b) ${option}" \ + "pass" + + # Provoke divide by zero + ping -c 1 192.0.2.2 + true +} + +atf_test_case "no_addrs_source_hash" "cleanup" +no_addrs_source_hash_head() +{ + atf_set descr 'Test source-hash on an interface with no addresses' + atf_set require.user root +} + +no_addrs_source_hash_body() +{ + no_addrs_common "source-hash" +} + +no_addrs_source_hash_cleanup() +{ + pft_cleanup +} + +atf_test_case "no_addrs_random" "cleanup" +no_addrs_random_head() +{ + atf_set descr 'Test random on an interface with no addresses' + atf_set require.user root +} + +no_addrs_random_body() +{ + no_addrs_common "random" +} + +no_addrs_random_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "exhaust" atf_add_test_case "nested_anchor" atf_add_test_case "endpoint_independent" atf_add_test_case "nat6_nolinklocal" + atf_add_test_case "empty_table_source_hash" + atf_add_test_case "no_addrs_source_hash" + atf_add_test_case "empty_table_random" + atf_add_test_case "no_addrs_random" }