1[
2    {
3        "id": "d959",
4        "name": "Add cBPF action with valid bytecode",
5        "category": [
6            "actions",
7            "bpf"
8        ],
9        "setup": [
10            [
11                "$TC action flush action bpf",
12                0,
13                1,
14                255
15            ]
16        ],
17        "cmdUnderTest": "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 100",
18        "expExitCode": "0",
19        "verifyCmd": "$TC action get action bpf index 100",
20        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' default-action pipe.*index 100 ref",
21        "matchCount": "1",
22        "teardown": [
23            "$TC action flush action bpf"
24        ]
25    },
26    {
27        "id": "f84a",
28        "name": "Add cBPF action with invalid bytecode",
29        "category": [
30            "actions",
31            "bpf"
32        ],
33        "setup": [
34            [
35                "$TC actions flush action bpf",
36                0,
37                1,
38                255
39            ]
40        ],
41        "cmdUnderTest": "$TC action add action bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0' index 100",
42        "expExitCode": "255",
43        "verifyCmd": "$TC action get action bpf index 100",
44        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0' default-action pipe.*index 100 ref",
45        "matchCount": "0",
46        "teardown": [
47            "$TC actions flush action bpf"
48        ]
49    },
50    {
51        "id": "e939",
52        "name": "Add eBPF action with valid object-file",
53        "category": [
54            "actions",
55            "bpf"
56        ],
57        "setup": [
58            "printf '#include <linux/bpf.h>\nchar l[] __attribute__((section(\"license\"),used))=\"GPL\"; __attribute__((section(\"action\"),used)) int m(struct __sk_buff *s) { return 2; }' | clang -O2 -x c -c - -target bpf -o _b.o",
59            [
60                "$TC action flush action bpf",
61                0,
62                1,
63                255
64            ]
65        ],
66        "cmdUnderTest": "$TC action add action bpf object-file _b.o index 667",
67        "expExitCode": "0",
68        "verifyCmd": "$TC action get action bpf index 667",
69        "matchPattern": "action order [0-9]*: bpf _b.o:\\[action\\] id [0-9]* tag 3b185187f1855c4c( jited)? default-action pipe.*index 667 ref",
70        "matchCount": "1",
71        "teardown": [
72            "$TC action flush action bpf",
73            "rm -f _b.o"
74        ]
75    },
76    {
77        "id": "282d",
78        "name": "Add eBPF action with invalid object-file",
79        "category": [
80            "actions",
81            "bpf"
82        ],
83        "setup": [
84            "printf '#include <linux/bpf.h>\nchar l[] __attribute__((section(\"license\"),used))=\"GPL\"; __attribute__((section(\"action\"),used)) int m(struct __sk_buff *s) { s->data = 0x0; return 2; }' | clang -O2 -x c -c - -target bpf -o _c.o",
85            [
86                "$TC action flush action bpf",
87                0,
88                1,
89                255
90            ]
91        ],
92        "cmdUnderTest": "$TC action add action bpf object-file _c.o index 667",
93        "expExitCode": "255",
94        "verifyCmd": "$TC action get action bpf index 667",
95        "matchPattern": "action order [0-9]*: bpf _c.o:\\[action\\] id [0-9].*index 667 ref",
96        "matchCount": "0",
97        "teardown": [
98            [
99                "$TC action flush action bpf",
100                0,
101                1,
102                255
103            ],
104            "rm -f _c.o"
105        ]
106    },
107    {
108        "id": "d819",
109        "name": "Replace cBPF bytecode and action control",
110        "category": [
111            "actions",
112            "bpf"
113        ],
114        "setup": [
115            [
116                "$TC actions flush action bpf",
117                0,
118                1,
119                255
120            ],
121            [
122                "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 555",
123                0,
124                1,
125                255
126            ]
127        ],
128        "cmdUnderTest": "$TC action replace action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' drop index 555",
129        "expExitCode": "0",
130        "verifyCmd": "$TC action get action bpf index 555",
131        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' default-action drop.*index 555 ref",
132        "matchCount": "1",
133        "teardown": [
134            "$TC action flush action bpf"
135        ]
136    },
137    {
138        "id": "6ae3",
139        "name": "Delete cBPF action ",
140        "category": [
141            "actions",
142            "bpf"
143        ],
144        "setup": [
145            [
146                "$TC actions flush action bpf",
147                0,
148                1,
149                255
150            ],
151            [
152                "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 444",
153                0,
154                1,
155                255
156            ]
157        ],
158        "cmdUnderTest": "$TC action delete action bpf index 444",
159        "expExitCode": "0",
160        "verifyCmd": "$TC action get action bpf index 444",
161        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' default-action pipe.*index 444 ref",
162        "matchCount": "0",
163        "teardown": [
164            "$TC action flush action bpf"
165        ]
166    },
167    {
168        "id": "3e0d",
169        "name": "List cBPF actions",
170        "category": [
171            "actions",
172            "bpf"
173        ],
174        "setup": [
175            [
176                "$TC action flush action bpf",
177                0,
178                1,
179                255
180            ],
181            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' ok index 101",
182            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' drop index 102",
183            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 33024,6 0 0 262144,6 0 0 0' continue index 103"
184        ],
185        "cmdUnderTest": "$TC action list action bpf",
186        "expExitCode": "0",
187        "verifyCmd": "$TC action list action bpf",
188        "matchPattern": "action order [0-9]*: bpf bytecode",
189        "matchCount": "3",
190        "teardown": [
191            "$TC actions flush action bpf"
192        ]
193    },
194    {
195        "id": "55ce",
196        "name": "Flush BPF actions",
197        "category": [
198            "actions",
199            "bpf"
200        ],
201        "setup": [
202            [
203                "$TC actions flush action bpf",
204                0,
205                1,
206                255
207            ],
208            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' ok index 101",
209            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' drop index 102",
210            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 33024,6 0 0 262144,6 0 0 0' continue index 103"
211        ],
212        "cmdUnderTest": "$TC action flush action bpf",
213        "expExitCode": "0",
214        "verifyCmd": "$TC action list action bpf",
215        "matchPattern": "action order [0-9]*: bpf bytecode",
216        "matchCount": "0",
217        "teardown": [
218            "$TC actions flush action bpf"
219        ]
220    },
221    {
222        "id": "ccc3",
223        "name": "Add cBPF action with duplicate index",
224        "category": [
225            "actions",
226            "bpf"
227        ],
228        "setup": [
229            [
230                "$TC actions flush action bpf",
231                0,
232                1,
233                255
234            ],
235            "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 4294967295"
236        ],
237        "cmdUnderTest": "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' index 4294967295",
238        "expExitCode": "255",
239        "verifyCmd": "$TC action get action bpf index 4294967295",
240        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' default-action pipe.*index 4294967295",
241        "matchCount": "1",
242        "teardown": [
243            "$TC action flush action bpf"
244        ]
245    },
246    {
247        "id": "89c7",
248        "name": "Add cBPF action with invalid index",
249        "category": [
250            "actions",
251            "bpf"
252        ],
253        "setup": [
254            [
255                "$TC actions flush action bpf",
256                0,
257                1,
258                255
259            ]
260        ],
261        "cmdUnderTest": "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' index 4294967296 cookie 12345",
262        "expExitCode": "255",
263        "verifyCmd": "$TC action ls action bpf",
264        "matchPattern": "action order [0-9]*: bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' default-action pipe.*cookie 12345",
265        "matchCount": "0",
266        "teardown": [
267            "$TC action flush action bpf"
268        ]
269    },
270    {
271        "id": "7ab9",
272        "name": "Add cBPF action with cookie",
273        "category": [
274            "actions",
275            "bpf"
276        ],
277        "setup": [
278            [
279                "$TC actions flush action bpf",
280                0,
281                1,
282                255
283            ]
284        ],
285        "cmdUnderTest": "$TC action add action bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0' cookie d0d0d0d0d0d0d0d0",
286        "expExitCode": "0",
287        "verifyCmd": "$TC action list action bpf",
288        "matchPattern": "action order [0-9]*: bpf.*cookie d0d0d0d0d0d0d0",
289        "matchCount": "1",
290        "teardown": [
291            "$TC action flush action bpf"
292        ]
293    }
294]
295