summaryrefslogtreecommitdiffstats
path: root/iptables/tests/shell/testcases/iptables/0003-list-rules_0
blob: d335d44257a499a33984b4da2c9abe4b8eb4c4ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

set -e

$XT_MULTI iptables -N foo
$XT_MULTI iptables -A FORWARD -i eth23 -o eth42 -j ACCEPT
$XT_MULTI iptables -A FORWARD -i eth42 -o eth23 -g foo
$XT_MULTI iptables -t nat -A OUTPUT -o eth123 -m mark --mark 0x42 -j ACCEPT

EXPECT='-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N foo
-A FORWARD -i eth23 -o eth42 -j ACCEPT
-A FORWARD -i eth42 -o eth23 -g foo'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -S)

EXPECT='-P INPUT ACCEPT -c 0 0
-P FORWARD ACCEPT -c 0 0
-P OUTPUT ACCEPT -c 0 0
-N foo
-A FORWARD -i eth23 -o eth42 -c 0 0 -j ACCEPT
-A FORWARD -i eth42 -o eth23 -c 0 0 -g foo'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S)

EXPECT='-P FORWARD ACCEPT
-A FORWARD -i eth23 -o eth42 -j ACCEPT
-A FORWARD -i eth42 -o eth23 -g foo'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -S FORWARD)

EXPECT='-P FORWARD ACCEPT -c 0 0
-A FORWARD -i eth23 -o eth42 -c 0 0 -j ACCEPT
-A FORWARD -i eth42 -o eth23 -c 0 0 -g foo'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -v -S FORWARD)

EXPECT='-P OUTPUT ACCEPT
-A OUTPUT -o eth123 -m mark --mark 0x42 -j ACCEPT'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -t nat -S OUTPUT)

EXPECT='-P OUTPUT ACCEPT -c 0 0
-A OUTPUT -o eth123 -m mark --mark 0x42 -c 0 0 -j ACCEPT'

diff -u -Z <(echo -e "$EXPECT") <($XT_MULTI iptables -v -t nat -S OUTPUT)

# some of the following commands are supposed to fail
set +e

$XT_MULTI iptables -S nonexistent && {
	echo "list-rules in non-existent chain should fail"
	exit 1
}
$XT_MULTI iptables -S nonexistent 23 && {
	echo "list-rules in non-existent chain with given rule number should fail"
	exit 1
}
$XT_MULTI iptables -S FORWARD 234 || {
	echo "list-rules in existent chain with invalid rule number should succeed"
	exit 1
}