1[
2    {
3        "id": "afa9",
4        "name": "Add u32 with source match",
5        "category": [
6            "filter",
7            "u32"
8        ],
9        "plugins": {
10            "requires": "nsPlugin"
11        },
12        "setup": [
13            "$TC qdisc add dev $DEV1 ingress"
14        ],
15        "cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.1/32 flowid 1:1 action ok",
16        "expExitCode": "0",
17        "verifyCmd": "$TC filter show dev $DEV1 ingress",
18        "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1.*match 7f000001/ffffffff at 12)",
19        "matchCount": "3",
20        "teardown": [
21            "$TC qdisc del dev $DEV1 ingress"
22        ]
23    },
24    {
25        "id": "6aa7",
26        "name": "Add/Replace u32 with source match and invalid indev",
27        "category": [
28            "filter",
29            "u32"
30        ],
31        "plugins": {
32            "requires": "nsPlugin"
33        },
34        "setup": [
35            "$TC qdisc add dev $DEV1 ingress"
36        ],
37        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.1/32 indev notexist20 flowid 1:1 action ok",
38        "expExitCode": "2",
39        "verifyCmd": "$TC filter show dev $DEV1 ingress",
40        "matchPattern": "filter protocol ip pref 1 u32 chain 0",
41        "matchCount": "0",
42        "teardown": [
43            "$TC qdisc del dev $DEV1 ingress"
44        ]
45    },
46    {
47        "id": "bc4d",
48        "name": "Replace valid u32 with source match and invalid indev",
49        "category": [
50            "filter",
51            "u32"
52        ],
53        "plugins": {
54            "requires": "nsPlugin"
55        },
56        "setup": [
57            "$TC qdisc add dev $DEV1 ingress",
58            "$TC filter add dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.3/32 flowid 1:3 action ok"
59        ],
60        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 1 u32 match ip src 127.0.0.2/32 indev notexist20 flowid 1:2 action ok",
61        "expExitCode": "2",
62        "verifyCmd": "$TC filter show dev $DEV1 ingress",
63        "matchPattern": "filter protocol ip pref 1 u32 chain (0[ ]+$|0 fh 800: ht divisor 1|0 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:3.*match 7f000003/ffffffff at 12)",
64        "matchCount": "3",
65        "teardown": [
66            "$TC qdisc del dev $DEV1 ingress"
67        ]
68    },
69    {
70        "id": "648b",
71        "name": "Add u32 with custom hash table",
72        "category": [
73            "filter",
74            "u32"
75        ],
76        "plugins": {
77            "requires": "nsPlugin"
78        },
79        "setup": [
80            "$TC qdisc add dev $DEV1 ingress"
81        ],
82        "cmdUnderTest": "$TC filter add dev $DEV1 ingress prio 99 handle 42: u32 divisor 256",
83        "expExitCode": "0",
84        "verifyCmd": "$TC filter show dev $DEV1 ingress",
85        "matchPattern": "pref 99 u32 chain (0[ ]+$|0 fh 42: ht divisor 256|0 fh 800: ht divisor 1)",
86        "matchCount": "3",
87        "teardown": [
88            "$TC qdisc del dev $DEV1 ingress"
89        ]
90    },
91    {
92        "id": "6658",
93        "name": "Add/Replace u32 with custom hash table and invalid handle",
94        "category": [
95            "filter",
96            "u32"
97        ],
98        "plugins": {
99            "requires": "nsPlugin"
100        },
101        "setup": [
102            "$TC qdisc add dev $DEV1 ingress"
103        ],
104        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress prio 99 handle 42:42 u32 divisor 256",
105        "expExitCode": "2",
106        "verifyCmd": "$TC filter show dev $DEV1 ingress",
107        "matchPattern": "pref 99 u32 chain 0",
108        "matchCount": "0",
109        "teardown": [
110            "$TC qdisc del dev $DEV1 ingress"
111        ]
112    },
113    {
114        "id": "9d0a",
115        "name": "Replace valid u32 with custom hash table and invalid handle",
116        "category": [
117            "filter",
118            "u32"
119        ],
120        "plugins": {
121            "requires": "nsPlugin"
122        },
123        "setup": [
124            "$TC qdisc add dev $DEV1 ingress",
125            "$TC filter add dev $DEV1 ingress prio 99 handle 42: u32 divisor 256"
126        ],
127        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress prio 99 handle 42:42 u32 divisor 128",
128        "expExitCode": "2",
129        "verifyCmd": "$TC filter show dev $DEV1 ingress",
130        "matchPattern": "pref 99 u32 chain (0[ ]+$|0 fh 42: ht divisor 256|0 fh 800: ht divisor 1)",
131        "matchCount": "3",
132        "teardown": [
133            "$TC qdisc del dev $DEV1 ingress"
134        ]
135    },
136    {
137        "id": "1644",
138        "name": "Add u32 filter that links to a custom hash table",
139        "category": [
140            "filter",
141            "u32"
142        ],
143        "plugins": {
144            "requires": "nsPlugin"
145        },
146        "setup": [
147            "$TC qdisc add dev $DEV1 ingress",
148            "$TC filter add dev $DEV1 ingress prio 99 handle 43: u32 divisor 256"
149        ],
150        "cmdUnderTest": "$TC filter add dev $DEV1 ingress protocol ip prio 98 u32 link 43: hashkey mask 0x0000ff00 at 12 match ip src 192.168.0.0/16",
151        "expExitCode": "0",
152        "verifyCmd": "$TC filter show dev $DEV1 ingress",
153        "matchPattern": "filter protocol ip pref 98 u32 chain (0[ ]+$|0 fh 801: ht divisor 1|0 fh 801::800 order 2048 key ht 801 bkt 0 link 43:.*match c0a80000/ffff0000 at 12.*hash mask 0000ff00 at 12)",
154        "matchCount": "3",
155        "teardown": [
156            "$TC qdisc del dev $DEV1 ingress"
157        ]
158    },
159    {
160        "id": "74c2",
161        "name": "Add/Replace u32 filter with invalid hash table id",
162        "category": [
163            "filter",
164            "u32"
165        ],
166        "plugins": {
167            "requires": "nsPlugin"
168        },
169        "setup": [
170            "$TC qdisc add dev $DEV1 ingress"
171        ],
172        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 20 u32 ht 47:47 action drop",
173        "expExitCode": "2",
174        "verifyCmd": "$TC filter show dev $DEV1 ingress",
175        "matchPattern": "filter protocol ip pref 20 u32 chain 0",
176        "matchCount": "0",
177        "teardown": [
178            "$TC qdisc del dev $DEV1 ingress"
179        ]
180    },
181    {
182        "id": "1fe6",
183        "name": "Replace valid u32 filter with invalid hash table id",
184        "category": [
185            "filter",
186            "u32"
187        ],
188        "plugins": {
189            "requires": "nsPlugin"
190        },
191        "setup": [
192            "$TC qdisc add dev $DEV1 ingress",
193            "$TC filter add dev $DEV1 ingress protocol ip prio 99 handle 43: u32 divisor 1",
194            "$TC filter add dev $DEV1 ingress protocol ip prio 98 u32 ht 43: match tcp src 22 FFFF classid 1:3"
195        ],
196        "cmdUnderTest": "$TC filter replace dev $DEV1 ingress protocol ip prio 98 u32 ht 43:1 match tcp src 23 FFFF classid 1:4",
197        "expExitCode": "2",
198        "verifyCmd": "$TC filter show dev $DEV1 ingress",
199        "matchPattern": "filter protocol ip pref 99 u32 chain (0[ ]+$|0 fh (43|800): ht divisor 1|0 fh 43::800 order 2048 key ht 43 bkt 0 flowid 1:3.*match 00160000/ffff0000 at nexthdr\\+0)",
200        "matchCount": "4",
201        "teardown": [
202            "$TC qdisc del dev $DEV1 ingress"
203        ]
204    },
205    {
206        "id": "0692",
207        "name": "Test u32 sample option, divisor 256",
208        "category": [
209            "filter",
210            "u32"
211        ],
212        "plugins": {
213            "requires": "nsPlugin"
214        },
215        "setup": [
216            "$TC qdisc add dev $DEV1 ingress",
217            "$TC filter add dev $DEV1 ingress prio 99 handle 1: u32 divisor 256"
218        ],
219        "cmdUnderTest": "bash -c \"for mask in ff ffff ffffff ffffffff ff00ff ff0000ff ffff00ff; do $TC filter add dev $DEV1 ingress prio 99 u32 ht 1: sample u32 0x10203040 \\$mask match u8 0 0 classid 1:1; done\"",
220        "expExitCode": "0",
221        "verifyCmd": "$TC filter show dev $DEV1 ingress",
222        "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 40 flowid 1:1",
223        "matchCount": "7",
224        "teardown": [
225            "$TC qdisc del dev $DEV1 ingress"
226        ]
227    },
228    {
229        "id": "2478",
230        "name": "Test u32 sample option, divisor 16",
231        "category": [
232            "filter",
233            "u32"
234        ],
235        "plugins": {
236            "requires": "nsPlugin"
237        },
238        "setup": [
239            "$TC qdisc add dev $DEV1 ingress",
240            "$TC filter add dev $DEV1 ingress prio 99 handle 1: u32 divisor 256"
241        ],
242        "cmdUnderTest": "bash -c \"for mask in 70 f0 ff0 fff0 ff00f0; do $TC filter add dev $DEV1 ingress prio 99 u32 ht 1: sample u32 0x10203040 \\$mask match u8 0 0 classid 1:1; done\"",
243        "expExitCode": "0",
244        "verifyCmd": "$TC filter show dev $DEV1 ingress",
245        "matchPattern": "filter protocol all pref 99 u32( (chain|fh|order) [0-9:]+){3} key ht 1 bkt 4 flowid 1:1",
246        "matchCount": "5",
247        "teardown": [
248            "$TC qdisc del dev $DEV1 ingress"
249        ]
250    },
251    {
252        "id": "0c37",
253        "name": "Try to delete class referenced by u32 after a replace",
254        "category": [
255            "filter",
256            "u32"
257        ],
258        "plugins": {
259            "requires": "nsPlugin"
260        },
261        "setup": [
262            "$TC qdisc add dev $DEV1 parent root handle 10: drr",
263            "$TC class add dev $DEV1 parent root classid 1 drr",
264            "$TC filter add dev $DEV1 parent 10: prio 1 u32 match icmp type 1 0xff classid 10:1 action ok",
265            "$TC filter replace dev $DEV1 parent 10: prio 1 u32 match icmp type 1 0xff classid 10:1 action drop"
266        ],
267        "cmdUnderTest": "$TC class delete dev $DEV1 parent 10: classid 10:1",
268        "expExitCode": "2",
269        "verifyCmd": "$TC class show dev $DEV1",
270        "matchPattern": "class drr 10:1",
271        "matchCount": "1",
272        "teardown": [
273            "$TC qdisc del dev $DEV1 parent root drr"
274        ]
275    },
276    {
277        "id": "bd32",
278        "name": "Try to delete hashtable referenced by another u32 filter",
279        "category": [
280            "filter",
281            "u32"
282        ],
283        "plugins": {
284            "requires": "nsPlugin"
285        },
286        "setup": [
287            "$TC qdisc add dev $DEV1 parent root handle 10: drr",
288            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 handle 1: u32 divisor 1",
289            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 800: match ip src any link 1:"
290        ],
291        "cmdUnderTest": "$TC filter delete dev $DEV1 parent 10: prio 2 handle 1: u32",
292        "expExitCode": "2",
293        "verifyCmd": "$TC filter show dev $DEV1",
294        "matchPattern": "protocol ip pref 2 u32 chain 0 fh 1:",
295        "matchCount": "1",
296        "teardown": [
297            "$TC qdisc del dev $DEV1 parent root drr"
298        ]
299    },
300    {
301        "id": "4585",
302        "name": "Delete small tree of u32 hashtables and filters",
303        "category": [
304            "filter",
305            "u32"
306        ],
307        "plugins": {
308            "requires": "nsPlugin"
309        },
310        "setup": [
311            "$TC qdisc add dev $DEV1 parent root handle 10: drr",
312            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 handle 1: u32 divisor 1",
313            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 handle 2: u32 divisor 1",
314            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 handle 3: u32 divisor 2",
315            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 handle 4: u32 divisor 1",
316            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 1: match ip src any action drop",
317            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 2: match ip src any action drop",
318            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 3: match ip src any link 2:",
319            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 3: match ip src any link 1:",
320            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 4: match ip src any action drop",
321            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 800: match ip src any link 3:",
322            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 ht 800: match ip src any link 4:"
323        ],
324        "cmdUnderTest": "$TC filter delete dev $DEV1 parent 10:",
325        "expExitCode": "0",
326        "verifyCmd": "$TC filter show dev $DEV1",
327        "matchPattern": "protocol ip pref 2 u32",
328        "matchCount": "0",
329        "teardown": [
330            "$TC qdisc del dev $DEV1 parent root drr"
331        ]
332    },
333    {
334        "id": "1234",
335        "name": "Exercise IDR leaks by creating/deleting a filter many (2048) times",
336        "category": [
337            "filter",
338            "u32"
339        ],
340        "plugins": {
341            "requires": "nsPlugin"
342        },
343        "setup": [
344            "$TC qdisc add dev $DEV1 parent root handle 10: drr",
345            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 2 u32 match ip src 0.0.0.2/32 action drop",
346            "$TC filter add dev $DEV1 parent 10:0 protocol ip prio 3 u32 match ip src 0.0.0.3/32 action drop"
347        ],
348        "cmdUnderTest": "bash -c 'for i in {1..2048} ;do echo filter delete dev $DEV1 pref 3;echo filter add dev $DEV1 parent 10:0 protocol ip prio 3 u32 match ip src 0.0.0.3/32 action drop;done | $TC -b -'",
349        "expExitCode": "0",
350        "verifyCmd": "$TC filter show dev $DEV1",
351        "matchPattern": "protocol ip pref 3 u32",
352        "matchCount": "3",
353        "teardown": [
354            "$TC qdisc del dev $DEV1 parent root drr"
355        ]
356    }
357]
358