File: set_stmt

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 (50 lines) | stat: -rwxr-xr-x 851 bytes parent folder | download
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
#!/bin/bash

# NFT_TEST_REQUIRES(NFT_TEST_HAVE_set_expr)

test_set_stmt() {
	local i=$1
	local stmt1=$2
	local stmt2=$3

	RULESET="table x {
	set y$i {
		type ipv4_addr
		$stmt1
		elements = { 5.5.5.$i $stmt1,
			     6.6.6.$i $stmt2 }
	}
	chain y$i {
		ip daddr @y$i
	}
}"

	$NFT -f - <<< $RULESET
	# should work
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	# should work
	$NFT add element x y$i { 2.2.2.$i $stmt2 }
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	# should work
	$NFT add element x y$i { 3.3.3.$i }
	if [ $? -ne 0 ]
	then
		exit 1
	fi
}

test_set_stmt "0" "counter packets 1 bytes 2" "counter packets 3 bytes 4"
test_set_stmt "1" "limit rate 1/second" "limit rate 5/second"
test_set_stmt "2" "ct count over 2" "ct count over 5"
test_set_stmt "3" "last" "last"
test_set_stmt "4" "quota over 1000 bytes" "quota over 30000 bytes used 1000 bytes"

exit 0