From 4abb44c978d75656f69dd59f24522eb970881ccf Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 17 Sep 2019 18:43:21 +0200 Subject: xtables-restore: Introduce rule counter tokenizer function The same piece of code appears three times, introduce a function to take care of tokenizing and error reporting. Pass buffer pointer via reference so it can be updated to point to after the counters (if found). While being at it, drop pointless casting when passing pcnt/bcnt to add_argv(). Signed-off-by: Phil Sutter Acked-by: Pablo Neira Ayuso --- .../testcases/ipt-restore/0008-restore-counters_0 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 iptables/tests/shell/testcases/ipt-restore/0008-restore-counters_0 (limited to 'iptables/tests/shell/testcases/ipt-restore') diff --git a/iptables/tests/shell/testcases/ipt-restore/0008-restore-counters_0 b/iptables/tests/shell/testcases/ipt-restore/0008-restore-counters_0 new file mode 100755 index 00000000..5ac70682 --- /dev/null +++ b/iptables/tests/shell/testcases/ipt-restore/0008-restore-counters_0 @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +DUMP="*filter +:foo - [23:42] +[13:37] -A foo -j ACCEPT +COMMIT +" + +EXPECT=":foo - [0:0] +[0:0] -A foo -j ACCEPT" + +$XT_MULTI iptables-restore <<< "$DUMP" +diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables-save --counters | grep foo) + +# iptables-*-restore ignores custom chain counters :( +EXPECT=":foo - [0:0] +[13:37] -A foo -j ACCEPT" + +$XT_MULTI iptables-restore --counters <<< "$DUMP" +diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables-save --counters | grep foo) -- cgit v1.2.3