filter.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. * Linux Socket Filter Data Structures
  3. */
  4. #ifndef __LINUX_FILTER_H__
  5. #define __LINUX_FILTER_H__
  6. #include <stdarg.h>
  7. #include <linux/atomic.h>
  8. #include <linux/compat.h>
  9. #include <linux/skbuff.h>
  10. #include <linux/linkage.h>
  11. #include <linux/printk.h>
  12. #include <linux/workqueue.h>
  13. #include <linux/sched.h>
  14. #include <net/sch_generic.h>
  15. #include <asm/cacheflush.h>
  16. #include <uapi/linux/filter.h>
  17. #include <uapi/linux/bpf.h>
  18. struct sk_buff;
  19. struct sock;
  20. struct seccomp_data;
  21. struct bpf_prog_aux;
  22. /* ArgX, context and stack frame pointer register positions. Note,
  23. * Arg1, Arg2, Arg3, etc are used as argument mappings of function
  24. * calls in BPF_CALL instruction.
  25. */
  26. #define BPF_REG_ARG1 BPF_REG_1
  27. #define BPF_REG_ARG2 BPF_REG_2
  28. #define BPF_REG_ARG3 BPF_REG_3
  29. #define BPF_REG_ARG4 BPF_REG_4
  30. #define BPF_REG_ARG5 BPF_REG_5
  31. #define BPF_REG_CTX BPF_REG_6
  32. #define BPF_REG_FP BPF_REG_10
  33. /* Additional register mappings for converted user programs. */
  34. #define BPF_REG_A BPF_REG_0
  35. #define BPF_REG_X BPF_REG_7
  36. #define BPF_REG_TMP BPF_REG_8
  37. /* BPF program can access up to 512 bytes of stack space. */
  38. #define MAX_BPF_STACK 512
  39. /* Helper macros for filter block array initializers. */
  40. /* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
  41. #define BPF_ALU64_REG(OP, DST, SRC) \
  42. ((struct bpf_insn) { \
  43. .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \
  44. .dst_reg = DST, \
  45. .src_reg = SRC, \
  46. .off = 0, \
  47. .imm = 0 })
  48. #define BPF_ALU32_REG(OP, DST, SRC) \
  49. ((struct bpf_insn) { \
  50. .code = BPF_ALU | BPF_OP(OP) | BPF_X, \
  51. .dst_reg = DST, \
  52. .src_reg = SRC, \
  53. .off = 0, \
  54. .imm = 0 })
  55. /* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */
  56. #define BPF_ALU64_IMM(OP, DST, IMM) \
  57. ((struct bpf_insn) { \
  58. .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \
  59. .dst_reg = DST, \
  60. .src_reg = 0, \
  61. .off = 0, \
  62. .imm = IMM })
  63. #define BPF_ALU32_IMM(OP, DST, IMM) \
  64. ((struct bpf_insn) { \
  65. .code = BPF_ALU | BPF_OP(OP) | BPF_K, \
  66. .dst_reg = DST, \
  67. .src_reg = 0, \
  68. .off = 0, \
  69. .imm = IMM })
  70. /* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */
  71. #define BPF_ENDIAN(TYPE, DST, LEN) \
  72. ((struct bpf_insn) { \
  73. .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \
  74. .dst_reg = DST, \
  75. .src_reg = 0, \
  76. .off = 0, \
  77. .imm = LEN })
  78. /* Short form of mov, dst_reg = src_reg */
  79. #define BPF_MOV64_REG(DST, SRC) \
  80. ((struct bpf_insn) { \
  81. .code = BPF_ALU64 | BPF_MOV | BPF_X, \
  82. .dst_reg = DST, \
  83. .src_reg = SRC, \
  84. .off = 0, \
  85. .imm = 0 })
  86. #define BPF_MOV32_REG(DST, SRC) \
  87. ((struct bpf_insn) { \
  88. .code = BPF_ALU | BPF_MOV | BPF_X, \
  89. .dst_reg = DST, \
  90. .src_reg = SRC, \
  91. .off = 0, \
  92. .imm = 0 })
  93. /* Short form of mov, dst_reg = imm32 */
  94. #define BPF_MOV64_IMM(DST, IMM) \
  95. ((struct bpf_insn) { \
  96. .code = BPF_ALU64 | BPF_MOV | BPF_K, \
  97. .dst_reg = DST, \
  98. .src_reg = 0, \
  99. .off = 0, \
  100. .imm = IMM })
  101. #define BPF_MOV32_IMM(DST, IMM) \
  102. ((struct bpf_insn) { \
  103. .code = BPF_ALU | BPF_MOV | BPF_K, \
  104. .dst_reg = DST, \
  105. .src_reg = 0, \
  106. .off = 0, \
  107. .imm = IMM })
  108. /* BPF_LD_IMM64 macro encodes single 'load 64-bit immediate' insn */
  109. #define BPF_LD_IMM64(DST, IMM) \
  110. BPF_LD_IMM64_RAW(DST, 0, IMM)
  111. #define BPF_LD_IMM64_RAW(DST, SRC, IMM) \
  112. ((struct bpf_insn) { \
  113. .code = BPF_LD | BPF_DW | BPF_IMM, \
  114. .dst_reg = DST, \
  115. .src_reg = SRC, \
  116. .off = 0, \
  117. .imm = (__u32) (IMM) }), \
  118. ((struct bpf_insn) { \
  119. .code = 0, /* zero is reserved opcode */ \
  120. .dst_reg = 0, \
  121. .src_reg = 0, \
  122. .off = 0, \
  123. .imm = ((__u64) (IMM)) >> 32 })
  124. /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
  125. #define BPF_LD_MAP_FD(DST, MAP_FD) \
  126. BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD)
  127. /* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */
  128. #define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \
  129. ((struct bpf_insn) { \
  130. .code = BPF_ALU64 | BPF_MOV | BPF_SRC(TYPE), \
  131. .dst_reg = DST, \
  132. .src_reg = SRC, \
  133. .off = 0, \
  134. .imm = IMM })
  135. #define BPF_MOV32_RAW(TYPE, DST, SRC, IMM) \
  136. ((struct bpf_insn) { \
  137. .code = BPF_ALU | BPF_MOV | BPF_SRC(TYPE), \
  138. .dst_reg = DST, \
  139. .src_reg = SRC, \
  140. .off = 0, \
  141. .imm = IMM })
  142. /* Direct packet access, R0 = *(uint *) (skb->data + imm32) */
  143. #define BPF_LD_ABS(SIZE, IMM) \
  144. ((struct bpf_insn) { \
  145. .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \
  146. .dst_reg = 0, \
  147. .src_reg = 0, \
  148. .off = 0, \
  149. .imm = IMM })
  150. /* Indirect packet access, R0 = *(uint *) (skb->data + src_reg + imm32) */
  151. #define BPF_LD_IND(SIZE, SRC, IMM) \
  152. ((struct bpf_insn) { \
  153. .code = BPF_LD | BPF_SIZE(SIZE) | BPF_IND, \
  154. .dst_reg = 0, \
  155. .src_reg = SRC, \
  156. .off = 0, \
  157. .imm = IMM })
  158. /* Memory load, dst_reg = *(uint *) (src_reg + off16) */
  159. #define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \
  160. ((struct bpf_insn) { \
  161. .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \
  162. .dst_reg = DST, \
  163. .src_reg = SRC, \
  164. .off = OFF, \
  165. .imm = 0 })
  166. /* Memory store, *(uint *) (dst_reg + off16) = src_reg */
  167. #define BPF_STX_MEM(SIZE, DST, SRC, OFF) \
  168. ((struct bpf_insn) { \
  169. .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \
  170. .dst_reg = DST, \
  171. .src_reg = SRC, \
  172. .off = OFF, \
  173. .imm = 0 })
  174. /* Atomic memory add, *(uint *)(dst_reg + off16) += src_reg */
  175. #define BPF_STX_XADD(SIZE, DST, SRC, OFF) \
  176. ((struct bpf_insn) { \
  177. .code = BPF_STX | BPF_SIZE(SIZE) | BPF_XADD, \
  178. .dst_reg = DST, \
  179. .src_reg = SRC, \
  180. .off = OFF, \
  181. .imm = 0 })
  182. /* Memory store, *(uint *) (dst_reg + off16) = imm32 */
  183. #define BPF_ST_MEM(SIZE, DST, OFF, IMM) \
  184. ((struct bpf_insn) { \
  185. .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \
  186. .dst_reg = DST, \
  187. .src_reg = 0, \
  188. .off = OFF, \
  189. .imm = IMM })
  190. /* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */
  191. #define BPF_JMP_REG(OP, DST, SRC, OFF) \
  192. ((struct bpf_insn) { \
  193. .code = BPF_JMP | BPF_OP(OP) | BPF_X, \
  194. .dst_reg = DST, \
  195. .src_reg = SRC, \
  196. .off = OFF, \
  197. .imm = 0 })
  198. /* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */
  199. #define BPF_JMP_IMM(OP, DST, IMM, OFF) \
  200. ((struct bpf_insn) { \
  201. .code = BPF_JMP | BPF_OP(OP) | BPF_K, \
  202. .dst_reg = DST, \
  203. .src_reg = 0, \
  204. .off = OFF, \
  205. .imm = IMM })
  206. /* Function call */
  207. #define BPF_EMIT_CALL(FUNC) \
  208. ((struct bpf_insn) { \
  209. .code = BPF_JMP | BPF_CALL, \
  210. .dst_reg = 0, \
  211. .src_reg = 0, \
  212. .off = 0, \
  213. .imm = ((FUNC) - __bpf_call_base) })
  214. /* Raw code statement block */
  215. #define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \
  216. ((struct bpf_insn) { \
  217. .code = CODE, \
  218. .dst_reg = DST, \
  219. .src_reg = SRC, \
  220. .off = OFF, \
  221. .imm = IMM })
  222. /* Program exit */
  223. #define BPF_EXIT_INSN() \
  224. ((struct bpf_insn) { \
  225. .code = BPF_JMP | BPF_EXIT, \
  226. .dst_reg = 0, \
  227. .src_reg = 0, \
  228. .off = 0, \
  229. .imm = 0 })
  230. /* Internal classic blocks for direct assignment */
  231. #define __BPF_STMT(CODE, K) \
  232. ((struct sock_filter) BPF_STMT(CODE, K))
  233. #define __BPF_JUMP(CODE, K, JT, JF) \
  234. ((struct sock_filter) BPF_JUMP(CODE, K, JT, JF))
  235. #define bytes_to_bpf_size(bytes) \
  236. ({ \
  237. int bpf_size = -EINVAL; \
  238. \
  239. if (bytes == sizeof(u8)) \
  240. bpf_size = BPF_B; \
  241. else if (bytes == sizeof(u16)) \
  242. bpf_size = BPF_H; \
  243. else if (bytes == sizeof(u32)) \
  244. bpf_size = BPF_W; \
  245. else if (bytes == sizeof(u64)) \
  246. bpf_size = BPF_DW; \
  247. \
  248. bpf_size; \
  249. })
  250. #ifdef CONFIG_COMPAT
  251. /* A struct sock_filter is architecture independent. */
  252. struct compat_sock_fprog {
  253. u16 len;
  254. compat_uptr_t filter; /* struct sock_filter * */
  255. };
  256. #endif
  257. struct sock_fprog_kern {
  258. u16 len;
  259. struct sock_filter *filter;
  260. };
  261. struct bpf_binary_header {
  262. unsigned int pages;
  263. u8 image[];
  264. };
  265. struct bpf_prog {
  266. u16 pages; /* Number of allocated pages */
  267. kmemcheck_bitfield_begin(meta);
  268. u16 jited:1, /* Is our filter JIT'ed? */
  269. gpl_compatible:1, /* Is filter GPL compatible? */
  270. cb_access:1, /* Is control block accessed? */
  271. dst_needed:1; /* Do we need dst entry? */
  272. kmemcheck_bitfield_end(meta);
  273. u32 len; /* Number of filter blocks */
  274. enum bpf_prog_type type; /* Type of BPF program */
  275. struct bpf_prog_aux *aux; /* Auxiliary fields */
  276. struct sock_fprog_kern *orig_prog; /* Original BPF program */
  277. unsigned int (*bpf_func)(const struct sk_buff *skb,
  278. const struct bpf_insn *filter);
  279. /* Instructions for interpreter */
  280. union {
  281. struct sock_filter insns[0];
  282. struct bpf_insn insnsi[0];
  283. };
  284. };
  285. struct sk_filter {
  286. atomic_t refcnt;
  287. struct rcu_head rcu;
  288. struct bpf_prog *prog;
  289. };
  290. #define BPF_PROG_RUN(filter, ctx) (*filter->bpf_func)(ctx, filter->insnsi)
  291. #define BPF_SKB_CB_LEN QDISC_CB_PRIV_LEN
  292. struct bpf_skb_data_end {
  293. struct qdisc_skb_cb qdisc_cb;
  294. void *data_end;
  295. };
  296. /* compute the linear packet data range [data, data_end) which
  297. * will be accessed by cls_bpf and act_bpf programs
  298. */
  299. static inline void bpf_compute_data_end(struct sk_buff *skb)
  300. {
  301. struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb;
  302. BUILD_BUG_ON(sizeof(*cb) > FIELD_SIZEOF(struct sk_buff, cb));
  303. cb->data_end = skb->data + skb_headlen(skb);
  304. }
  305. static inline u8 *bpf_skb_cb(struct sk_buff *skb)
  306. {
  307. /* eBPF programs may read/write skb->cb[] area to transfer meta
  308. * data between tail calls. Since this also needs to work with
  309. * tc, that scratch memory is mapped to qdisc_skb_cb's data area.
  310. *
  311. * In some socket filter cases, the cb unfortunately needs to be
  312. * saved/restored so that protocol specific skb->cb[] data won't
  313. * be lost. In any case, due to unpriviledged eBPF programs
  314. * attached to sockets, we need to clear the bpf_skb_cb() area
  315. * to not leak previous contents to user space.
  316. */
  317. BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) != BPF_SKB_CB_LEN);
  318. BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) !=
  319. FIELD_SIZEOF(struct qdisc_skb_cb, data));
  320. return qdisc_skb_cb(skb)->data;
  321. }
  322. static inline u32 bpf_prog_run_save_cb(const struct bpf_prog *prog,
  323. struct sk_buff *skb)
  324. {
  325. u8 *cb_data = bpf_skb_cb(skb);
  326. u8 cb_saved[BPF_SKB_CB_LEN];
  327. u32 res;
  328. if (unlikely(prog->cb_access)) {
  329. memcpy(cb_saved, cb_data, sizeof(cb_saved));
  330. memset(cb_data, 0, sizeof(cb_saved));
  331. }
  332. res = BPF_PROG_RUN(prog, skb);
  333. if (unlikely(prog->cb_access))
  334. memcpy(cb_data, cb_saved, sizeof(cb_saved));
  335. return res;
  336. }
  337. static inline u32 bpf_prog_run_clear_cb(const struct bpf_prog *prog,
  338. struct sk_buff *skb)
  339. {
  340. u8 *cb_data = bpf_skb_cb(skb);
  341. if (unlikely(prog->cb_access))
  342. memset(cb_data, 0, BPF_SKB_CB_LEN);
  343. return BPF_PROG_RUN(prog, skb);
  344. }
  345. static inline unsigned int bpf_prog_size(unsigned int proglen)
  346. {
  347. return max(sizeof(struct bpf_prog),
  348. offsetof(struct bpf_prog, insns[proglen]));
  349. }
  350. static inline bool bpf_prog_was_classic(const struct bpf_prog *prog)
  351. {
  352. /* When classic BPF programs have been loaded and the arch
  353. * does not have a classic BPF JIT (anymore), they have been
  354. * converted via bpf_migrate_filter() to eBPF and thus always
  355. * have an unspec program type.
  356. */
  357. return prog->type == BPF_PROG_TYPE_UNSPEC;
  358. }
  359. #define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
  360. #ifdef CONFIG_DEBUG_SET_MODULE_RONX
  361. static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
  362. {
  363. set_memory_ro((unsigned long)fp, fp->pages);
  364. }
  365. static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
  366. {
  367. set_memory_rw((unsigned long)fp, fp->pages);
  368. }
  369. #else
  370. static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
  371. {
  372. }
  373. static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
  374. {
  375. }
  376. #endif /* CONFIG_DEBUG_SET_MODULE_RONX */
  377. int sk_filter(struct sock *sk, struct sk_buff *skb);
  378. struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err);
  379. void bpf_prog_free(struct bpf_prog *fp);
  380. struct bpf_prog *bpf_prog_alloc(unsigned int size, gfp_t gfp_extra_flags);
  381. struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
  382. gfp_t gfp_extra_flags);
  383. void __bpf_prog_free(struct bpf_prog *fp);
  384. static inline void bpf_prog_unlock_free(struct bpf_prog *fp)
  385. {
  386. bpf_prog_unlock_ro(fp);
  387. __bpf_prog_free(fp);
  388. }
  389. typedef int (*bpf_aux_classic_check_t)(struct sock_filter *filter,
  390. unsigned int flen);
  391. int bpf_prog_create(struct bpf_prog **pfp, struct sock_fprog_kern *fprog);
  392. int bpf_prog_create_from_user(struct bpf_prog **pfp, struct sock_fprog *fprog,
  393. bpf_aux_classic_check_t trans, bool save_orig);
  394. void bpf_prog_destroy(struct bpf_prog *fp);
  395. int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
  396. int sk_attach_bpf(u32 ufd, struct sock *sk);
  397. int sk_reuseport_attach_filter(struct sock_fprog *fprog, struct sock *sk);
  398. int sk_reuseport_attach_bpf(u32 ufd, struct sock *sk);
  399. int sk_detach_filter(struct sock *sk);
  400. int sk_get_filter(struct sock *sk, struct sock_filter __user *filter,
  401. unsigned int len);
  402. bool sk_filter_charge(struct sock *sk, struct sk_filter *fp);
  403. void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp);
  404. u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
  405. struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog);
  406. bool bpf_helper_changes_skb_data(void *func);
  407. struct bpf_prog *bpf_patch_insn_single(struct bpf_prog *prog, u32 off,
  408. const struct bpf_insn *patch, u32 len);
  409. #ifdef CONFIG_BPF_JIT
  410. extern int bpf_jit_enable;
  411. typedef void (*bpf_jit_fill_hole_t)(void *area, unsigned int size);
  412. struct bpf_binary_header *
  413. bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
  414. unsigned int alignment,
  415. bpf_jit_fill_hole_t bpf_fill_ill_insns);
  416. void bpf_jit_binary_free(struct bpf_binary_header *hdr);
  417. void bpf_jit_compile(struct bpf_prog *fp);
  418. void bpf_jit_free(struct bpf_prog *fp);
  419. static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
  420. u32 pass, void *image)
  421. {
  422. pr_err("flen=%u proglen=%u pass=%u image=%pK from=%s pid=%d\n", flen,
  423. proglen, pass, image, current->comm, task_pid_nr(current));
  424. if (image)
  425. print_hex_dump(KERN_ERR, "JIT code: ", DUMP_PREFIX_OFFSET,
  426. 16, 1, image, proglen, false);
  427. }
  428. #else
  429. static inline void bpf_jit_compile(struct bpf_prog *fp)
  430. {
  431. }
  432. static inline void bpf_jit_free(struct bpf_prog *fp)
  433. {
  434. bpf_prog_unlock_free(fp);
  435. }
  436. #endif /* CONFIG_BPF_JIT */
  437. #define BPF_ANC BIT(15)
  438. static inline bool bpf_needs_clear_a(const struct sock_filter *first)
  439. {
  440. switch (first->code) {
  441. case BPF_RET | BPF_K:
  442. case BPF_LD | BPF_W | BPF_LEN:
  443. return false;
  444. case BPF_LD | BPF_W | BPF_ABS:
  445. case BPF_LD | BPF_H | BPF_ABS:
  446. case BPF_LD | BPF_B | BPF_ABS:
  447. if (first->k == SKF_AD_OFF + SKF_AD_ALU_XOR_X)
  448. return true;
  449. return false;
  450. default:
  451. return true;
  452. }
  453. }
  454. static inline u16 bpf_anc_helper(const struct sock_filter *ftest)
  455. {
  456. BUG_ON(ftest->code & BPF_ANC);
  457. switch (ftest->code) {
  458. case BPF_LD | BPF_W | BPF_ABS:
  459. case BPF_LD | BPF_H | BPF_ABS:
  460. case BPF_LD | BPF_B | BPF_ABS:
  461. #define BPF_ANCILLARY(CODE) case SKF_AD_OFF + SKF_AD_##CODE: \
  462. return BPF_ANC | SKF_AD_##CODE
  463. switch (ftest->k) {
  464. BPF_ANCILLARY(PROTOCOL);
  465. BPF_ANCILLARY(PKTTYPE);
  466. BPF_ANCILLARY(IFINDEX);
  467. BPF_ANCILLARY(NLATTR);
  468. BPF_ANCILLARY(NLATTR_NEST);
  469. BPF_ANCILLARY(MARK);
  470. BPF_ANCILLARY(QUEUE);
  471. BPF_ANCILLARY(HATYPE);
  472. BPF_ANCILLARY(RXHASH);
  473. BPF_ANCILLARY(CPU);
  474. BPF_ANCILLARY(ALU_XOR_X);
  475. BPF_ANCILLARY(VLAN_TAG);
  476. BPF_ANCILLARY(VLAN_TAG_PRESENT);
  477. BPF_ANCILLARY(PAY_OFFSET);
  478. BPF_ANCILLARY(RANDOM);
  479. BPF_ANCILLARY(VLAN_TPID);
  480. }
  481. /* Fallthrough. */
  482. default:
  483. return ftest->code;
  484. }
  485. }
  486. void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb,
  487. int k, unsigned int size);
  488. static inline void *bpf_load_pointer(const struct sk_buff *skb, int k,
  489. unsigned int size, void *buffer)
  490. {
  491. if (k >= 0)
  492. return skb_header_pointer(skb, k, size, buffer);
  493. return bpf_internal_load_pointer_neg_helper(skb, k, size);
  494. }
  495. static inline int bpf_tell_extensions(void)
  496. {
  497. return SKF_AD_MAX;
  498. }
  499. #endif /* __LINUX_FILTER_H__ */