blob: 355de5f11a4fd4fa4721ae173d8565b7ce8e744f (
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
|
#!/bin/bash
set -e
$NFT add table test-ip
$NFT add counter test-ip https-traffic # should have handle 1
$NFT add quota test-ip https-quota 25 mbytes # should have handle 2
$NFT add map test-ip ports { type inet_service : quota \; } # should have handle 3
$NFT add table ip6 test-ip6
$NFT add quota ip6 test-ip6 http-quota over 25 mbytes # should have handle 1
$NFT add counter ip6 test-ip6 http-traffic # should have handle 2
$NFT add quota ip6 test-ip6 ssh-quota 10 mbytes # should have handle 3
$NFT delete counter test-ip handle 1
$NFT delete quota ip6 test-ip6 handle 3
EXPECTED="table ip test-ip {
quota https-quota {
25 mbytes used 2 bytes
} # handle 2
map ports {
type inet_service : quota
} # handle 3
} # handle 1
table ip6 test-ip6 {
quota http-quota {
over 25 mbytes used 1 bytes
} # handle 1
counter http-traffic {
packets 0 bytes 2
} # handle 2
} # handle 2"
GET="$($NFT list ruleset -a)"
if [ "$EXPECTED" != "$GET" ] ; then
DIFF="$(which diff)"
[ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
exit 1
fi
|