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