[iptables PATCH 3/3] tests: shell: Test some commands involving rule numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Skip on ip6tables and arptables as they share the relevant code with
iptables.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 .../shell/testcases/ebtables/0011-rulenum_0   | 104 ++++++++++++++++++
 .../shell/testcases/iptables/0011-rulenum_0   |  93 ++++++++++++++++
 2 files changed, 197 insertions(+)
 create mode 100755 iptables/tests/shell/testcases/ebtables/0011-rulenum_0
 create mode 100755 iptables/tests/shell/testcases/iptables/0011-rulenum_0

diff --git a/iptables/tests/shell/testcases/ebtables/0011-rulenum_0 b/iptables/tests/shell/testcases/ebtables/0011-rulenum_0
new file mode 100755
index 0000000000000..51302f347baf4
--- /dev/null
+++ b/iptables/tests/shell/testcases/ebtables/0011-rulenum_0
@@ -0,0 +1,104 @@
+#!/bin/bash -x
+
+case "$XT_MULTI" in
+*xtables-nft-multi)
+	;;
+*)
+	echo "skip $XT_MULTI"
+	exit 0
+	;;
+esac
+
+set -e
+
+load_ruleset() {
+	$XT_MULTI ebtables-restore <<EOF
+*filter
+-A FORWARD --mark 0x1 -c 1 2
+-A FORWARD --mark 0x2 -c 2 3
+EOF
+}
+
+load_ruleset
+
+$XT_MULTI ebtables -L 0 && exit 1
+
+EXPECT='--mark 0x1 -j CONTINUE , pcnt = 1 -- bcnt = 2'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI ebtables -L FORWARD 1 --Lc)
+
+EXPECT='--mark 0x2 -j CONTINUE , pcnt = 2 -- bcnt = 3'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -L FORWARD 2 --Lc)
+
+[[ -z $($XT_MULTI ebtables -L FORWARD 3) ]]
+
+$XT_MULTI ebtables -S FORWARD 0 && exit 1
+
+EXPECT='[1:2] -A FORWARD --mark 0x1 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S FORWARD 1)
+
+EXPECT='[2:3] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S FORWARD 2)
+
+[[ -z $($XT_MULTI ebtables -S FORWARD 3) ]]
+
+$XT_MULTI ebtables -v -Z FORWARD 0 && exit 1
+
+[[ -z $($XT_MULTI ebtables -v -Z FORWARD 1) ]]
+EXPECT='[0:0] -A FORWARD --mark 0x1 -j CONTINUE
+[2:3] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+[[ -z $($XT_MULTI ebtables -v -Z FORWARD 2) ]]
+EXPECT='[0:0] -A FORWARD --mark 0x1 -j CONTINUE
+[0:0] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+$XT_MULTI ebtables -v -Z FORWARD 3 && exit 1
+
+load_ruleset
+
+[[ -z $($XT_MULTI ebtables -v -L -Z FORWARD 1) ]]
+EXPECT='[0:0] -A FORWARD --mark 0x1 -j CONTINUE
+[2:3] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+[[ -z $($XT_MULTI ebtables -v -L -Z FORWARD 2) ]]
+EXPECT='[0:0] -A FORWARD --mark 0x1 -j CONTINUE
+[0:0] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+load_ruleset
+
+$XT_MULTI ebtables -v -Z -L FORWARD 0 && exit 1
+
+EXPECT='--mark 0x1 -j CONTINUE
+Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -Z -L FORWARD 1)
+EXPECT='[0:0] -A FORWARD --mark 0x1 -j CONTINUE
+[0:0] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+EXPECT='--mark 0x2 -j CONTINUE
+Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -Z -L FORWARD 2)
+
+$XT_MULTI ebtables -v -Z -L FORWARD 0 && exit 1
+
+EXPECT='Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -Z -L FORWARD 3)
+
+load_ruleset
+
+[[ -z $($XT_MULTI ebtables -v -D FORWARD 1) ]]
+EXPECT='[2:3] -A FORWARD --mark 0x2 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+load_ruleset
+
+[[ -z $($XT_MULTI ebtables -v -D FORWARD 2) ]]
+EXPECT='[1:2] -A FORWARD --mark 0x1 -j CONTINUE'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI ebtables -v -S | grep -v '^-P')
+
+$XT_MULTI ebtables -v -D FORWARD 3 && exit 1
+
+exit 0
diff --git a/iptables/tests/shell/testcases/iptables/0011-rulenum_0 b/iptables/tests/shell/testcases/iptables/0011-rulenum_0
new file mode 100755
index 0000000000000..4f973cdc6f378
--- /dev/null
+++ b/iptables/tests/shell/testcases/iptables/0011-rulenum_0
@@ -0,0 +1,93 @@
+#!/bin/bash -x
+
+set -e
+
+load_ruleset() {
+	$XT_MULTI iptables-restore <<EOF
+*filter
+-A FORWARD -m mark --mark 0x1 -c 1 2
+-A FORWARD -m mark --mark 0x2 -c 2 3
+COMMIT
+EOF
+}
+
+load_ruleset
+
+$XT_MULTI iptables -L 0 && exit 1
+
+EXPECT=' 1 2 all -- any any anywhere anywhere mark match 0x1'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI iptables -v -L FORWARD 1)
+
+EXPECT=' 2 3 all -- any any anywhere anywhere mark match 0x2'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI iptables -v -L FORWARD 2)
+
+[[ -z $($XT_MULTI iptables -L FORWARD 3) ]]
+
+$XT_MULTI iptables -S FORWARD 0 && exit 1
+
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 1 2'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S FORWARD 1)
+
+EXPECT='-A FORWARD -m mark --mark 0x2 -c 2 3'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S FORWARD 2)
+
+[[ -z $($XT_MULTI iptables -S FORWARD 3) ]]
+
+$XT_MULTI iptables -v -Z FORWARD 0 && exit 1
+
+[[ -z $($XT_MULTI iptables -v -Z FORWARD 1) ]]
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 0 0
+-A FORWARD -m mark --mark 0x2 -c 2 3'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+[[ -z $($XT_MULTI iptables -v -Z FORWARD 2) ]]
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 0 0
+-A FORWARD -m mark --mark 0x2 -c 0 0'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+$XT_MULTI iptables -v -Z FORWARD 3 && exit 1
+
+load_ruleset
+
+[[ -z $($XT_MULTI iptables -v -L -Z FORWARD 1) ]]
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 0 0
+-A FORWARD -m mark --mark 0x2 -c 2 3'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+[[ -z $($XT_MULTI iptables -v -L -Z FORWARD 2) ]]
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 0 0
+-A FORWARD -m mark --mark 0x2 -c 0 0'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+load_ruleset
+
+$XT_MULTI iptables -v -Z -L FORWARD 0 && exit 1
+
+EXPECT=' 1 2 all -- any any anywhere anywhere mark match 0x1
+Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI iptables -v -Z -L FORWARD 1)
+
+EXPECT=' 0 0 all -- any any anywhere anywhere mark match 0x2
+Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI iptables -v -Z -L FORWARD 2)
+
+$XT_MULTI iptables -v -Z -L FORWARD 0 && exit 1
+
+EXPECT='Zeroing chain `FORWARD'\'
+diff -u -b <(echo -e "$EXPECT") <($XT_MULTI iptables -v -Z -L FORWARD 3)
+
+load_ruleset
+
+[[ -z $($XT_MULTI iptables -v -D FORWARD 1) ]]
+EXPECT='-A FORWARD -m mark --mark 0x2 -c 2 3'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+load_ruleset
+
+[[ -z $($XT_MULTI iptables -v -D FORWARD 2) ]]
+EXPECT='-A FORWARD -m mark --mark 0x1 -c 1 2'
+diff -u <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S | grep -v '^-P')
+
+$XT_MULTI iptables -v -D FORWARD 3 && exit 1
+
+exit 0
-- 
2.43.0





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux