summaryrefslogtreecommitdiff
path: root/include/net/netfilter/nf_conntrack_bpf.h
blob: a61a93d1c6dc4e7251f139052a34fc6b1a93428e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _NF_CONNTRACK_BPF_H
#define _NF_CONNTRACK_BPF_H

#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/kconfig.h>
#include <linux/mutex.h>

#if (IS_BUILTIN(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) || \
    (IS_MODULE(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES))

extern int register_nf_conntrack_bpf(void);
extern void cleanup_nf_conntrack_bpf(void);

extern struct mutex nf_conn_btf_access_lock;
extern int (*nfct_bsa)(struct bpf_verifier_log *log, const struct btf *btf,
		       const struct btf_type *t, int off, int size,
		       enum bpf_access_type atype, u32 *next_btf_id,
		       enum bpf_type_flag *flag);

#else

static inline int register_nf_conntrack_bpf(void)
{
	return 0;
}

static inline void cleanup_nf_conntrack_bpf(void)
{
}

static inline int nf_conntrack_btf_struct_access(struct bpf_verifier_log *log,
						 const struct btf *btf,
						 const struct btf_type *t, int off,
						 int size, enum bpf_access_type atype,
						 u32 *next_btf_id,
						 enum bpf_type_flag *flag)
{
	return -EACCES;
}

#endif

#endif /* _NF_CONNTRACK_BPF_H */