• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _XT_BPF_H
2 #define _XT_BPF_H
3 
4 #include <linux/filter.h>
5 #include <linux/limits.h>
6 #include <linux/types.h>
7 
8 #define XT_BPF_MAX_NUM_INSTR	64
9 #define XT_BPF_PATH_MAX		(XT_BPF_MAX_NUM_INSTR * sizeof(struct sock_filter))
10 
11 struct bpf_prog;
12 
13 struct xt_bpf_info {
14 	__u16 bpf_program_num_elem;
15 	struct sock_filter bpf_program[XT_BPF_MAX_NUM_INSTR];
16 
17 	/* only used in the kernel */
18 	struct bpf_prog *filter __attribute__((aligned(8)));
19 };
20 
21 enum xt_bpf_modes {
22 	XT_BPF_MODE_BYTECODE,
23 	XT_BPF_MODE_FD_PINNED,
24 	XT_BPF_MODE_FD_ELF,
25 };
26 
27 struct xt_bpf_info_v1 {
28 	__u16 mode;
29 	__u16 bpf_program_num_elem;
30 	__s32 fd;
31 	union {
32 		struct sock_filter bpf_program[XT_BPF_MAX_NUM_INSTR];
33 		char path[XT_BPF_PATH_MAX];
34 	};
35 
36 	/* only used in the kernel */
37 	struct bpf_prog *filter __attribute__((aligned(8)));
38 };
39 
40 #endif /*_XT_BPF_H */
41