laurenceman / rpms / iptables

Forked from rpms/iptables 5 years ago
Clone

Blame SOURCES/0040-tests-shell-Add-arptables-nft-verbose-output-test.patch

029dc7
From bf2b28732579e44bf4c77869be586ee7d73bdabb Mon Sep 17 00:00:00 2001
029dc7
From: Phil Sutter <phil@nwl.cc>
029dc7
Date: Thu, 31 Jan 2019 16:12:56 +0100
029dc7
Subject: [PATCH] tests: shell: Add arptables-nft verbose output test
029dc7
029dc7
With arptables-nft output being in a very good state now, add a test to
029dc7
ensure it stays that way.
029dc7
029dc7
Signed-off-by: Phil Sutter <phil@nwl.cc>
029dc7
Signed-off-by: Florian Westphal <fw@strlen.de>
029dc7
(cherry picked from commit 3d8f261c565a024c13d627b18a0fcafc76de8f2c)
029dc7
Signed-off-by: Phil Sutter <psutter@redhat.com>
029dc7
---
029dc7
 .../arptables/0003-arptables-verbose-output_0 | 64 +++++++++++++++++++
029dc7
 1 file changed, 64 insertions(+)
029dc7
 create mode 100755 iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
029dc7
029dc7
diff --git a/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0 b/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
029dc7
new file mode 100755
029dc7
index 0000000000000..35126fa7d717c
029dc7
--- /dev/null
029dc7
+++ b/iptables/tests/shell/testcases/arptables/0003-arptables-verbose-output_0
029dc7
@@ -0,0 +1,64 @@
029dc7
+#!/bin/bash
029dc7
+
029dc7
+set -e
029dc7
+set -x
029dc7
+
029dc7
+# there is no legacy backend to test
029dc7
+[[ $XT_MULTI == */xtables-nft-multi ]] || { echo "skip $XT_MULTI"; exit 0; }
029dc7
+
029dc7
+$XT_MULTI arptables -N foo
029dc7
+
029dc7
+# check verbose output matches expectations
029dc7
+
029dc7
+RULE1='-i eth23 -j ACCEPT'
029dc7
+VOUT1='-j ACCEPT -i eth23 -o *'
029dc7
+
029dc7
+RULE2='-i eth23'
029dc7
+VOUT2='-i eth23 -o *'
029dc7
+
029dc7
+RULE3='-i eth23 -j MARK --set-mark 42'
029dc7
+VOUT3='-j MARK -i eth23 -o * --set-mark 42'
029dc7
+
029dc7
+RULE4='-o eth23 -j CLASSIFY --set-class 23:42'
029dc7
+VOUT4='-j CLASSIFY -i * -o eth23 --set-class 23:42'
029dc7
+
029dc7
+RULE5='-o eth23 -j foo'
029dc7
+VOUT5='-j foo -i * -o eth23'
029dc7
+
029dc7
+RULE6='-o eth23 -j mangle --mangle-ip-s 10.0.0.1'
029dc7
+VOUT6='-j mangle -i * -o eth23 --mangle-ip-s 10.0.0.1'
029dc7
+
029dc7
+diff -u -Z <(echo -e "$VOUT1") <($XT_MULTI arptables -v -A INPUT $RULE1)
029dc7
+diff -u -Z <(echo -e "$VOUT2") <($XT_MULTI arptables -v -A INPUT $RULE2)
029dc7
+diff -u -Z <(echo -e "$VOUT3") <($XT_MULTI arptables -v -A INPUT $RULE3)
029dc7
+diff -u -Z <(echo -e "$VOUT4") <($XT_MULTI arptables -v -A OUTPUT $RULE4)
029dc7
+diff -u -Z <(echo -e "$VOUT5") <($XT_MULTI arptables -v -A OUTPUT $RULE5)
029dc7
+diff -u -Z <(echo -e "$VOUT6") <($XT_MULTI arptables -v -A foo $RULE6)
029dc7
+
029dc7
+EXPECT='Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
029dc7
+-j ACCEPT -i eth23 -o *, pcnt=0 -- bcnt=0
029dc7
+-i eth23 -o *, pcnt=0 -- bcnt=0
029dc7
+-j MARK -i eth23 -o * --set-mark 42, pcnt=0 -- bcnt=0
029dc7
+
029dc7
+Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
029dc7
+-j CLASSIFY -i * -o eth23 --set-class 23:42, pcnt=0 -- bcnt=0
029dc7
+-j foo -i * -o eth23, pcnt=0 -- bcnt=0
029dc7
+
029dc7
+Chain foo (1 references)
029dc7
+-j mangle -i * -o eth23 --mangle-ip-s 10.0.0.1, pcnt=0 -- bcnt=0'
029dc7
+
029dc7
+diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI arptables -v -n -L)
029dc7
+
029dc7
+EXPECT='*filter
029dc7
+:INPUT ACCEPT
029dc7
+:OUTPUT ACCEPT
029dc7
+:foo -
029dc7
+-A INPUT -j ACCEPT -i eth23
029dc7
+-A INPUT -i eth23
029dc7
+-A INPUT -j MARK -i eth23 --set-mark 42
029dc7
+-A OUTPUT -j CLASSIFY -o eth23 --set-class 23:42
029dc7
+-A OUTPUT -j foo -o eth23
029dc7
+-A foo -j mangle -o eth23 --mangle-ip-s 10.0.0.1
029dc7
+'
029dc7
+
029dc7
+diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI arptables-save)
029dc7
-- 
029dc7
2.21.0
029dc7