File: table_onoff

package info (click to toggle)
nftables 1.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,384 kB
  • sloc: ansic: 50,901; sh: 20,277; yacc: 5,861; python: 1,746; lex: 1,367; makefile: 392
file content (44 lines) | stat: -rwxr-xr-x 949 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

# attempt to re-awaken a table that is flagged dormant within
# same transaction
$NFT -f - <<EOF
add table ip t
add table ip t { flags dormant; }
add chain ip t c { type filter hook input priority 0; }
add table ip t
delete table ip t
EOF

if [ $? -eq 0 ]; then
	exit 1
fi

set -e

ip link set lo up

# add a dormant table, then wake it up in same
# transaction.
$NFT -f - <<EOF
add table ip t { flags dormant; }
add chain ip t c { type filter hook input priority 0; }
add rule ip t c ip daddr 127.0.0.42 counter
add table ip t
EOF

# check table is indeed active.
ping -c 1 127.0.0.42
$NFT list chain ip t c | grep "counter packets 1"
$NFT delete table ip t

# allow to flag table dormant.
$NFT -f - <<EOF
add table ip t
add chain ip t c { type filter hook input priority 0; }
add rule ip t c ip daddr 127.0.0.42 counter
add table ip t { flags dormant; }
EOF

ping -c 1 127.0.0.42
# expect run-tests.sh to complain if counter isn't 0.