summaryrefslogtreecommitdiffstats
path: root/iptables/tests/shell/testcases/ip6tables/0004-return-codes_0
blob: f023b7915498e3abf9e24fd3bddf7c52a4ac9f57 (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
#!/bin/sh

# make sure error return codes are as expected useful cases
# (e.g. commands to check ruleset state)

global_rc=0

cmd() { # (rc, cmd, [args ...])
	rc_exp=$1; shift

	$XT_MULTI "$@"
	rc=$?

	[ $rc -eq $rc_exp ] || {
		echo "---> expected $rc_exp, got $rc for command '$@'"
		global_rc=1
	}
}

# test chain creation
cmd 0 ip6tables -N foo
cmd 1 ip6tables -N foo
# iptables-nft allows this - bug or feature?
#cmd 2 ip6tables -N "invalid name"

# test rule adding
cmd 0 ip6tables -A INPUT -j ACCEPT
cmd 1 ip6tables -A noexist -j ACCEPT

# test rule checking
cmd 0 ip6tables -C INPUT -j ACCEPT
cmd 1 ip6tables -C FORWARD -j ACCEPT
cmd 1 ip6tables -C nonexist -j ACCEPT
cmd 2 ip6tables -C INPUT -j foobar
cmd 2 ip6tables -C INPUT -m foobar -j ACCEPT
cmd 3 ip6tables -t foobar -C INPUT -j ACCEPT

exit $global_rc