From nobody Thu Jan 16 15:23:03 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 4YYmpH2kpBz5kYt5; Thu, 16 Jan 2025 15:23:03 +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 4YYmpH1sDQz4KjN; Thu, 16 Jan 2025 15:23:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737040983; 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=e9y6XAIQogJmz+Crj/oSVLuOl88XX8yoZEs54JKxCMo=; b=J4w93QB4GBlVfi+lTl5jFqkxXWWUUFqTK5h7kF9GVEBLtBgckUw33vzVAUJkPVFC2yxs3t +EEhjfjC5vpxYaPdY2N6/OzLK7LyAMDf8bS5EVBOG9TcqgYBhjxcDG99W/isQ05EYY/oM3 z8prailg6x0/9HsKXphCDNq+R0GPFGyYBxEFkqtZy3ttWJnak/gIPPDR4h92Q6D6cHlkco dWLmh1imxSKL/9+0R/yVD6g3LwTvvkUQrMKo28CHC5gJPZ6S03ZX9Qo8bpADxUG92IPrgY cMkDyPEUHF3HscgP/D4r0xDLxTesD76sYA2hpmEqAiLIIEctX8n8ae8smtR6Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737040983; 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=e9y6XAIQogJmz+Crj/oSVLuOl88XX8yoZEs54JKxCMo=; b=DDr7DA44ByTshUSBJjY+Jw5f+pHywLzF7vqdcezgy6LKJjQ7BrjuxW+SNk96UcDH+J+i5d hZS4t12s2leIOJihBOXBFSS/NW8pJOXXPm46TG6HrNSQTI2e6KashQ0IWzimnZRLKcw8ku VDYOvBtERiiWOFjVahgC5ZXuIdnPLpv+/O40K63BouMZnQ+Pp7Q+a/Uaqqx4KJPfkfAhuy t3lhUw2lRbOzi+mwHAbg1I7wwSYCG716HP/JYvk+80QDuy5FBfPkkBZEpOQ7cGFERt+Jkg HwBVysqqaR1LoKC7oJSbJhAb2C+HolmTSFxthzrKED4i2gKLEy7eKccNif1RKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737040983; a=rsa-sha256; cv=none; b=Rk6hmJANP8T+RPF4tiNEYvA0llDAdmagOEcIL66cE8BQrUC+nLCe9W23MNpkAYMiMbihcA yYw1gxSVu++MXdVS/dY1bqenl9r2zjTg9VF8fUShrbkoflnS1g9yiIBT0W2bjw3CbTsS3/ qOxPQbSheL1IlxqxBdysWDldQFaZrYHfqCLvMvhBwpVuikwDZ1W8yrIYjE5nzIptj/PgO6 12NGb99GzgaADS7N9JGstchxgm1PmM5UtL20gt+INKYcxjfmFcR8lhXB/LBqii3cdBuMJk BLdUnxG9KaW/C8INPuPD5Ai15Q/5Z0p8h5ntVWyVDsjkegyKm2DeJ1KkunXjMg== 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 4YYmpH18N0zfHT; Thu, 16 Jan 2025 15:23:03 +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 50GFN3R5087861; Thu, 16 Jan 2025 15:23:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50GFN3lV087858; Thu, 16 Jan 2025 15:23:03 GMT (envelope-from git) Date: Thu, 16 Jan 2025 15:23:03 GMT Message-Id: <202501161523.50GFN3lV087858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 635c2b82f60e - stable/13 - pf tests: check cleared time when zeroing stats for table addresses 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 635c2b82f60e7417746a03d4d22c7fafd08f7e7c Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=635c2b82f60e7417746a03d4d22c7fafd08f7e7c commit 635c2b82f60e7417746a03d4d22c7fafd08f7e7c Author: Leonid Evdokimov AuthorDate: 2025-01-02 09:30:06 +0000 Commit: Kristof Provost CommitDate: 2025-01-16 08:42:04 +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 (cherry picked from commit 0749d8134300b8e3c956e161890ab496247d2542) --- 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 b650884c7c30..b2fb2ea728e8 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