Debian Codegraph @

tests/shell/testcases/flowtable/0016name_based_hook_0

raw
1 #!/bin/bash
2
3 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_ifname_based_hooks)
4 # NFT_TEST_REQUIRES(NFT_TEST_HAVE_list_hooks_flowtable_info)
5
6 ftspec=' flowtable ip t ft'
7 $NFT add table t
8 $NFT add $ftspec '{ hook ingress priority 0; devices = { lo, foo* }; }'
9 $NFT list hooks netdev device lo | grep -q "$ftspec" || {
10 echo "Existing device lo not hooked into flowtable as expected"
11 exit 1
12 }
13
14 [[ $($NFT list hooks | grep -c "$ftspec") -eq 1 ]] || {
15 echo "Flowtable hooks into more than just lo"
16 exit 2
17 }
18
19 ip link add foo1 type dummy
20 $NFT list hooks netdev device foo1 | grep -q "$ftspec" || {
21 echo "Flowtable did not hook into new device foo1"
22 exit 3
23 }
24 [[ $($NFT list hooks | grep -c "$ftspec") -eq 2 ]] || {
25 echo "Flowtable expected to hook into exactly two devices"
26 exit 4
27 }
28
29 ip link del foo1
30 $NFT list hooks netdev device foo1 | grep -q "$ftspec" && {
31 echo "Flowtable still hooks into removed device foo1"
32 exit 5
33 }
34 [[ $($NFT list hooks | grep -c "$ftspec") -eq 1 ]] || {
35 echo "Flowtable expected to hook into just lo"
36 exit 6
37 }
38
39 for ((i = 0; i < 100; i++)); do
40 ip link add foo$i type dummy
41 done
42 [[ $($NFT list hooks | grep -c "$ftspec") -eq 101 ]] || {
43 echo "Flowtable did not hook into all 100 new devices"
44 exit 7
45 }