From 28fa76f1360015672caddca6352d9b2dd9b20dc9 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 14 Dec 2011 04:20:00 +0700 Subject: Bug #6617: fix counters flush for rules with logging. --- scripts/vyatta-clear-nat-counters.pl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/vyatta-clear-nat-counters.pl b/scripts/vyatta-clear-nat-counters.pl index a15da6c..06e67ae 100755 --- a/scripts/vyatta-clear-nat-counters.pl +++ b/scripts/vyatta-clear-nat-counters.pl @@ -89,11 +89,15 @@ sub clear_rule { $iptables_rule = `$cmd`; return "couldn't find an underlying iptables rule" if ! defined $iptables_rule; chomp $iptables_rule; + # Rules with "log" statement and "tcp_udp" rules take more than one line + my @numbers = split(/\n/, $iptables_rule); # clear the counters for that rule - $cmd = "$iptables -t nat -Z $chain $iptables_rule"; - $error = system($cmd); - return "error clearing counters for NAT rule $clirule" if $error; + for my $number (@numbers) { + $cmd = "$iptables -t nat -Z $chain $number"; + $error = system($cmd); + return "error clearing counters for NAT rule $clirule" if $error; + } } return; } -- cgit v1.2.3