1[
2    {
3        "id": "23c3",
4        "name": "Add cBPF filter with valid bytecode",
5        "category": [
6            "filter",
7            "bpf-filter"
8        ],
9        "plugins": {
10            "requires": "nsPlugin"
11        },
12        "setup": [
13            "$TC qdisc add dev $DEV1 ingress"
14        ],
15        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
16        "expExitCode": "0",
17        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
18        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
19        "matchCount": "1",
20        "teardown": [
21            "$TC qdisc del dev $DEV1 ingress"
22        ]
23    },
24    {
25        "id": "1563",
26        "name": "Add cBPF filter with invalid bytecode",
27        "category": [
28            "filter",
29            "bpf-filter"
30        ],
31        "plugins": {
32            "requires": "nsPlugin"
33        },
34        "setup": [
35            "$TC qdisc add dev $DEV1 ingress"
36        ],
37        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0'",
38        "expExitCode": "2",
39        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
40        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
41        "matchCount": "0",
42        "teardown": [
43            "$TC qdisc del dev $DEV1 ingress"
44        ]
45    },
46    {
47        "id": "2334",
48        "name": "Add eBPF filter with valid object-file",
49        "category": [
50            "filter",
51            "bpf-filter"
52        ],
53        "plugins": {
54            "requires": [
55               "nsPlugin"
56            ]
57        },
58        "setup": [
59            "$TC qdisc add dev $DEV1 ingress"
60        ],
61        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action-ebpf section action-ok",
62        "expExitCode": "0",
63        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
64        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action-ebpf:\\[action-ok\\].*tag [0-9a-f]{16}( jited)?",
65        "matchCount": "1",
66        "teardown": [
67            "$TC qdisc del dev $DEV1 ingress"
68        ]
69    },
70    {
71        "id": "2373",
72        "name": "Add eBPF filter with invalid object-file",
73        "category": [
74            "filter",
75            "bpf-filter"
76        ],
77        "plugins": {
78            "requires": [
79               "nsPlugin"
80            ]
81        },
82        "setup": [
83            "$TC qdisc add dev $DEV1 ingress"
84        ],
85        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action-ebpf section action-ko",
86        "expExitCode": "1",
87        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
88        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action-ebpf:\\[action-ko\\].*tag [0-9a-f]{16}( jited)?",
89        "matchCount": "0",
90        "teardown": [
91            "$TC qdisc del dev $DEV1 ingress"
92        ]
93    },
94    {
95        "id": "4423",
96        "name": "Replace cBPF bytecode",
97        "category": [
98            "filter",
99            "bpf-filter"
100        ],
101        "plugins": {
102            "requires": "nsPlugin"
103        },
104        "setup": [
105            "$TC qdisc add dev $DEV1 ingress",
106            [
107                "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
108                0,
109                1,
110                255
111            ]
112        ],
113        "cmdUnderTest": "$TC filter replace dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'",
114        "expExitCode": "0",
115        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
116        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'",
117        "matchCount": "1",
118        "teardown": [
119            "$TC qdisc del dev $DEV1 ingress"
120        ]
121    },
122    {
123        "id": "5122",
124        "name": "Delete cBPF filter",
125        "category": [
126            "filter",
127            "bpf-filter"
128        ],
129        "plugins": {
130            "requires": "nsPlugin"
131        },
132        "setup": [
133            "$TC qdisc add dev $DEV1 ingress",
134            [
135                "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
136                0,
137                1,
138                255
139            ]
140        ],
141        "cmdUnderTest": "$TC filter del dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
142        "expExitCode": "0",
143        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
144        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1.*bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
145        "matchCount": "0",
146        "teardown": [
147            "$TC qdisc del dev $DEV1 ingress"
148        ]
149    },
150    {
151        "id": "e0a9",
152        "name": "List cBPF filters",
153        "category": [
154            "filter",
155            "bpf-filter"
156        ],
157        "plugins": {
158            "requires": "nsPlugin"
159        },
160        "setup": [
161            "$TC qdisc add dev $DEV1 ingress",
162            "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0'",
163            "$TC filter add dev $DEV1 parent ffff: handle 2 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 2054,6 0 0 262144,6 0 0 0'",
164            "$TC filter add dev $DEV1 parent ffff: handle 100 protocol ip prio 100 bpf bytecode '4,40 0 0 12,21 0 1 33024,6 0 0 262144,6 0 0 0'"
165        ],
166        "cmdUnderTest": "$TC filter show dev $DEV1 parent ffff:",
167        "expExitCode": "0",
168        "verifyCmd": "$TC filter show dev $DEV1 parent ffff:",
169        "matchPattern": "filter protocol ip pref 100 bpf chain [0-9]+ handle",
170        "matchCount": "3",
171        "teardown": [
172            "$TC qdisc del dev $DEV1 ingress"
173        ]
174    }
175]
176