[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120231106.328585-1-aleksey.oladko@virtuozzo.com>
Date: Tue, 20 Jan 2026 23:11:06 +0000
From: Aleksei Oladko <aleksey.oladko@...tuozzo.com>
To: Pablo Neira Ayuso <pablo@...filter.org>, Florian Westphal <fw@...len.de>,
Phil Sutter <phil@....cc>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Shuah Khan <shuah@...nel.org>
Cc: Aleksei Oladko <aleksey.oladko@...tuozzo.com>,
Konstantin Khorenko <khorenko@...tuozzo.com>,
netfilter-devel@...r.kernel.org, coreteam@...filter.org,
netdev@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] selftests: netfilter: avoid RULE_REPLACE error when zeroing rule counters
The rpath.sh test fails on certain iptables versions when
attempting to zero all table counters at once via 'iptables -Z'.
The operation returns
RULE_REPLACE failed (Invalid argument): rule in chain PREROUTING
As a workaround, reset counters by iterating over rules and
zeroing them individually instead of using a single RULE_REPLACE
operation.
Signed-off-by: Aleksei Oladko <aleksey.oladko@...tuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@...tuozzo.com>
---
.../testing/selftests/net/netfilter/rpath.sh | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/netfilter/rpath.sh b/tools/testing/selftests/net/netfilter/rpath.sh
index 24ad41d526d9..90cc21233235 100755
--- a/tools/testing/selftests/net/netfilter/rpath.sh
+++ b/tools/testing/selftests/net/netfilter/rpath.sh
@@ -125,8 +125,24 @@ netns_ping() { # (netns, args...)
}
clear_counters() {
- [ -n "$iptables" ] && ip netns exec "$ns2" "$iptables" -t raw -Z
- [ -n "$ip6tables" ] && ip netns exec "$ns2" "$ip6tables" -t raw -Z
+ if [ -n "$iptables" ]; then
+ if ! ip netns exec "$ns2" "$iptables" -t raw -Z 2>/dev/null; then
+ ip netns exec "$ns2" "$iptables" -L PREROUTING -t raw -n --line-numbers | \
+ awk '$1+0>0 {print $1}' | \
+ while read rulenum; do
+ ip netns exec "$ns2" "$iptables" -t raw -Z PREROUTING "$rulenum" 2>/dev/null
+ done
+ fi
+ fi
+ if [ -n "$ip6tables" ]; then
+ if ! ip netns exec "$ns2" "$ip6tables" -t raw -Z 2>/dev/null; then
+ ip netns exec "$ns2" "$ip6tables" -L PREROUTING -t raw -n --line-numbers | \
+ awk '$1+0>0 {print $1}' | \
+ while read rulenum; do
+ ip netns exec "$ns2" "$ip6tables" -t raw -Z PREROUTING "$rulenum" 2>/dev/null
+ done
+ fi
+ fi
if [ -n "$nft" ]; then
(
echo "delete table inet t";
--
2.43.0
Powered by blists - more mailing lists