From nobody Thu Jan 02 12:35:08 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 4YP5l04yKhz5j975; Thu, 02 Jan 2025 12:35:08 +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 4YP5l0411Cz4FTX; Thu, 2 Jan 2025 12:35:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735821308; 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=C1Z4x2t7+piejvUOYNB35XXe7zBVdhxPWpWinJyftr0=; b=jPxf7kR7nECvVdUp43l3EA78kNvBr8vv7ME3Bt2E0vMyUYS3QYMufjWyDD0rqRlm3GV0Fx W9TGgTUDZ5rbHm0HP3bZiTqlo9wwLJlA3o8tCzcR6Lg73JRkOaEoBhbvD8Eu+KWQ900mnZ xBD4UvU2dgyBpEA/Bjbn6SI7tE1x+CvfWthSTwI3l72YCKgfnsxZDu0f5FNC1xBLJg0IKW +7eEe+zy3kzvL/0O8XQiFZTgwXD8cJI18zqe9+kavfHLdfPv1NVWjWnAfcFRwHlJnsNi+g WxEg3zYohENPZjsAUvkQ2KWbaHfjqh4Q6Tq/6ARB/jWAOIUg7vVkdYvklZ/S2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735821308; 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=C1Z4x2t7+piejvUOYNB35XXe7zBVdhxPWpWinJyftr0=; b=JgqH3R6VNQ1251ngxdOGyhRgX8JBw8N5Z2aUW8HcK3yzXLI3c3kJtgTONdO0MSg8K1PoYz OVQIvcdfvCCAF1foUnigrAXGpgCWrnMne7yDisvWjzwsHjalOKcSyBvHktSx1kmSNVM8Lp NSEljh79+S6vb/1zgjrNyKc4FVMtC/uX9WBuWRFT6E4ZG5LYqnkUFsbqTR1ivKw3qo9B46 4dmCaodcUP9siaP4G4N3QRPdOrCfuOhM5Ij9GbYrxgxEjtg21Ju0GEhxgle64zSNrkvPfy QUgWckeuPjTZYxOAC54u+mnq+hEgnMkjoC33cEV/NXw0h1pCcGb4yD3NQ076hw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735821308; a=rsa-sha256; cv=none; b=jcXorIB8aGfseWUA6LBuA7If7lKoWLkgBvuu67jo8Y+sH8pkwraLiBnDGP26NdFW6xg52W PJ7PpkqVFivIwcIsOUyZawHi+X5KprsmLwiMXtZ/fNjW0Ktgd9Ej1V8hruwT9+Y0egM6Zl KYuks0bHQOrSCzVbR4RjcXcIil2eLyVnVeOdC5BpIpG7tT43KpTsLa0UK77zSmhxzP3Urt 2h6hpm/XWYF/LzQVzmQky4BejARQX7q1TfbBohCK5L6Jk9J1fQugbdXONGPSYg1jCWDy6d CJkO7NZdzSE5jUbqxbqIjBKsPfJ/l55zin+ACmc9t4MNFocn1DxDcPs32YJHYQ== 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 4YP5l03V9kzdWX; Thu, 02 Jan 2025 12:35:08 +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 502CZ8P7007494; Thu, 2 Jan 2025 12:35:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 502CZ81v007491; Thu, 2 Jan 2025 12:35:08 GMT (envelope-from git) Date: Thu, 2 Jan 2025 12:35:08 GMT Message-Id: <202501021235.502CZ81v007491@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: 0749d8134300 - main - pf tests: check cleared time when zeroing stats for table addresses 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: 0749d8134300b8e3c956e161890ab496247d2542 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=0749d8134300b8e3c956e161890ab496247d2542 commit 0749d8134300b8e3c956e161890ab496247d2542 Author: Leonid Evdokimov AuthorDate: 2025-01-02 09:30:06 +0000 Commit: Kristof Provost CommitDate: 2025-01-02 12:34:50 +0000 pf tests: check cleared time when zeroing stats for table addresses Verify that we reset the cleared time when we zero an address' counters in a table. PR: 282877, 282984 Reviewed by: kp MFC after: 2 weeks Signed-off-by: Leonid Evdokimov Differential Revision: https://reviews.freebsd.org/D48242 --- tests/sys/netpfil/pf/table.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index 62c9d66d80ce..f655463f3c03 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -116,6 +116,20 @@ zero_one_head() atf_set require.user root } +pft_cleared_ctime() +{ + jexec "$1" pfctl -t "$2" -vvT show | awk -v ip="$3" ' + ($1 == ip) { m = 1 } + ($1 == "Cleared:" && m) { + sub("[[:space:]]*Cleared:[[:space:]]*", ""); print; exit }' +} + +ctime_to_unixtime() +{ + # NB: it's not TZ=UTC, it's TZ=/etc/localtime + date -jf '%a %b %d %H:%M:%S %Y' "$1" '+%s' +} + zero_one_body() { epair_send=$(vnet_mkepair) @@ -145,16 +159,31 @@ zero_one_body() -o match:'Out/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ jexec alcatraz pfctl -t foo -T show -vv + local uniq base ts1 ts3 + uniq=`jexec alcatraz pfctl -t foo -vvT show | sort -u | grep -c Cleared` + atf_check_equal 1 "$uniq" # time they were added + + base=`pft_cleared_ctime alcatraz foo 192.0.2.1` + atf_check -s exit:0 -e ignore \ jexec alcatraz pfctl -t foo -T zero 192.0.2.3 + ts1=`pft_cleared_ctime alcatraz foo 192.0.2.1` + atf_check_equal "$base" "$ts1" + + ts3=`pft_cleared_ctime alcatraz foo 192.0.2.3` + atf_check test "$ts1" != "$ts3" + + ts1=`ctime_to_unixtime "$ts1"` + ts3=`ctime_to_unixtime "$ts3"` + atf_check test $(( "$ts3" - "$ts1" )) -lt 10 # (3 pings * 2) + epsilon + atf_check test "$ts1" -lt "$ts3" + # We now have a zeroed and a non-zeroed counter, so both patterns # should match atf_check -s exit:0 -e ignore \ -o match:'In/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ -o match:'Out/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ - jexec alcatraz pfctl -t foo -T show -vv - atf_check -s exit:0 -e ignore \ -o match:'In/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ -o match:'Out/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ jexec alcatraz pfctl -t foo -T show -vv