Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 1 | #ifndef _XT_BPF_H |
| 2 | #define _XT_BPF_H |
| 3 | |
| 4 | #include <linux/filter.h> |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame^] | 5 | #include <linux/limits.h> |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 6 | #include <linux/types.h> |
| 7 | |
| 8 | #define XT_BPF_MAX_NUM_INSTR 64 |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame^] | 9 | #define XT_BPF_PATH_MAX (XT_BPF_MAX_NUM_INSTR * sizeof(struct sock_filter)) |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 10 | |
Christopher Ferris | 7c0b639 | 2015-01-23 15:34:26 -0800 | [diff] [blame] | 11 | struct bpf_prog; |
| 12 | |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 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 */ |
Christopher Ferris | 7c0b639 | 2015-01-23 15:34:26 -0800 | [diff] [blame] | 18 | struct bpf_prog *filter __attribute__((aligned(8))); |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 19 | }; |
| 20 | |
Christopher Ferris | 2fd4b3c | 2017-02-21 12:32:08 -0800 | [diff] [blame^] | 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 | |
Ben Cheng | 30692c6 | 2013-10-15 18:26:18 -0700 | [diff] [blame] | 40 | #endif /*_XT_BPF_H */ |