diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2009-01-29 18:49:48 -0800 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2009-01-29 18:49:48 -0800 |
commit | 9e1e38ba7c5f536d35aa5ff39d6b8e0583fd9509 (patch) | |
tree | 1e7ffc482693f0053cb16076e4e158a6a89805b4 /templates | |
parent | 4e2e957c31d888a7ed3f1473cc3aa42f97a19bcc (diff) | |
download | vyatta-op-firewall-9e1e38ba7c5f536d35aa5ff39d6b8e0583fd9509.tar.gz vyatta-op-firewall-9e1e38ba7c5f536d35aa5ff39d6b8e0583fd9509.zip |
Fix Bug 1041 Add "clear firewall name <name> rule <number> counters" command
Diffstat (limited to 'templates')
4 files changed, 25 insertions, 2 deletions
diff --git a/templates/clear/firewall/name/node.tag/counters/node.def b/templates/clear/firewall/name/node.tag/counters/node.def index b3a7724..61819b1 100644 --- a/templates/clear/firewall/name/node.tag/counters/node.def +++ b/templates/clear/firewall/name/node.tag/counters/node.def @@ -1,3 +1,6 @@ help: Clear firewall counters -run: sudo /sbin/iptables -Z "$4" - +run: sudo /sbin/iptables -Z "$4" 2>/dev/null + result=`echo $?` + if [ $result != 0 ]; then + echo Invalid firewall name \'$4\' + fi diff --git a/templates/clear/firewall/name/node.tag/rule/node.def b/templates/clear/firewall/name/node.tag/rule/node.def new file mode 100644 index 0000000..ff490a2 --- /dev/null +++ b/templates/clear/firewall/name/node.tag/rule/node.def @@ -0,0 +1 @@ +help: Clear firewall statistics for a rule diff --git a/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def b/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def new file mode 100644 index 0000000..2171060 --- /dev/null +++ b/templates/clear/firewall/name/node.tag/rule/node.tag/counters/node.def @@ -0,0 +1,17 @@ +help: Clear counters for specified rule +run: + firewall_name=$4 + cli_rule_num=$6 + result=`sudo /sbin/iptables -L $firewall_name 2>/dev/null` + result=`echo $?` + if [ $result != 0 ]; then + echo Invalid firewall name \'$firewall_name\' + else + iptables_rule_num=`sudo /sbin/iptables -L $firewall_name -xvn --line-numbers \ + | grep "/\* $firewall_name-$cli_rule_num " | awk '{ print $1 }'` + if [ -n "$iptables_rule_num" ]; then + sudo /sbin/iptables -Z "$firewall_name" "$iptables_rule_num" + else + echo No \'rule $cli_rule_num\' under firewall name \'$firewall_name\' + fi + fi diff --git a/templates/clear/firewall/name/node.tag/rule/node.tag/node.def b/templates/clear/firewall/name/node.tag/rule/node.tag/node.def new file mode 100644 index 0000000..1830c94 --- /dev/null +++ b/templates/clear/firewall/name/node.tag/rule/node.tag/node.def @@ -0,0 +1,2 @@ +help: Clear firewall statistics for given rule +allowed: ls /opt/vyatta/config/active/firewall/name/${COMP_WORDS[COMP_CWORD-2]}/rule/ 2>/dev/null |