Debian Codegraph @

tests/shell/testcases/cache/0003_cache_update_0

raw
1 #!/bin/bash
2
3 set -e
4
5 # Expose how naive cache update logic (i.e., drop cache and repopulate from
6 # kernel ruleset) may mess things up. The following input does:
7 #
8 # list ruleset -> populate the cache, cache->genid is non-zero
9 # add table ip t -> make kernel's genid increment (cache->genid remains
10 # unchanged)
11 # add table ip t2; -> first command of batch, new table t2 is added to the cache
12 # add chain ip t2 c -> second command of batch, triggers cache_update() which
13 # removes table t2 from it
14
15 $NFT -i >/dev/null <<EOF
16 list ruleset
17 add table ip t
18 add table ip t2; add chain ip t2 c
19 EOF
20
21 # The following test exposes a problem with simple locking of cache when local
22 # entries are added:
23 #
24 # add table ip t3 -> cache would be locked without previous update
25 # add chain ip t c -> table t is not found due to no cache update happening
26
27 $NFT -i >/dev/null <<EOF
28 add table ip t3; add chain ip t c
29 EOF
30
31 # The following test exposes a problem with incremental cache update when
32 # reading commands from a file that add a rule using the "index" keyword.
33 #
34 # add rule ip t4 c meta l4proto icmp accept -> rule to reference in next step
35 # add rule ip t4 c index 0 drop -> index 0 is not found due to rule cache not
36 # being updated
37 # add rule ip t4 c index 2 drop -> index 2 is not found due to igmp rule being
38 # in same transaction and therefore not having
39 # an allocated handle
40 $NFT -i >/dev/null <<EOF
41 add table ip t4; add chain ip t4 c
42 add rule ip t4 c meta l4proto icmp accept
43 EOF
44 $NFT -f - >/dev/null <<EOF
45 add rule ip t4 c index 0 drop
46 EOF
47 $NFT -f - >/dev/null <<EOF
48 add rule ip t4 c meta l4proto igmp accept
49 add rule ip t4 c index 2 drop
50 EOF