Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Linux Socket Filter Data Structures | |
3 | */ | |
1da177e4 LT |
4 | #ifndef __LINUX_FILTER_H__ |
5 | #define __LINUX_FILTER_H__ | |
6 | ||
b954d834 DB |
7 | #include <stdarg.h> |
8 | ||
60063497 | 9 | #include <linux/atomic.h> |
0c5fe1b4 | 10 | #include <linux/compat.h> |
9f12fbe6 | 11 | #include <linux/skbuff.h> |
b954d834 DB |
12 | #include <linux/linkage.h> |
13 | #include <linux/printk.h> | |
d45ed4a4 | 14 | #include <linux/workqueue.h> |
b954d834 | 15 | |
60a3b225 | 16 | #include <asm/cacheflush.h> |
b954d834 DB |
17 | |
18 | #include <uapi/linux/filter.h> | |
daedfb22 | 19 | #include <uapi/linux/bpf.h> |
60a3b225 DB |
20 | |
21 | struct sk_buff; | |
22 | struct sock; | |
23 | struct seccomp_data; | |
792d4b5c | 24 | |
30743837 DB |
25 | /* ArgX, context and stack frame pointer register positions. Note, |
26 | * Arg1, Arg2, Arg3, etc are used as argument mappings of function | |
27 | * calls in BPF_CALL instruction. | |
28 | */ | |
29 | #define BPF_REG_ARG1 BPF_REG_1 | |
30 | #define BPF_REG_ARG2 BPF_REG_2 | |
31 | #define BPF_REG_ARG3 BPF_REG_3 | |
32 | #define BPF_REG_ARG4 BPF_REG_4 | |
33 | #define BPF_REG_ARG5 BPF_REG_5 | |
34 | #define BPF_REG_CTX BPF_REG_6 | |
35 | #define BPF_REG_FP BPF_REG_10 | |
36 | ||
37 | /* Additional register mappings for converted user programs. */ | |
38 | #define BPF_REG_A BPF_REG_0 | |
39 | #define BPF_REG_X BPF_REG_7 | |
40 | #define BPF_REG_TMP BPF_REG_8 | |
bd4cf0ed AS |
41 | |
42 | /* BPF program can access up to 512 bytes of stack space. */ | |
43 | #define MAX_BPF_STACK 512 | |
44 | ||
f8f6d679 DB |
45 | /* Helper macros for filter block array initializers. */ |
46 | ||
e430f34e | 47 | /* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ |
f8f6d679 | 48 | |
e430f34e | 49 | #define BPF_ALU64_REG(OP, DST, SRC) \ |
2695fb55 | 50 | ((struct bpf_insn) { \ |
f8f6d679 | 51 | .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \ |
e430f34e AS |
52 | .dst_reg = DST, \ |
53 | .src_reg = SRC, \ | |
f8f6d679 DB |
54 | .off = 0, \ |
55 | .imm = 0 }) | |
56 | ||
e430f34e | 57 | #define BPF_ALU32_REG(OP, DST, SRC) \ |
2695fb55 | 58 | ((struct bpf_insn) { \ |
f8f6d679 | 59 | .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ |
e430f34e AS |
60 | .dst_reg = DST, \ |
61 | .src_reg = SRC, \ | |
f8f6d679 DB |
62 | .off = 0, \ |
63 | .imm = 0 }) | |
64 | ||
e430f34e | 65 | /* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ |
f8f6d679 | 66 | |
e430f34e | 67 | #define BPF_ALU64_IMM(OP, DST, IMM) \ |
2695fb55 | 68 | ((struct bpf_insn) { \ |
f8f6d679 | 69 | .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \ |
e430f34e AS |
70 | .dst_reg = DST, \ |
71 | .src_reg = 0, \ | |
f8f6d679 DB |
72 | .off = 0, \ |
73 | .imm = IMM }) | |
74 | ||
e430f34e | 75 | #define BPF_ALU32_IMM(OP, DST, IMM) \ |
2695fb55 | 76 | ((struct bpf_insn) { \ |
f8f6d679 | 77 | .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ |
e430f34e AS |
78 | .dst_reg = DST, \ |
79 | .src_reg = 0, \ | |
f8f6d679 DB |
80 | .off = 0, \ |
81 | .imm = IMM }) | |
82 | ||
83 | /* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */ | |
84 | ||
e430f34e | 85 | #define BPF_ENDIAN(TYPE, DST, LEN) \ |
2695fb55 | 86 | ((struct bpf_insn) { \ |
f8f6d679 | 87 | .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \ |
e430f34e AS |
88 | .dst_reg = DST, \ |
89 | .src_reg = 0, \ | |
f8f6d679 DB |
90 | .off = 0, \ |
91 | .imm = LEN }) | |
92 | ||
e430f34e | 93 | /* Short form of mov, dst_reg = src_reg */ |
f8f6d679 | 94 | |
e430f34e | 95 | #define BPF_MOV64_REG(DST, SRC) \ |
2695fb55 | 96 | ((struct bpf_insn) { \ |
f8f6d679 | 97 | .code = BPF_ALU64 | BPF_MOV | BPF_X, \ |
e430f34e AS |
98 | .dst_reg = DST, \ |
99 | .src_reg = SRC, \ | |
f8f6d679 DB |
100 | .off = 0, \ |
101 | .imm = 0 }) | |
102 | ||
e430f34e | 103 | #define BPF_MOV32_REG(DST, SRC) \ |
2695fb55 | 104 | ((struct bpf_insn) { \ |
f8f6d679 | 105 | .code = BPF_ALU | BPF_MOV | BPF_X, \ |
e430f34e AS |
106 | .dst_reg = DST, \ |
107 | .src_reg = SRC, \ | |
f8f6d679 DB |
108 | .off = 0, \ |
109 | .imm = 0 }) | |
110 | ||
e430f34e | 111 | /* Short form of mov, dst_reg = imm32 */ |
f8f6d679 | 112 | |
e430f34e | 113 | #define BPF_MOV64_IMM(DST, IMM) \ |
2695fb55 | 114 | ((struct bpf_insn) { \ |
f8f6d679 | 115 | .code = BPF_ALU64 | BPF_MOV | BPF_K, \ |
e430f34e AS |
116 | .dst_reg = DST, \ |
117 | .src_reg = 0, \ | |
f8f6d679 DB |
118 | .off = 0, \ |
119 | .imm = IMM }) | |
120 | ||
e430f34e | 121 | #define BPF_MOV32_IMM(DST, IMM) \ |
2695fb55 | 122 | ((struct bpf_insn) { \ |
f8f6d679 | 123 | .code = BPF_ALU | BPF_MOV | BPF_K, \ |
e430f34e AS |
124 | .dst_reg = DST, \ |
125 | .src_reg = 0, \ | |
f8f6d679 DB |
126 | .off = 0, \ |
127 | .imm = IMM }) | |
128 | ||
02ab695b AS |
129 | /* BPF_LD_IMM64 macro encodes single 'load 64-bit immediate' insn */ |
130 | #define BPF_LD_IMM64(DST, IMM) \ | |
131 | BPF_LD_IMM64_RAW(DST, 0, IMM) | |
132 | ||
133 | #define BPF_LD_IMM64_RAW(DST, SRC, IMM) \ | |
134 | ((struct bpf_insn) { \ | |
135 | .code = BPF_LD | BPF_DW | BPF_IMM, \ | |
136 | .dst_reg = DST, \ | |
137 | .src_reg = SRC, \ | |
138 | .off = 0, \ | |
139 | .imm = (__u32) (IMM) }), \ | |
140 | ((struct bpf_insn) { \ | |
141 | .code = 0, /* zero is reserved opcode */ \ | |
142 | .dst_reg = 0, \ | |
143 | .src_reg = 0, \ | |
144 | .off = 0, \ | |
145 | .imm = ((__u64) (IMM)) >> 32 }) | |
146 | ||
e430f34e | 147 | /* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ |
f8f6d679 | 148 | |
e430f34e | 149 | #define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \ |
2695fb55 | 150 | ((struct bpf_insn) { \ |
f8f6d679 | 151 | .code = BPF_ALU64 | BPF_MOV | BPF_SRC(TYPE), \ |
e430f34e AS |
152 | .dst_reg = DST, \ |
153 | .src_reg = SRC, \ | |
f8f6d679 DB |
154 | .off = 0, \ |
155 | .imm = IMM }) | |
156 | ||
e430f34e | 157 | #define BPF_MOV32_RAW(TYPE, DST, SRC, IMM) \ |
2695fb55 | 158 | ((struct bpf_insn) { \ |
f8f6d679 | 159 | .code = BPF_ALU | BPF_MOV | BPF_SRC(TYPE), \ |
e430f34e AS |
160 | .dst_reg = DST, \ |
161 | .src_reg = SRC, \ | |
f8f6d679 DB |
162 | .off = 0, \ |
163 | .imm = IMM }) | |
164 | ||
e430f34e | 165 | /* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ |
f8f6d679 | 166 | |
e430f34e | 167 | #define BPF_LD_ABS(SIZE, IMM) \ |
2695fb55 | 168 | ((struct bpf_insn) { \ |
f8f6d679 | 169 | .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ |
e430f34e AS |
170 | .dst_reg = 0, \ |
171 | .src_reg = 0, \ | |
f8f6d679 | 172 | .off = 0, \ |
e430f34e | 173 | .imm = IMM }) |
f8f6d679 | 174 | |
e430f34e | 175 | /* Indirect packet access, R0 = *(uint *) (skb->data + src_reg + imm32) */ |
f8f6d679 | 176 | |
e430f34e | 177 | #define BPF_LD_IND(SIZE, SRC, IMM) \ |
2695fb55 | 178 | ((struct bpf_insn) { \ |
f8f6d679 | 179 | .code = BPF_LD | BPF_SIZE(SIZE) | BPF_IND, \ |
e430f34e AS |
180 | .dst_reg = 0, \ |
181 | .src_reg = SRC, \ | |
f8f6d679 | 182 | .off = 0, \ |
e430f34e | 183 | .imm = IMM }) |
f8f6d679 | 184 | |
e430f34e | 185 | /* Memory load, dst_reg = *(uint *) (src_reg + off16) */ |
f8f6d679 | 186 | |
e430f34e | 187 | #define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \ |
2695fb55 | 188 | ((struct bpf_insn) { \ |
f8f6d679 | 189 | .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ |
e430f34e AS |
190 | .dst_reg = DST, \ |
191 | .src_reg = SRC, \ | |
f8f6d679 DB |
192 | .off = OFF, \ |
193 | .imm = 0 }) | |
194 | ||
e430f34e AS |
195 | /* Memory store, *(uint *) (dst_reg + off16) = src_reg */ |
196 | ||
197 | #define BPF_STX_MEM(SIZE, DST, SRC, OFF) \ | |
2695fb55 | 198 | ((struct bpf_insn) { \ |
f8f6d679 | 199 | .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ |
e430f34e AS |
200 | .dst_reg = DST, \ |
201 | .src_reg = SRC, \ | |
f8f6d679 DB |
202 | .off = OFF, \ |
203 | .imm = 0 }) | |
204 | ||
e430f34e AS |
205 | /* Memory store, *(uint *) (dst_reg + off16) = imm32 */ |
206 | ||
207 | #define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ | |
2695fb55 | 208 | ((struct bpf_insn) { \ |
e430f34e AS |
209 | .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \ |
210 | .dst_reg = DST, \ | |
211 | .src_reg = 0, \ | |
212 | .off = OFF, \ | |
213 | .imm = IMM }) | |
214 | ||
215 | /* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */ | |
f8f6d679 | 216 | |
e430f34e | 217 | #define BPF_JMP_REG(OP, DST, SRC, OFF) \ |
2695fb55 | 218 | ((struct bpf_insn) { \ |
f8f6d679 | 219 | .code = BPF_JMP | BPF_OP(OP) | BPF_X, \ |
e430f34e AS |
220 | .dst_reg = DST, \ |
221 | .src_reg = SRC, \ | |
f8f6d679 DB |
222 | .off = OFF, \ |
223 | .imm = 0 }) | |
224 | ||
e430f34e | 225 | /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ |
f8f6d679 | 226 | |
e430f34e | 227 | #define BPF_JMP_IMM(OP, DST, IMM, OFF) \ |
2695fb55 | 228 | ((struct bpf_insn) { \ |
f8f6d679 | 229 | .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ |
e430f34e AS |
230 | .dst_reg = DST, \ |
231 | .src_reg = 0, \ | |
f8f6d679 DB |
232 | .off = OFF, \ |
233 | .imm = IMM }) | |
234 | ||
235 | /* Function call */ | |
236 | ||
237 | #define BPF_EMIT_CALL(FUNC) \ | |
2695fb55 | 238 | ((struct bpf_insn) { \ |
f8f6d679 | 239 | .code = BPF_JMP | BPF_CALL, \ |
e430f34e AS |
240 | .dst_reg = 0, \ |
241 | .src_reg = 0, \ | |
f8f6d679 DB |
242 | .off = 0, \ |
243 | .imm = ((FUNC) - __bpf_call_base) }) | |
244 | ||
245 | /* Raw code statement block */ | |
246 | ||
e430f34e | 247 | #define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ |
2695fb55 | 248 | ((struct bpf_insn) { \ |
f8f6d679 | 249 | .code = CODE, \ |
e430f34e AS |
250 | .dst_reg = DST, \ |
251 | .src_reg = SRC, \ | |
f8f6d679 DB |
252 | .off = OFF, \ |
253 | .imm = IMM }) | |
254 | ||
255 | /* Program exit */ | |
256 | ||
257 | #define BPF_EXIT_INSN() \ | |
2695fb55 | 258 | ((struct bpf_insn) { \ |
f8f6d679 | 259 | .code = BPF_JMP | BPF_EXIT, \ |
e430f34e AS |
260 | .dst_reg = 0, \ |
261 | .src_reg = 0, \ | |
f8f6d679 DB |
262 | .off = 0, \ |
263 | .imm = 0 }) | |
264 | ||
265 | #define bytes_to_bpf_size(bytes) \ | |
266 | ({ \ | |
267 | int bpf_size = -EINVAL; \ | |
268 | \ | |
269 | if (bytes == sizeof(u8)) \ | |
270 | bpf_size = BPF_B; \ | |
271 | else if (bytes == sizeof(u16)) \ | |
272 | bpf_size = BPF_H; \ | |
273 | else if (bytes == sizeof(u32)) \ | |
274 | bpf_size = BPF_W; \ | |
275 | else if (bytes == sizeof(u64)) \ | |
276 | bpf_size = BPF_DW; \ | |
277 | \ | |
278 | bpf_size; \ | |
279 | }) | |
9739eef1 | 280 | |
30743837 | 281 | /* Macro to invoke filter function. */ |
7ae457c1 AS |
282 | #define SK_RUN_FILTER(filter, ctx) \ |
283 | (*filter->prog->bpf_func)(ctx, filter->prog->insnsi) | |
bd4cf0ed | 284 | |
bd4cf0ed AS |
285 | #ifdef CONFIG_COMPAT |
286 | /* A struct sock_filter is architecture independent. */ | |
0c5fe1b4 WD |
287 | struct compat_sock_fprog { |
288 | u16 len; | |
bd4cf0ed | 289 | compat_uptr_t filter; /* struct sock_filter * */ |
0c5fe1b4 WD |
290 | }; |
291 | #endif | |
292 | ||
a3ea269b DB |
293 | struct sock_fprog_kern { |
294 | u16 len; | |
295 | struct sock_filter *filter; | |
296 | }; | |
297 | ||
738cbe72 DB |
298 | struct bpf_binary_header { |
299 | unsigned int pages; | |
300 | u8 image[]; | |
301 | }; | |
302 | ||
60a3b225 DB |
303 | struct bpf_work_struct { |
304 | struct bpf_prog *prog; | |
305 | struct work_struct work; | |
306 | }; | |
792d4b5c | 307 | |
7ae457c1 | 308 | struct bpf_prog { |
286aad3c DB |
309 | u16 pages; /* Number of allocated pages */ |
310 | bool jited; /* Is our filter JIT'ed? */ | |
311 | u32 len; /* Number of filter blocks */ | |
a3ea269b | 312 | struct sock_fprog_kern *orig_prog; /* Original BPF program */ |
60a3b225 | 313 | struct bpf_work_struct *work; /* Deferred free work struct */ |
0a14842f | 314 | unsigned int (*bpf_func)(const struct sk_buff *skb, |
2695fb55 | 315 | const struct bpf_insn *filter); |
60a3b225 | 316 | /* Instructions for interpreter */ |
d45ed4a4 | 317 | union { |
bd4cf0ed | 318 | struct sock_filter insns[0]; |
2695fb55 | 319 | struct bpf_insn insnsi[0]; |
d45ed4a4 | 320 | }; |
b715631f SH |
321 | }; |
322 | ||
7ae457c1 AS |
323 | struct sk_filter { |
324 | atomic_t refcnt; | |
325 | struct rcu_head rcu; | |
326 | struct bpf_prog *prog; | |
327 | }; | |
328 | ||
329 | #define BPF_PROG_RUN(filter, ctx) (*filter->bpf_func)(ctx, filter->insnsi) | |
330 | ||
331 | static inline unsigned int bpf_prog_size(unsigned int proglen) | |
b715631f | 332 | { |
7ae457c1 AS |
333 | return max(sizeof(struct bpf_prog), |
334 | offsetof(struct bpf_prog, insns[proglen])); | |
b715631f SH |
335 | } |
336 | ||
009937e7 | 337 | #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) |
a3ea269b | 338 | |
60a3b225 DB |
339 | #ifdef CONFIG_DEBUG_SET_MODULE_RONX |
340 | static inline void bpf_prog_lock_ro(struct bpf_prog *fp) | |
341 | { | |
342 | set_memory_ro((unsigned long)fp, fp->pages); | |
343 | } | |
344 | ||
345 | static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) | |
346 | { | |
347 | set_memory_rw((unsigned long)fp, fp->pages); | |
348 | } | |
349 | #else | |
350 | static inline void bpf_prog_lock_ro(struct bpf_prog *fp) | |
351 | { | |
352 | } | |
353 | ||
354 | static inline void bpf_prog_unlock_ro(struct bpf_prog *fp) | |
355 | { | |
356 | } | |
357 | #endif /* CONFIG_DEBUG_SET_MODULE_RONX */ | |
358 | ||
fbc907f0 | 359 | int sk_filter(struct sock *sk, struct sk_buff *skb); |
bd4cf0ed | 360 | |
7ae457c1 AS |
361 | void bpf_prog_select_runtime(struct bpf_prog *fp); |
362 | void bpf_prog_free(struct bpf_prog *fp); | |
bd4cf0ed | 363 | |
8fb575ca AS |
364 | int bpf_convert_filter(struct sock_filter *prog, int len, |
365 | struct bpf_insn *new_prog, int *new_len); | |
a3ea269b | 366 | |
60a3b225 DB |
367 | struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags); |
368 | struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size, | |
369 | gfp_t gfp_extra_flags); | |
370 | void __bpf_prog_free(struct bpf_prog *fp); | |
371 | ||
372 | static inline void bpf_prog_unlock_free(struct bpf_prog *fp) | |
373 | { | |
374 | bpf_prog_unlock_ro(fp); | |
375 | __bpf_prog_free(fp); | |
376 | } | |
377 | ||
7ae457c1 AS |
378 | int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog); |
379 | void bpf_prog_destroy(struct bpf_prog *fp); | |
a3ea269b | 380 | |
fbc907f0 DB |
381 | int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); |
382 | int sk_detach_filter(struct sock *sk); | |
a3ea269b | 383 | |
4df95ff4 | 384 | int bpf_check_classic(const struct sock_filter *filter, unsigned int flen); |
fbc907f0 DB |
385 | int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, |
386 | unsigned int len); | |
fbc907f0 | 387 | |
278571ba | 388 | bool sk_filter_charge(struct sock *sk, struct sk_filter *fp); |
fbc907f0 | 389 | void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp); |
0a14842f | 390 | |
62258278 | 391 | u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); |
7ae457c1 | 392 | void bpf_int_jit_compile(struct bpf_prog *fp); |
62258278 | 393 | |
b954d834 DB |
394 | #ifdef CONFIG_BPF_JIT |
395 | typedef void (*bpf_jit_fill_hole_t)(void *area, unsigned int size); | |
396 | ||
397 | struct bpf_binary_header * | |
398 | bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr, | |
399 | unsigned int alignment, | |
400 | bpf_jit_fill_hole_t bpf_fill_ill_insns); | |
401 | void bpf_jit_binary_free(struct bpf_binary_header *hdr); | |
402 | ||
403 | void bpf_jit_compile(struct bpf_prog *fp); | |
404 | void bpf_jit_free(struct bpf_prog *fp); | |
405 | ||
406 | static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen, | |
407 | u32 pass, void *image) | |
408 | { | |
409 | pr_err("flen=%u proglen=%u pass=%u image=%pK\n", | |
410 | flen, proglen, pass, image); | |
411 | if (image) | |
412 | print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET, | |
413 | 16, 1, image, proglen, false); | |
414 | } | |
415 | #else | |
416 | static inline void bpf_jit_compile(struct bpf_prog *fp) | |
417 | { | |
418 | } | |
419 | ||
420 | static inline void bpf_jit_free(struct bpf_prog *fp) | |
421 | { | |
422 | bpf_prog_unlock_free(fp); | |
423 | } | |
424 | #endif /* CONFIG_BPF_JIT */ | |
425 | ||
34805931 DB |
426 | #define BPF_ANC BIT(15) |
427 | ||
428 | static inline u16 bpf_anc_helper(const struct sock_filter *ftest) | |
429 | { | |
430 | BUG_ON(ftest->code & BPF_ANC); | |
431 | ||
432 | switch (ftest->code) { | |
433 | case BPF_LD | BPF_W | BPF_ABS: | |
434 | case BPF_LD | BPF_H | BPF_ABS: | |
435 | case BPF_LD | BPF_B | BPF_ABS: | |
436 | #define BPF_ANCILLARY(CODE) case SKF_AD_OFF + SKF_AD_##CODE: \ | |
437 | return BPF_ANC | SKF_AD_##CODE | |
438 | switch (ftest->k) { | |
439 | BPF_ANCILLARY(PROTOCOL); | |
440 | BPF_ANCILLARY(PKTTYPE); | |
441 | BPF_ANCILLARY(IFINDEX); | |
442 | BPF_ANCILLARY(NLATTR); | |
443 | BPF_ANCILLARY(NLATTR_NEST); | |
444 | BPF_ANCILLARY(MARK); | |
445 | BPF_ANCILLARY(QUEUE); | |
446 | BPF_ANCILLARY(HATYPE); | |
447 | BPF_ANCILLARY(RXHASH); | |
448 | BPF_ANCILLARY(CPU); | |
449 | BPF_ANCILLARY(ALU_XOR_X); | |
450 | BPF_ANCILLARY(VLAN_TAG); | |
451 | BPF_ANCILLARY(VLAN_TAG_PRESENT); | |
452 | BPF_ANCILLARY(PAY_OFFSET); | |
453 | BPF_ANCILLARY(RANDOM); | |
454 | } | |
455 | /* Fallthrough. */ | |
456 | default: | |
457 | return ftest->code; | |
458 | } | |
459 | } | |
460 | ||
9f12fbe6 ZSL |
461 | void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, |
462 | int k, unsigned int size); | |
463 | ||
464 | static inline void *bpf_load_pointer(const struct sk_buff *skb, int k, | |
465 | unsigned int size, void *buffer) | |
466 | { | |
467 | if (k >= 0) | |
468 | return skb_header_pointer(skb, k, size, buffer); | |
469 | ||
470 | return bpf_internal_load_pointer_neg_helper(skb, k, size); | |
471 | } | |
472 | ||
ea02f941 MS |
473 | static inline int bpf_tell_extensions(void) |
474 | { | |
37692299 | 475 | return SKF_AD_MAX; |
ea02f941 MS |
476 | } |
477 | ||
1da177e4 | 478 | #endif /* __LINUX_FILTER_H__ */ |