blob: 91186deca13d03125f2456e3fdcad01a174d01dc (
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
|
#!/bin/bash
set -e
RULESET="add table x
add table y
flush ruleset"
$NFT -f - <<< "$RULESET"
if [ $? -ne 0 ] ; then
echo "E: unable to load good ruleset" >&2
exit 1
fi
KERNEL_RULESET="$($NFT list ruleset)"
if [ "" != "$KERNEL_RULESET" ] ; then
echo "Got a ruleset, but expected empty: "
echo "$KERNEL_RULESET"
exit 1
fi
RULESET="table ip x {
}
table ip y {
}"
$NFT -f - <<< "$RULESET"
if [ $? -ne 0 ] ; then
echo "E: unable to load good ruleset" >&2
exit 1
fi
RULESETFAIL="flush ruleset
create table ip nat
create table inet filter
create chain ip nat testchain
delete table ip testtable"
# testtable doesn't exist, batch expected to fail
$NFT -f - <<< "$RULESETFAIL" && exit 2
KERNEL_RULESET="$($NFT list ruleset)"
if [ "$RULESET" != "$KERNEL_RULESET" ] ; then
$DIFF -u <(echo "$RULESET") <(echo "$KERNEL_RULESET")
exit 1
fi
|