Skip to content

Commit 4717b05

Browse files
Roman Mashakdavem330
Roman Mashak
authored andcommitted
tc-testing: Introduced tdc tests for basic filter
Added tests for 'cmp' extended match rules. Signed-off-by: Roman Mashak <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ce9db46 commit 4717b05

File tree

1 file changed

+325
-0
lines changed
  • tools/testing/selftests/tc-testing/tc-tests/filters

1 file changed

+325
-0
lines changed
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
[
2+
{
3+
"id": "7a92",
4+
"name": "Add basic filter with cmp ematch u8/link layer and default action",
5+
"category": [
6+
"filter",
7+
"basic"
8+
],
9+
"setup": [
10+
"$TC qdisc add dev $DEV1 ingress"
11+
],
12+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff gt 10)' classid 1:1",
13+
"expExitCode": "0",
14+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
15+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1 flowid 1:1.*cmp\\(u8 at 0 layer 0 mask 0xff gt 10\\)",
16+
"matchCount": "1",
17+
"teardown": [
18+
"$TC qdisc del dev $DEV1 ingress"
19+
]
20+
},
21+
{
22+
"id": "2e8a",
23+
"name": "Add basic filter with cmp ematch u8/link layer with trans flag and default action",
24+
"category": [
25+
"filter",
26+
"basic"
27+
],
28+
"setup": [
29+
"$TC qdisc add dev $DEV1 ingress"
30+
],
31+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff trans gt 10)' classid 1:1",
32+
"expExitCode": "0",
33+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
34+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1 flowid 1:1.*cmp\\(u8 at 0 layer 0 mask 0xff trans gt 10\\)",
35+
"matchCount": "1",
36+
"teardown": [
37+
"$TC qdisc del dev $DEV1 ingress"
38+
]
39+
},
40+
{
41+
"id": "4d9f",
42+
"name": "Add basic filter with cmp ematch u16/link layer and a single action",
43+
"category": [
44+
"filter",
45+
"basic"
46+
],
47+
"setup": [
48+
"$TC qdisc add dev $DEV1 ingress"
49+
],
50+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u16 at 0 layer 0 mask 0xff00 lt 3)' action pass",
51+
"expExitCode": "0",
52+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
53+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u16 at 0 layer 0 mask 0xff00 lt 3\\).*action.*gact action pass",
54+
"matchCount": "1",
55+
"teardown": [
56+
"$TC qdisc del dev $DEV1 ingress"
57+
]
58+
},
59+
{
60+
"id": "4943",
61+
"name": "Add basic filter with cmp ematch u32/link layer and miltiple actions",
62+
"category": [
63+
"filter",
64+
"basic"
65+
],
66+
"setup": [
67+
"$TC qdisc add dev $DEV1 ingress"
68+
],
69+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u32 at 4 layer link mask 0xff00ff00 eq 3)' action skbedit mark 7 pipe action gact drop",
70+
"expExitCode": "0",
71+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
72+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u32 at 4 layer 0 mask 0xff00ff00 eq 3\\).*action.*skbedit.*mark 7 pipe.*action.*gact action drop",
73+
"matchCount": "1",
74+
"teardown": [
75+
"$TC qdisc del dev $DEV1 ingress"
76+
]
77+
},
78+
{
79+
"id": "7559",
80+
"name": "Add basic filter with cmp ematch u8/network layer and default action",
81+
"category": [
82+
"filter",
83+
"basic"
84+
],
85+
"setup": [
86+
"$TC qdisc add dev $DEV1 ingress"
87+
],
88+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 0xab protocol ip prio 11 basic match 'cmp(u8 at 0 layer 1 mask 0xff gt 10)' classid 1:1",
89+
"expExitCode": "0",
90+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 0xab prio 11 protocol ip basic",
91+
"matchPattern": "^filter parent ffff: protocol ip pref 11 basic.*handle 0xab flowid 1:1.*cmp\\(u8 at 0 layer 1 mask 0xff gt 10\\)",
92+
"matchCount": "1",
93+
"teardown": [
94+
"$TC qdisc del dev $DEV1 ingress"
95+
]
96+
},
97+
{
98+
"id": "aff4",
99+
"name": "Add basic filter with cmp ematch u8/network layer with trans flag and default action",
100+
"category": [
101+
"filter",
102+
"basic"
103+
],
104+
"setup": [
105+
"$TC qdisc add dev $DEV1 ingress"
106+
],
107+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 0xab protocol ip prio 11 basic match 'cmp(u8 at 0 layer 1 mask 0xff trans gt 10)' classid 1:1",
108+
"expExitCode": "0",
109+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 0xab prio 11 protocol ip basic",
110+
"matchPattern": "^filter parent ffff: protocol ip pref 11 basic.*handle 0xab flowid 1:1.*cmp\\(u8 at 0 layer 1 mask 0xff trans gt 10\\)",
111+
"matchCount": "1",
112+
"teardown": [
113+
"$TC qdisc del dev $DEV1 ingress"
114+
]
115+
},
116+
{
117+
"id": "c732",
118+
"name": "Add basic filter with cmp ematch u16/network layer and a single action",
119+
"category": [
120+
"filter",
121+
"basic"
122+
],
123+
"setup": [
124+
"$TC qdisc add dev $DEV1 ingress"
125+
],
126+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 0x100 protocol ip prio 100 basic match 'cmp(u16 at 0 layer network mask 0xff00 lt 3)' action pass",
127+
"expExitCode": "0",
128+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 0x100 prio 100 protocol ip basic",
129+
"matchPattern": "^filter parent ffff: protocol ip pref 100 basic.*handle 0x100.*cmp\\(u16 at 0 layer 1 mask 0xff00 lt 3\\).*action.*gact action pass",
130+
"matchCount": "1",
131+
"teardown": [
132+
"$TC qdisc del dev $DEV1 ingress"
133+
]
134+
},
135+
{
136+
"id": "32d8",
137+
"name": "Add basic filter with cmp ematch u32/network layer and miltiple actions",
138+
"category": [
139+
"filter",
140+
"basic"
141+
],
142+
"setup": [
143+
"$TC qdisc add dev $DEV1 ingress"
144+
],
145+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 0x112233 protocol ip prio 7 basic match 'cmp(u32 at 4 layer network mask 0xff00ff00 eq 3)' action skbedit mark 7 pipe action gact drop",
146+
"expExitCode": "0",
147+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 0x112233 prio 7 protocol ip basic",
148+
"matchPattern": "^filter parent ffff: protocol ip pref 7 basic.*handle 0x112233.*cmp\\(u32 at 4 layer 1 mask 0xff00ff00 eq 3\\).*action.*skbedit.*mark 7 pipe.*action.*gact action drop",
149+
"matchCount": "1",
150+
"teardown": [
151+
"$TC qdisc del dev $DEV1 ingress"
152+
]
153+
},
154+
{
155+
"id": "6f5e",
156+
"name": "Add basic filter with cmp ematch u8/transport layer and default action",
157+
"category": [
158+
"filter",
159+
"basic"
160+
],
161+
"setup": [
162+
"$TC qdisc add dev $DEV1 ingress"
163+
],
164+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer transport mask 0xff gt 10)' classid 1:1",
165+
"expExitCode": "0",
166+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
167+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1 flowid 1:1.*cmp\\(u8 at 0 layer 2 mask 0xff gt 10\\)",
168+
"matchCount": "1",
169+
"teardown": [
170+
"$TC qdisc del dev $DEV1 ingress"
171+
]
172+
},
173+
{
174+
"id": "0752",
175+
"name": "Add basic filter with cmp ematch u8/transport layer with trans flag and default action",
176+
"category": [
177+
"filter",
178+
"basic"
179+
],
180+
"setup": [
181+
"$TC qdisc add dev $DEV1 ingress"
182+
],
183+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer transport mask 0xff trans gt 10)' classid 1:1",
184+
"expExitCode": "0",
185+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
186+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1 flowid 1:1.*cmp\\(u8 at 0 layer 2 mask 0xff trans gt 10\\)",
187+
"matchCount": "1",
188+
"teardown": [
189+
"$TC qdisc del dev $DEV1 ingress"
190+
]
191+
},
192+
{
193+
"id": "7e07",
194+
"name": "Add basic filter with cmp ematch u16/transport layer and a single action",
195+
"category": [
196+
"filter",
197+
"basic"
198+
],
199+
"setup": [
200+
"$TC qdisc add dev $DEV1 ingress"
201+
],
202+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u16 at 0 layer 2 mask 0xff00 lt 3)' action pass",
203+
"expExitCode": "0",
204+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
205+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u16 at 0 layer 2 mask 0xff00 lt 3\\).*action.*gact action pass",
206+
"matchCount": "1",
207+
"teardown": [
208+
"$TC qdisc del dev $DEV1 ingress"
209+
]
210+
},
211+
{
212+
"id": "62d7",
213+
"name": "Add basic filter with cmp ematch u32/transport layer and miltiple actions",
214+
"category": [
215+
"filter",
216+
"basic"
217+
],
218+
"setup": [
219+
"$TC qdisc add dev $DEV1 ingress"
220+
],
221+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u32 at 4 layer transport mask 0xff00ff00 eq 3)' action skbedit mark 7 pipe action gact drop",
222+
"expExitCode": "0",
223+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
224+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u32 at 4 layer 2 mask 0xff00ff00 eq 3\\).*action.*skbedit.*mark 7 pipe.*action.*gact action drop",
225+
"matchCount": "1",
226+
"teardown": [
227+
"$TC qdisc del dev $DEV1 ingress"
228+
]
229+
},
230+
{
231+
"id": "304b",
232+
"name": "Add basic filter with NOT cmp ematch rule and default action",
233+
"category": [
234+
"filter",
235+
"basic"
236+
],
237+
"setup": [
238+
"$TC qdisc add dev $DEV1 ingress"
239+
],
240+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'not cmp(u8 at 0 layer link mask 0xff eq 3)' classid 1:1",
241+
"expExitCode": "0",
242+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
243+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1 flowid 1:1.*NOT cmp\\(u8 at 0 layer 0 mask 0xff eq 3\\)",
244+
"matchCount": "1",
245+
"teardown": [
246+
"$TC qdisc del dev $DEV1 ingress"
247+
]
248+
},
249+
{
250+
"id": "8ecb",
251+
"name": "Add basic filter with two ANDed cmp ematch rules and single action",
252+
"category": [
253+
"filter",
254+
"basic"
255+
],
256+
"setup": [
257+
"$TC qdisc add dev $DEV1 ingress"
258+
],
259+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff eq 3) and cmp(u16 at 8 layer link mask 0x00ff gt 7)' action gact drop",
260+
"expExitCode": "0",
261+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
262+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u8 at 0 layer 0 mask 0xff eq 3\\).*AND cmp\\(u16 at 8 layer 0 mask 0xff gt 7\\).*action.*gact action drop",
263+
"matchCount": "1",
264+
"teardown": [
265+
"$TC qdisc del dev $DEV1 ingress"
266+
]
267+
},
268+
{
269+
"id": "b1ad",
270+
"name": "Add basic filter with two ORed cmp ematch rules and single action",
271+
"category": [
272+
"filter",
273+
"basic"
274+
],
275+
"setup": [
276+
"$TC qdisc add dev $DEV1 ingress"
277+
],
278+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff eq 3) or cmp(u16 at 8 layer link mask 0x00ff gt 7)' action gact drop",
279+
"expExitCode": "0",
280+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
281+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u8 at 0 layer 0 mask 0xff eq 3\\).*OR cmp\\(u16 at 8 layer 0 mask 0xff gt 7\\).*action.*gact action drop",
282+
"matchCount": "1",
283+
"teardown": [
284+
"$TC qdisc del dev $DEV1 ingress"
285+
]
286+
},
287+
{
288+
"id": "4600",
289+
"name": "Add basic filter with two ANDed cmp ematch rules and one ORed ematch rule and single action",
290+
"category": [
291+
"filter",
292+
"basic"
293+
],
294+
"setup": [
295+
"$TC qdisc add dev $DEV1 ingress"
296+
],
297+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff eq 3) and cmp(u16 at 8 layer link mask 0x00ff gt 7) or cmp(u32 at 4 layer network mask 0xa0a0 lt 3)' action gact drop",
298+
"expExitCode": "0",
299+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
300+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u8 at 0 layer 0 mask 0xff eq 3\\).*AND cmp\\(u16 at 8 layer 0 mask 0xff gt 7\\).*OR cmp\\(u32 at 4 layer 1 mask 0xa0a0 lt 3\\).*action.*gact action drop",
301+
"matchCount": "1",
302+
"teardown": [
303+
"$TC qdisc del dev $DEV1 ingress"
304+
]
305+
},
306+
{
307+
"id": "bc59",
308+
"name": "Add basic filter with two ANDed cmp ematch rules and one NOT ORed ematch rule and single action",
309+
"category": [
310+
"filter",
311+
"basic"
312+
],
313+
"setup": [
314+
"$TC qdisc add dev $DEV1 ingress"
315+
],
316+
"cmdUnderTest": "$TC filter add dev $DEV1 parent ffff: handle 1 protocol ip prio 1 basic match 'cmp(u8 at 0 layer link mask 0xff eq 3) and cmp(u16 at 8 layer link mask 0x00ff gt 7) or not cmp(u32 at 4 layer network mask 0xa0a0 lt 3)' action gact drop",
317+
"expExitCode": "0",
318+
"verifyCmd": "$TC filter get dev $DEV1 parent ffff: handle 1 prio 1 protocol ip basic",
319+
"matchPattern": "^filter parent ffff: protocol ip pref 1 basic.*handle 0x1.*cmp\\(u8 at 0 layer 0 mask 0xff eq 3\\).*AND cmp\\(u16 at 8 layer 0 mask 0xff gt 7\\).*OR NOT cmp\\(u32 at 4 layer 1 mask 0xa0a0 lt 3\\).*action.*gact action drop",
320+
"matchCount": "1",
321+
"teardown": [
322+
"$TC qdisc del dev $DEV1 ingress"
323+
]
324+
}
325+
]

0 commit comments

Comments
 (0)