diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2014-05-22 13:16:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-23 15:09:09 -0400 |
commit | ece80490e2c1cefda018b2e5b96d4f39083d9096 (patch) | |
tree | 05d399547dee0945172cb887b185edeb6bc8557a /lib/test_bpf.c | |
parent | ed616689a3d95eb6c9bdbb1ef74b0f50cbdf276a (diff) |
lib/test_bpf.c: don't use gcc union shortcut
Older gcc's (mine is gcc-4.4.4) make a mess of this.
lib/test_bpf.c:74: error: unknown field 'insns' specified in initializer
lib/test_bpf.c:75: warning: missing braces around initializer
lib/test_bpf.c:75: warning: (near initialization for 'tests[0].<anonymous>.insns[0]')
lib/test_bpf.c:76: error: extra brace group at end of initializer
lib/test_bpf.c:76: error: (near initialization for 'tests[0].<anonymous>')
lib/test_bpf.c:76: warning: excess elements in union initializer
lib/test_bpf.c:76: warning: (near initialization for 'tests[0].<anonymous>')
lib/test_bpf.c:77: error: extra brace group at end of initializer
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/test_bpf.c')
-rw-r--r-- | lib/test_bpf.c | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c index e160934430eb..3d80adbdb559 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c | |||
@@ -54,7 +54,7 @@ struct bpf_test { | |||
54 | union { | 54 | union { |
55 | struct sock_filter insns[MAX_INSNS]; | 55 | struct sock_filter insns[MAX_INSNS]; |
56 | struct sock_filter_int insns_int[MAX_INSNS]; | 56 | struct sock_filter_int insns_int[MAX_INSNS]; |
57 | }; | 57 | } u; |
58 | enum { | 58 | enum { |
59 | NO_DATA, | 59 | NO_DATA, |
60 | EXPECTED_FAIL, | 60 | EXPECTED_FAIL, |
@@ -71,7 +71,7 @@ struct bpf_test { | |||
71 | static struct bpf_test tests[] = { | 71 | static struct bpf_test tests[] = { |
72 | { | 72 | { |
73 | "TAX", | 73 | "TAX", |
74 | .insns = { | 74 | .u.insns = { |
75 | BPF_STMT(BPF_LD | BPF_IMM, 1), | 75 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
76 | BPF_STMT(BPF_MISC | BPF_TAX, 0), | 76 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
77 | BPF_STMT(BPF_LD | BPF_IMM, 2), | 77 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
@@ -90,7 +90,7 @@ static struct bpf_test tests[] = { | |||
90 | }, | 90 | }, |
91 | { | 91 | { |
92 | "TXA", | 92 | "TXA", |
93 | .insns = { | 93 | .u.insns = { |
94 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 94 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
95 | BPF_STMT(BPF_MISC | BPF_TXA, 0), | 95 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
96 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), | 96 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
@@ -102,7 +102,7 @@ static struct bpf_test tests[] = { | |||
102 | }, | 102 | }, |
103 | { | 103 | { |
104 | "ADD_SUB_MUL_K", | 104 | "ADD_SUB_MUL_K", |
105 | .insns = { | 105 | .u.insns = { |
106 | BPF_STMT(BPF_LD | BPF_IMM, 1), | 106 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
107 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2), | 107 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2), |
108 | BPF_STMT(BPF_LDX | BPF_IMM, 3), | 108 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
@@ -117,7 +117,7 @@ static struct bpf_test tests[] = { | |||
117 | }, | 117 | }, |
118 | { | 118 | { |
119 | "DIV_KX", | 119 | "DIV_KX", |
120 | .insns = { | 120 | .u.insns = { |
121 | BPF_STMT(BPF_LD | BPF_IMM, 8), | 121 | BPF_STMT(BPF_LD | BPF_IMM, 8), |
122 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2), | 122 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2), |
123 | BPF_STMT(BPF_MISC | BPF_TAX, 0), | 123 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
@@ -135,7 +135,7 @@ static struct bpf_test tests[] = { | |||
135 | }, | 135 | }, |
136 | { | 136 | { |
137 | "AND_OR_LSH_K", | 137 | "AND_OR_LSH_K", |
138 | .insns = { | 138 | .u.insns = { |
139 | BPF_STMT(BPF_LD | BPF_IMM, 0xff), | 139 | BPF_STMT(BPF_LD | BPF_IMM, 0xff), |
140 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), | 140 | BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0), |
141 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27), | 141 | BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27), |
@@ -151,7 +151,7 @@ static struct bpf_test tests[] = { | |||
151 | }, | 151 | }, |
152 | { | 152 | { |
153 | "LD_IND", | 153 | "LD_IND", |
154 | .insns = { | 154 | .u.insns = { |
155 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 155 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
156 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K), | 156 | BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K), |
157 | BPF_STMT(BPF_RET | BPF_K, 1) | 157 | BPF_STMT(BPF_RET | BPF_K, 1) |
@@ -162,7 +162,7 @@ static struct bpf_test tests[] = { | |||
162 | }, | 162 | }, |
163 | { | 163 | { |
164 | "LD_ABS", | 164 | "LD_ABS", |
165 | .insns = { | 165 | .u.insns = { |
166 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000), | 166 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000), |
167 | BPF_STMT(BPF_RET | BPF_K, 1) | 167 | BPF_STMT(BPF_RET | BPF_K, 1) |
168 | }, | 168 | }, |
@@ -172,7 +172,7 @@ static struct bpf_test tests[] = { | |||
172 | }, | 172 | }, |
173 | { | 173 | { |
174 | "LD_ABS_LL", | 174 | "LD_ABS_LL", |
175 | .insns = { | 175 | .u.insns = { |
176 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF), | 176 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF), |
177 | BPF_STMT(BPF_MISC | BPF_TAX, 0), | 177 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
178 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1), | 178 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1), |
@@ -185,7 +185,7 @@ static struct bpf_test tests[] = { | |||
185 | }, | 185 | }, |
186 | { | 186 | { |
187 | "LD_IND_LL", | 187 | "LD_IND_LL", |
188 | .insns = { | 188 | .u.insns = { |
189 | BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1), | 189 | BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1), |
190 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 190 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
191 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), | 191 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
@@ -199,7 +199,7 @@ static struct bpf_test tests[] = { | |||
199 | }, | 199 | }, |
200 | { | 200 | { |
201 | "LD_ABS_NET", | 201 | "LD_ABS_NET", |
202 | .insns = { | 202 | .u.insns = { |
203 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF), | 203 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF), |
204 | BPF_STMT(BPF_MISC | BPF_TAX, 0), | 204 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
205 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1), | 205 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1), |
@@ -212,7 +212,7 @@ static struct bpf_test tests[] = { | |||
212 | }, | 212 | }, |
213 | { | 213 | { |
214 | "LD_IND_NET", | 214 | "LD_IND_NET", |
215 | .insns = { | 215 | .u.insns = { |
216 | BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15), | 216 | BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15), |
217 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 217 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
218 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), | 218 | BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0), |
@@ -226,7 +226,7 @@ static struct bpf_test tests[] = { | |||
226 | }, | 226 | }, |
227 | { | 227 | { |
228 | "LD_PKTTYPE", | 228 | "LD_PKTTYPE", |
229 | .insns = { | 229 | .u.insns = { |
230 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 230 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
231 | SKF_AD_OFF + SKF_AD_PKTTYPE), | 231 | SKF_AD_OFF + SKF_AD_PKTTYPE), |
232 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), | 232 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0), |
@@ -247,7 +247,7 @@ static struct bpf_test tests[] = { | |||
247 | }, | 247 | }, |
248 | { | 248 | { |
249 | "LD_MARK", | 249 | "LD_MARK", |
250 | .insns = { | 250 | .u.insns = { |
251 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 251 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
252 | SKF_AD_OFF + SKF_AD_MARK), | 252 | SKF_AD_OFF + SKF_AD_MARK), |
253 | BPF_STMT(BPF_RET | BPF_A, 0) | 253 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -258,7 +258,7 @@ static struct bpf_test tests[] = { | |||
258 | }, | 258 | }, |
259 | { | 259 | { |
260 | "LD_RXHASH", | 260 | "LD_RXHASH", |
261 | .insns = { | 261 | .u.insns = { |
262 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 262 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
263 | SKF_AD_OFF + SKF_AD_RXHASH), | 263 | SKF_AD_OFF + SKF_AD_RXHASH), |
264 | BPF_STMT(BPF_RET | BPF_A, 0) | 264 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -269,7 +269,7 @@ static struct bpf_test tests[] = { | |||
269 | }, | 269 | }, |
270 | { | 270 | { |
271 | "LD_QUEUE", | 271 | "LD_QUEUE", |
272 | .insns = { | 272 | .u.insns = { |
273 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 273 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
274 | SKF_AD_OFF + SKF_AD_QUEUE), | 274 | SKF_AD_OFF + SKF_AD_QUEUE), |
275 | BPF_STMT(BPF_RET | BPF_A, 0) | 275 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -280,7 +280,7 @@ static struct bpf_test tests[] = { | |||
280 | }, | 280 | }, |
281 | { | 281 | { |
282 | "LD_PROTOCOL", | 282 | "LD_PROTOCOL", |
283 | .insns = { | 283 | .u.insns = { |
284 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1), | 284 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1), |
285 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0), | 285 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0), |
286 | BPF_STMT(BPF_RET | BPF_K, 0), | 286 | BPF_STMT(BPF_RET | BPF_K, 0), |
@@ -299,7 +299,7 @@ static struct bpf_test tests[] = { | |||
299 | }, | 299 | }, |
300 | { | 300 | { |
301 | "LD_VLAN_TAG", | 301 | "LD_VLAN_TAG", |
302 | .insns = { | 302 | .u.insns = { |
303 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 303 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
304 | SKF_AD_OFF + SKF_AD_VLAN_TAG), | 304 | SKF_AD_OFF + SKF_AD_VLAN_TAG), |
305 | BPF_STMT(BPF_RET | BPF_A, 0) | 305 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -313,7 +313,7 @@ static struct bpf_test tests[] = { | |||
313 | }, | 313 | }, |
314 | { | 314 | { |
315 | "LD_VLAN_TAG_PRESENT", | 315 | "LD_VLAN_TAG_PRESENT", |
316 | .insns = { | 316 | .u.insns = { |
317 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 317 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
318 | SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), | 318 | SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), |
319 | BPF_STMT(BPF_RET | BPF_A, 0) | 319 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -327,7 +327,7 @@ static struct bpf_test tests[] = { | |||
327 | }, | 327 | }, |
328 | { | 328 | { |
329 | "LD_IFINDEX", | 329 | "LD_IFINDEX", |
330 | .insns = { | 330 | .u.insns = { |
331 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 331 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
332 | SKF_AD_OFF + SKF_AD_IFINDEX), | 332 | SKF_AD_OFF + SKF_AD_IFINDEX), |
333 | BPF_STMT(BPF_RET | BPF_A, 0) | 333 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -338,7 +338,7 @@ static struct bpf_test tests[] = { | |||
338 | }, | 338 | }, |
339 | { | 339 | { |
340 | "LD_HATYPE", | 340 | "LD_HATYPE", |
341 | .insns = { | 341 | .u.insns = { |
342 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 342 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
343 | SKF_AD_OFF + SKF_AD_HATYPE), | 343 | SKF_AD_OFF + SKF_AD_HATYPE), |
344 | BPF_STMT(BPF_RET | BPF_A, 0) | 344 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -349,7 +349,7 @@ static struct bpf_test tests[] = { | |||
349 | }, | 349 | }, |
350 | { | 350 | { |
351 | "LD_CPU", | 351 | "LD_CPU", |
352 | .insns = { | 352 | .u.insns = { |
353 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 353 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
354 | SKF_AD_OFF + SKF_AD_CPU), | 354 | SKF_AD_OFF + SKF_AD_CPU), |
355 | BPF_STMT(BPF_MISC | BPF_TAX, 0), | 355 | BPF_STMT(BPF_MISC | BPF_TAX, 0), |
@@ -364,7 +364,7 @@ static struct bpf_test tests[] = { | |||
364 | }, | 364 | }, |
365 | { | 365 | { |
366 | "LD_NLATTR", | 366 | "LD_NLATTR", |
367 | .insns = { | 367 | .u.insns = { |
368 | BPF_STMT(BPF_LDX | BPF_IMM, 1), | 368 | BPF_STMT(BPF_LDX | BPF_IMM, 1), |
369 | BPF_STMT(BPF_MISC | BPF_TXA, 0), | 369 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
370 | BPF_STMT(BPF_LDX | BPF_IMM, 3), | 370 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
@@ -378,7 +378,7 @@ static struct bpf_test tests[] = { | |||
378 | }, | 378 | }, |
379 | { | 379 | { |
380 | "LD_NLATTR_NEST", | 380 | "LD_NLATTR_NEST", |
381 | .insns = { | 381 | .u.insns = { |
382 | BPF_STMT(BPF_LD | BPF_IMM, 1), | 382 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
383 | BPF_STMT(BPF_LDX | BPF_IMM, 3), | 383 | BPF_STMT(BPF_LDX | BPF_IMM, 3), |
384 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 384 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
@@ -412,7 +412,7 @@ static struct bpf_test tests[] = { | |||
412 | }, | 412 | }, |
413 | { | 413 | { |
414 | "LD_PAYLOAD_OFF", | 414 | "LD_PAYLOAD_OFF", |
415 | .insns = { | 415 | .u.insns = { |
416 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 416 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
417 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), | 417 | SKF_AD_OFF + SKF_AD_PAY_OFFSET), |
418 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 418 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
@@ -439,7 +439,7 @@ static struct bpf_test tests[] = { | |||
439 | }, | 439 | }, |
440 | { | 440 | { |
441 | "LD_ANC_XOR", | 441 | "LD_ANC_XOR", |
442 | .insns = { | 442 | .u.insns = { |
443 | BPF_STMT(BPF_LD | BPF_IMM, 10), | 443 | BPF_STMT(BPF_LD | BPF_IMM, 10), |
444 | BPF_STMT(BPF_LDX | BPF_IMM, 300), | 444 | BPF_STMT(BPF_LDX | BPF_IMM, 300), |
445 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, | 445 | BPF_STMT(BPF_LD | BPF_W | BPF_ABS, |
@@ -452,7 +452,7 @@ static struct bpf_test tests[] = { | |||
452 | }, | 452 | }, |
453 | { | 453 | { |
454 | "SPILL_FILL", | 454 | "SPILL_FILL", |
455 | .insns = { | 455 | .u.insns = { |
456 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 456 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
457 | BPF_STMT(BPF_LD | BPF_IMM, 2), | 457 | BPF_STMT(BPF_LD | BPF_IMM, 2), |
458 | BPF_STMT(BPF_ALU | BPF_RSH, 1), | 458 | BPF_STMT(BPF_ALU | BPF_RSH, 1), |
@@ -474,7 +474,7 @@ static struct bpf_test tests[] = { | |||
474 | }, | 474 | }, |
475 | { | 475 | { |
476 | "JEQ", | 476 | "JEQ", |
477 | .insns = { | 477 | .u.insns = { |
478 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 478 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
479 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), | 479 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
480 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1), | 480 | BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1), |
@@ -487,7 +487,7 @@ static struct bpf_test tests[] = { | |||
487 | }, | 487 | }, |
488 | { | 488 | { |
489 | "JGT", | 489 | "JGT", |
490 | .insns = { | 490 | .u.insns = { |
491 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 491 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
492 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), | 492 | BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2), |
493 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1), | 493 | BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1), |
@@ -500,7 +500,7 @@ static struct bpf_test tests[] = { | |||
500 | }, | 500 | }, |
501 | { | 501 | { |
502 | "JGE", | 502 | "JGE", |
503 | .insns = { | 503 | .u.insns = { |
504 | BPF_STMT(BPF_LDX | BPF_LEN, 0), | 504 | BPF_STMT(BPF_LDX | BPF_LEN, 0), |
505 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K), | 505 | BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K), |
506 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0), | 506 | BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0), |
@@ -519,7 +519,7 @@ static struct bpf_test tests[] = { | |||
519 | }, | 519 | }, |
520 | { | 520 | { |
521 | "JSET", | 521 | "JSET", |
522 | .insns = { | 522 | .u.insns = { |
523 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), | 523 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
524 | BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1), | 524 | BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1), |
525 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), | 525 | BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0), |
@@ -551,7 +551,7 @@ static struct bpf_test tests[] = { | |||
551 | }, | 551 | }, |
552 | { | 552 | { |
553 | "tcpdump port 22", | 553 | "tcpdump port 22", |
554 | .insns = { | 554 | .u.insns = { |
555 | { 0x28, 0, 0, 0x0000000c }, | 555 | { 0x28, 0, 0, 0x0000000c }, |
556 | { 0x15, 0, 8, 0x000086dd }, | 556 | { 0x15, 0, 8, 0x000086dd }, |
557 | { 0x30, 0, 0, 0x00000014 }, | 557 | { 0x30, 0, 0, 0x00000014 }, |
@@ -596,7 +596,7 @@ static struct bpf_test tests[] = { | |||
596 | }, | 596 | }, |
597 | { | 597 | { |
598 | "tcpdump complex", | 598 | "tcpdump complex", |
599 | .insns = { | 599 | .u.insns = { |
600 | /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] - | 600 | /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] - |
601 | * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and | 601 | * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and |
602 | * (len > 115 or len < 30000000000)' -d | 602 | * (len > 115 or len < 30000000000)' -d |
@@ -649,7 +649,7 @@ static struct bpf_test tests[] = { | |||
649 | }, | 649 | }, |
650 | { | 650 | { |
651 | "RET_A", | 651 | "RET_A", |
652 | .insns = { | 652 | .u.insns = { |
653 | /* check that unitialized X and A contain zeros */ | 653 | /* check that unitialized X and A contain zeros */ |
654 | BPF_STMT(BPF_MISC | BPF_TXA, 0), | 654 | BPF_STMT(BPF_MISC | BPF_TXA, 0), |
655 | BPF_STMT(BPF_RET | BPF_A, 0) | 655 | BPF_STMT(BPF_RET | BPF_A, 0) |
@@ -660,7 +660,7 @@ static struct bpf_test tests[] = { | |||
660 | }, | 660 | }, |
661 | { | 661 | { |
662 | "INT: ADD trivial", | 662 | "INT: ADD trivial", |
663 | .insns_int = { | 663 | .u.insns_int = { |
664 | BPF_ALU64_IMM(BPF_MOV, R1, 1), | 664 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
665 | BPF_ALU64_IMM(BPF_ADD, R1, 2), | 665 | BPF_ALU64_IMM(BPF_ADD, R1, 2), |
666 | BPF_ALU64_IMM(BPF_MOV, R2, 3), | 666 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
@@ -676,7 +676,7 @@ static struct bpf_test tests[] = { | |||
676 | }, | 676 | }, |
677 | { | 677 | { |
678 | "INT: MUL_X", | 678 | "INT: MUL_X", |
679 | .insns_int = { | 679 | .u.insns_int = { |
680 | BPF_ALU64_IMM(BPF_MOV, R0, -1), | 680 | BPF_ALU64_IMM(BPF_MOV, R0, -1), |
681 | BPF_ALU64_IMM(BPF_MOV, R1, -1), | 681 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
682 | BPF_ALU64_IMM(BPF_MOV, R2, 3), | 682 | BPF_ALU64_IMM(BPF_MOV, R2, 3), |
@@ -692,7 +692,7 @@ static struct bpf_test tests[] = { | |||
692 | }, | 692 | }, |
693 | { | 693 | { |
694 | "INT: MUL_X2", | 694 | "INT: MUL_X2", |
695 | .insns_int = { | 695 | .u.insns_int = { |
696 | BPF_ALU32_IMM(BPF_MOV, R0, -1), | 696 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
697 | BPF_ALU32_IMM(BPF_MOV, R1, -1), | 697 | BPF_ALU32_IMM(BPF_MOV, R1, -1), |
698 | BPF_ALU32_IMM(BPF_MOV, R2, 3), | 698 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
@@ -709,7 +709,7 @@ static struct bpf_test tests[] = { | |||
709 | }, | 709 | }, |
710 | { | 710 | { |
711 | "INT: MUL32_X", | 711 | "INT: MUL32_X", |
712 | .insns_int = { | 712 | .u.insns_int = { |
713 | BPF_ALU32_IMM(BPF_MOV, R0, -1), | 713 | BPF_ALU32_IMM(BPF_MOV, R0, -1), |
714 | BPF_ALU64_IMM(BPF_MOV, R1, -1), | 714 | BPF_ALU64_IMM(BPF_MOV, R1, -1), |
715 | BPF_ALU32_IMM(BPF_MOV, R2, 3), | 715 | BPF_ALU32_IMM(BPF_MOV, R2, 3), |
@@ -730,7 +730,7 @@ static struct bpf_test tests[] = { | |||
730 | * different asm code. | 730 | * different asm code. |
731 | */ | 731 | */ |
732 | "INT: ADD 64-bit", | 732 | "INT: ADD 64-bit", |
733 | .insns_int = { | 733 | .u.insns_int = { |
734 | BPF_ALU64_IMM(BPF_MOV, R0, 0), | 734 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
735 | BPF_ALU64_IMM(BPF_MOV, R1, 1), | 735 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
736 | BPF_ALU64_IMM(BPF_MOV, R2, 2), | 736 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
@@ -888,7 +888,7 @@ static struct bpf_test tests[] = { | |||
888 | }, | 888 | }, |
889 | { | 889 | { |
890 | "INT: ADD 32-bit", | 890 | "INT: ADD 32-bit", |
891 | .insns_int = { | 891 | .u.insns_int = { |
892 | BPF_ALU32_IMM(BPF_MOV, R0, 20), | 892 | BPF_ALU32_IMM(BPF_MOV, R0, 20), |
893 | BPF_ALU32_IMM(BPF_MOV, R1, 1), | 893 | BPF_ALU32_IMM(BPF_MOV, R1, 1), |
894 | BPF_ALU32_IMM(BPF_MOV, R2, 2), | 894 | BPF_ALU32_IMM(BPF_MOV, R2, 2), |
@@ -1034,7 +1034,7 @@ static struct bpf_test tests[] = { | |||
1034 | }, | 1034 | }, |
1035 | { /* Mainly checking JIT here. */ | 1035 | { /* Mainly checking JIT here. */ |
1036 | "INT: SUB", | 1036 | "INT: SUB", |
1037 | .insns_int = { | 1037 | .u.insns_int = { |
1038 | BPF_ALU64_IMM(BPF_MOV, R0, 0), | 1038 | BPF_ALU64_IMM(BPF_MOV, R0, 0), |
1039 | BPF_ALU64_IMM(BPF_MOV, R1, 1), | 1039 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
1040 | BPF_ALU64_IMM(BPF_MOV, R2, 2), | 1040 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
@@ -1167,7 +1167,7 @@ static struct bpf_test tests[] = { | |||
1167 | }, | 1167 | }, |
1168 | { /* Mainly checking JIT here. */ | 1168 | { /* Mainly checking JIT here. */ |
1169 | "INT: XOR", | 1169 | "INT: XOR", |
1170 | .insns_int = { | 1170 | .u.insns_int = { |
1171 | BPF_ALU64_REG(BPF_SUB, R0, R0), | 1171 | BPF_ALU64_REG(BPF_SUB, R0, R0), |
1172 | BPF_ALU64_REG(BPF_XOR, R1, R1), | 1172 | BPF_ALU64_REG(BPF_XOR, R1, R1), |
1173 | BPF_JMP_REG(BPF_JEQ, R0, R1, 1), | 1173 | BPF_JMP_REG(BPF_JEQ, R0, R1, 1), |
@@ -1233,7 +1233,7 @@ static struct bpf_test tests[] = { | |||
1233 | }, | 1233 | }, |
1234 | { /* Mainly checking JIT here. */ | 1234 | { /* Mainly checking JIT here. */ |
1235 | "INT: MUL", | 1235 | "INT: MUL", |
1236 | .insns_int = { | 1236 | .u.insns_int = { |
1237 | BPF_ALU64_IMM(BPF_MOV, R0, 11), | 1237 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
1238 | BPF_ALU64_IMM(BPF_MOV, R1, 1), | 1238 | BPF_ALU64_IMM(BPF_MOV, R1, 1), |
1239 | BPF_ALU64_IMM(BPF_MOV, R2, 2), | 1239 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
@@ -1295,7 +1295,7 @@ static struct bpf_test tests[] = { | |||
1295 | }, | 1295 | }, |
1296 | { | 1296 | { |
1297 | "INT: ALU MIX", | 1297 | "INT: ALU MIX", |
1298 | .insns_int = { | 1298 | .u.insns_int = { |
1299 | BPF_ALU64_IMM(BPF_MOV, R0, 11), | 1299 | BPF_ALU64_IMM(BPF_MOV, R0, 11), |
1300 | BPF_ALU64_IMM(BPF_ADD, R0, -1), | 1300 | BPF_ALU64_IMM(BPF_ADD, R0, -1), |
1301 | BPF_ALU64_IMM(BPF_MOV, R2, 2), | 1301 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
@@ -1315,7 +1315,7 @@ static struct bpf_test tests[] = { | |||
1315 | }, | 1315 | }, |
1316 | { | 1316 | { |
1317 | "INT: DIV + ABS", | 1317 | "INT: DIV + ABS", |
1318 | .insns_int = { | 1318 | .u.insns_int = { |
1319 | BPF_ALU64_REG(BPF_MOV, R6, R1), | 1319 | BPF_ALU64_REG(BPF_MOV, R6, R1), |
1320 | BPF_LD_ABS(BPF_B, 3), | 1320 | BPF_LD_ABS(BPF_B, 3), |
1321 | BPF_ALU64_IMM(BPF_MOV, R2, 2), | 1321 | BPF_ALU64_IMM(BPF_MOV, R2, 2), |
@@ -1332,7 +1332,7 @@ static struct bpf_test tests[] = { | |||
1332 | }, | 1332 | }, |
1333 | { | 1333 | { |
1334 | "INT: DIV by zero", | 1334 | "INT: DIV by zero", |
1335 | .insns_int = { | 1335 | .u.insns_int = { |
1336 | BPF_ALU64_REG(BPF_MOV, R6, R1), | 1336 | BPF_ALU64_REG(BPF_MOV, R6, R1), |
1337 | BPF_ALU64_IMM(BPF_MOV, R7, 0), | 1337 | BPF_ALU64_IMM(BPF_MOV, R7, 0), |
1338 | BPF_LD_ABS(BPF_B, 3), | 1338 | BPF_LD_ABS(BPF_B, 3), |
@@ -1345,7 +1345,7 @@ static struct bpf_test tests[] = { | |||
1345 | }, | 1345 | }, |
1346 | { | 1346 | { |
1347 | "check: missing ret", | 1347 | "check: missing ret", |
1348 | .insns = { | 1348 | .u.insns = { |
1349 | BPF_STMT(BPF_LD | BPF_IMM, 1), | 1349 | BPF_STMT(BPF_LD | BPF_IMM, 1), |
1350 | }, | 1350 | }, |
1351 | EXPECTED_FAIL, | 1351 | EXPECTED_FAIL, |
@@ -1354,7 +1354,7 @@ static struct bpf_test tests[] = { | |||
1354 | }, | 1354 | }, |
1355 | { | 1355 | { |
1356 | "check: div_k_0", | 1356 | "check: div_k_0", |
1357 | .insns = { | 1357 | .u.insns = { |
1358 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0), | 1358 | BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0), |
1359 | BPF_STMT(BPF_RET | BPF_K, 0) | 1359 | BPF_STMT(BPF_RET | BPF_K, 0) |
1360 | }, | 1360 | }, |
@@ -1364,7 +1364,7 @@ static struct bpf_test tests[] = { | |||
1364 | }, | 1364 | }, |
1365 | { | 1365 | { |
1366 | "check: unknown insn", | 1366 | "check: unknown insn", |
1367 | .insns = { | 1367 | .u.insns = { |
1368 | /* seccomp insn, rejected in socket filter */ | 1368 | /* seccomp insn, rejected in socket filter */ |
1369 | BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0), | 1369 | BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0), |
1370 | BPF_STMT(BPF_RET | BPF_K, 0) | 1370 | BPF_STMT(BPF_RET | BPF_K, 0) |
@@ -1375,7 +1375,7 @@ static struct bpf_test tests[] = { | |||
1375 | }, | 1375 | }, |
1376 | { | 1376 | { |
1377 | "check: out of range spill/fill", | 1377 | "check: out of range spill/fill", |
1378 | .insns = { | 1378 | .u.insns = { |
1379 | BPF_STMT(BPF_STX, 16), | 1379 | BPF_STMT(BPF_STX, 16), |
1380 | BPF_STMT(BPF_RET | BPF_K, 0) | 1380 | BPF_STMT(BPF_RET | BPF_K, 0) |
1381 | }, | 1381 | }, |
@@ -1478,7 +1478,7 @@ static __init int test_bpf(void) | |||
1478 | for (i = 0; i < ARRAY_SIZE(tests); i++) { | 1478 | for (i = 0; i < ARRAY_SIZE(tests); i++) { |
1479 | pr_info("#%d %s ", i, tests[i].descr); | 1479 | pr_info("#%d %s ", i, tests[i].descr); |
1480 | 1480 | ||
1481 | fprog.filter = tests[i].insns; | 1481 | fprog.filter = tests[i].u.insns; |
1482 | fprog.len = get_length(fprog.filter); | 1482 | fprog.len = get_length(fprog.filter); |
1483 | 1483 | ||
1484 | if (tests[i].data_type == SKB_INT) { | 1484 | if (tests[i].data_type == SKB_INT) { |
@@ -1486,7 +1486,7 @@ static __init int test_bpf(void) | |||
1486 | if (!fp_ext) | 1486 | if (!fp_ext) |
1487 | return -ENOMEM; | 1487 | return -ENOMEM; |
1488 | fp = fp_ext; | 1488 | fp = fp_ext; |
1489 | memcpy(fp_ext->insns, tests[i].insns_int, | 1489 | memcpy(fp_ext->insns, tests[i].u.insns_int, |
1490 | fprog.len * 8); | 1490 | fprog.len * 8); |
1491 | fp->len = fprog.len; | 1491 | fp->len = fprog.len; |
1492 | sk_filter_select_runtime(fp); | 1492 | sk_filter_select_runtime(fp); |