blob: 2dbcd22bb2ce1e7c1ee109cb150a892880ca5ed7 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/bin/bash
# support for ifname in named sets
EXPECTED="table inet t {
set s {
type ifname
elements = { \"eth0\" }
}
set sc {
type inet_service . ifname
elements = { \"ssh\" . \"eth0\" }
}
set nv {
type ifname . mark
}
set z {
typeof ct zone
elements = { 1 }
}
set m {
typeof meta mark
elements = { 1 }
}
map cz {
typeof meta iifname : ct zone
elements = { \"veth4\" : 1 }
}
map cm {
typeof meta iifname : ct mark
elements = { \"veth4\" : 1 }
}
chain c {
iifname @s accept
oifname @s accept
tcp dport . meta iifname @sc accept
meta iifname . meta mark @nv accept
}
}"
set -e
$NFT -f - <<< "$EXPECTED"
$NFT add element inet t s '{ "eth1" }'
$NFT add element inet t s '{ "eth2", "eth3", "veth1" }'
$NFT add element inet t sc '{ 80 . "eth0" }'
$NFT add element inet t sc '{ 80 . "eth0" }' || true
$NFT add element inet t sc '{ 80 . "eth1" }'
$NFT add element inet t sc '{ 81 . "eth0" }'
$NFT add element inet t nv '{ "eth0" . 1 }'
$NFT add element inet t nv '{ "eth0" . 2 }'
$NFT add element inet t z '{ 2, 3, 4, 5, 6 }'
$NFT add element inet t cz '{ "eth0" : 1, "eth1" : 2 }'
$NFT add element inet t m '{ 2, 3, 4, 5, 6 }'
$NFT add element inet t cm '{ "eth0" : 1, "eth1" : 2 }'
|