File: 0024named_objects_0

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

# This is the testscase:
# * creating valid named objects
# * referencing them from a valid rule

RULESET="
table inet x {
	counter user123 {
		packets 12 bytes 1433
	}
	counter user321 {
		packets 12 bytes 1433
	}
	quota user123 {
		over 2000 bytes
	}
	quota user124 {
		over 2000 bytes
	}
	set y {
		type ipv4_addr
	}
	map test {
		type ipv4_addr : quota
		elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124"}
	}
	chain y {
		type filter hook input priority 0; policy accept;
		counter name ip saddr map { 192.168.2.2 : "user123", 1.1.1.1 : "user123", 2.2.2.2 : "user123"}
		quota name ip saddr map @test drop
	}
}"

set -e
$NFT -f - <<< "$RULESET"

EXPECTED="table inet x {
	counter user321 {
		packets 12 bytes 1433
	}
}"

GET="$($NFT reset counter inet x user321)"
if [ "$EXPECTED" != "$GET" ] ; then
	$DIFF -u <(echo "$EXPECTED") <(echo "$GET")
	exit 1
fi