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               "buildebpfPlugin",
56               "nsPlugin"
57            ]
58        },
59        "setup": [
60            "$TC qdisc add dev $DEV1 ingress"
61        ],
62        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ok",
63        "expExitCode": "0",
64        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
65        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ok\\].*tag [0-9a-f]{16}( jited)?",
66        "matchCount": "1",
67        "teardown": [
68            "$TC qdisc del dev $DEV1 ingress"
69        ]
70    },
71    {
72        "id": "2373",
73        "name": "Add eBPF filter with invalid object-file",
74        "category": [
75            "filter",
76            "bpf-filter"
77        ],
78        "plugins": {
79            "requires": [
80               "buildebpfPlugin",
81               "nsPlugin"
82            ]
83        },
84        "setup": [
85            "$TC qdisc add dev $DEV1 ingress"
86        ],
87        "cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf object-file $EBPFDIR/action.o section action-ko",
88        "expExitCode": "1",
89        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
90        "matchPattern": "filter parent ffff: protocol ip pref 100 bpf chain [0-9]+ handle 0x1 action.o:\\[action-ko\\].*tag [0-9a-f]{16}( jited)?",
91        "matchCount": "0",
92        "teardown": [
93            "$TC qdisc del dev $DEV1 ingress"
94        ]
95    },
96    {
97        "id": "4423",
98        "name": "Replace cBPF bytecode",
99        "category": [
100            "filter",
101            "bpf-filter"
102        ],
103        "plugins": {
104            "requires": "nsPlugin"
105        },
106        "setup": [
107            "$TC qdisc add dev $DEV1 ingress",
108            [
109                "$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'",
110                0,
111                1,
112                255
113            ]
114        ],
115        "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'",
116        "expExitCode": "0",
117        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
118        "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'",
119        "matchCount": "1",
120        "teardown": [
121            "$TC qdisc del dev $DEV1 ingress"
122        ]
123    },
124    {
125        "id": "5122",
126        "name": "Delete cBPF filter",
127        "category": [
128            "filter",
129            "bpf-filter"
130        ],
131        "plugins": {
132            "requires": "nsPlugin"
133        },
134        "setup": [
135            "$TC qdisc add dev $DEV1 ingress",
136            [
137                "$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'",
138                0,
139                1,
140                255
141            ]
142        ],
143        "cmdUnderTest": "$TC filter del dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
144        "expExitCode": "0",
145        "verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 protocol ip prio 100 bpf",
146        "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'",
147        "matchCount": "0",
148        "teardown": [
149            "$TC qdisc del dev $DEV1 ingress"
150        ]
151    },
152    {
153        "id": "e0a9",
154        "name": "List cBPF filters",
155        "category": [
156            "filter",
157            "bpf-filter"
158        ],
159        "plugins": {
160            "requires": "nsPlugin"
161        },
162        "setup": [
163            "$TC qdisc add dev $DEV1 ingress",
164            "$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'",
165            "$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'",
166            "$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'"
167        ],
168        "cmdUnderTest": "$TC filter show dev $DEV1 parent ffff:",
169        "expExitCode": "0",
170        "verifyCmd": "$TC filter show dev $DEV1 parent ffff:",
171        "matchPattern": "filter protocol ip pref 100 bpf chain [0-9]+ handle",
172        "matchCount": "3",
173        "teardown": [
174            "$TC qdisc del dev $DEV1 ingress"
175        ]
176    }
177]
178