From nobody Fri Oct 31 15:28:38 2025 X-Original-To: dev-commits-src-all@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 4cylHq0ksWz6FyjM; Fri, 31 Oct 2025 15:28:39 +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 4cylHq07CKz3bCq; Fri, 31 Oct 2025 15:28:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761924519; 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=Jd7snt2fN+daR/mzkBNm1/nzIkV0FxYpHBHlBjJZ5U0=; b=oE/r6e/Qg44Kjk5wFoaWk6KNjUSz/f3G1MVseaLZYNzRJzgSnJ7aQ2E39txZvR5ZqTV8HL SaCq/RJAmibqZWR7i8cm99+ZiKf1wM8KPVX/bjfpYiALKkUZ5NQ5pAJJfx0+R4F3iIKd2l v+VjyD1boDmQ/LGg+i8zwk5MioHWmFHxOaidepY00DYnbSwTDoqpP0lmipukgI6zltRvAn itgqChf1HT+CCs8NDgI5xRdEtFmaCDV6tFjYF4pQDxBt+5VSCcYf82T5WfAzF+GyOFULE2 iw6XviJwcJB9NDawHVHPTvHsZAlf2TO8IypMU09w2b1EwEuUW0thh4kfmN50dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761924519; 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=Jd7snt2fN+daR/mzkBNm1/nzIkV0FxYpHBHlBjJZ5U0=; b=ktrAHihv8KIr1iUbBcC1GPzGFhWb/neTAmeVBaaOG0h06m7fEW2N52EmLk0AiqCVhTz8QT Hp6Yz7HvSPdeLxpn/qpk/O8dwn2oPsNgGU6ZNsgy7XCeSMMajkqgeisrBd6vB6BrxeETdn r683WSOFedc2Ijg2OVX7Fy33TxFTEoKCtgycbiYvv++ZxoaXxPbOY0ci0Axu6YPUoTWVB5 RREwQtmlwMscNXjzXSYHfMT+XNSbp8Gx4qwp/0m95ge5VLCNBoHTd0b3fbjfAdwjA1XT3o 1002MxuEhO6fZXiuYdc4v/0BEnSqcVzSpwRkU2Rb/Pr6sMgrE/VMkT+OEtcF4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761924519; a=rsa-sha256; cv=none; b=ibLTwX6zBhfJS1Ol14SIdAFKtM2W5F+NN7ZEXqedhS66zdtuqyKH/KAHwvkcErDitYMhWk XRcS2nzFi7e1CtxgrpAWcEI3mSF2qINjVbFxLsvrtmkjOQ7iPUlbtdRTMmLMgrzW02xuuO kQgbEndQEFwc97gmatqN1JTdwxFqVBjOaHPGYH24yz+quYobjJcwsHwz3c7v/+hKHposSv TaN4hXinb0RM7YysvKOFOMN1ALdDLY93OsUaSnfNsCxNwEKdzqawRpw51g7MDikWnZRg5Q N/fbWi4WYoOTRYRZYLHa6T8t95coZ2/qcaU+mrRwa6JsFqyPwUvhElMdXDzZ+Q== 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 4cylHp6YsYz1DF4; Fri, 31 Oct 2025 15:28:38 +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 59VFScqK045139; Fri, 31 Oct 2025 15:28:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59VFScAK045136; Fri, 31 Oct 2025 15:28:38 GMT (envelope-from git) Date: Fri, 31 Oct 2025 15:28:38 GMT Message-Id: <202510311528.59VFScAK045136@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: 56d5ec30e8e1 - main - pf tests: pfctl -T replace test List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 56d5ec30e8e135f716e10b5bf2c0cc1ba18933f9 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=56d5ec30e8e135f716e10b5bf2c0cc1ba18933f9 commit 56d5ec30e8e135f716e10b5bf2c0cc1ba18933f9 Author: Kristof Provost AuthorDate: 2025-10-31 09:44:00 +0000 Commit: Kristof Provost CommitDate: 2025-10-31 15:24:09 +0000 pf tests: pfctl -T replace test Sponsored by: Rubicon Communications, LLC ("Netgate") --- tests/sys/netpfil/pf/table.sh | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index 69fe12fc9804..6761ce652beb 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -747,6 +747,67 @@ in_anchor_cleanup() pft_cleanup } +atf_test_case "replace" "cleanup" +replace_head() +{ + atf_set descr 'Test table replace command' + atf_set require.user root +} + +replace_body() +{ + pft_init + pwd=$(pwd) + + epair_send=$(vnet_mkepair) + ifconfig ${epair_send}a 192.0.2.1/24 up + + vnet_mkjail alcatraz ${epair_send}b + jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "table counters { 192.0.2.1 }" \ + "block all" \ + "pass in from to any" \ + "pass out from any to " \ + "set skip on lo" + + atf_check -s exit:0 -o ignore ping -c 3 192.0.2.2 + + # Replace the address + atf_check -s exit:0 -e "match:1 addresses added." -e "match:1 addresses deleted." \ + jexec alcatraz pfctl -t foo -T replace 192.0.2.3 + atf_check -s exit:0 -o "match:192.0.2.3" \ + jexec alcatraz pfctl -t foo -T show + atf_check -s exit:2 -o ignore ping -c 3 192.0.2.2 + + # Negated address + atf_check -s exit:0 -e "match:1 addresses changed." \ + jexec alcatraz pfctl -t foo -T replace "!192.0.2.3" + + # Now add 500 addresses + for i in `seq 1 2`; do + for j in `seq 1 250`; do + echo "1.${i}.${j}.1" >> ${pwd}/foo.lst + done + done + atf_check -s exit:0 -e "match:500 addresses added." -e "match:1 addresses deleted." \ + jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst + + atf_check -s exit:0 -o "not-match:192.0.2.3" \ + jexec alcatraz pfctl -t foo -T show + + # Loading the same list produces no changes. + atf_check -s exit:0 -e "match:no changes." \ + jexec alcatraz pfctl -t foo -T replace -f ${pwd}/foo.lst +} + +replace_cleanup() +{ + pft_cleanup +} + atf_init_test_cases() { atf_add_test_case "v4_counters" @@ -765,4 +826,5 @@ atf_init_test_cases() atf_add_test_case "large" atf_add_test_case "show_recursive" atf_add_test_case "in_anchor" + atf_add_test_case "replace" }