Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _BPF_NETNS_H
3#define _BPF_NETNS_H
4
5#include <linux/mutex.h>
6#include <uapi/linux/bpf.h>
7
8enum netns_bpf_attach_type {
9 NETNS_BPF_INVALID = -1,
10 NETNS_BPF_FLOW_DISSECTOR = 0,
11 MAX_NETNS_BPF_ATTACH_TYPE
12};
13
14static inline enum netns_bpf_attach_type
15to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
16{
17 switch (attach_type) {
18 case BPF_FLOW_DISSECTOR:
19 return NETNS_BPF_FLOW_DISSECTOR;
20 default:
21 return NETNS_BPF_INVALID;
22 }
23}
24
25/* Protects updates to netns_bpf */
26extern struct mutex netns_bpf_mutex;
27
28union bpf_attr;
29struct bpf_prog;
30
31#ifdef CONFIG_NET
32int netns_bpf_prog_query(const union bpf_attr *attr,
33 union bpf_attr __user *uattr);
34int netns_bpf_prog_attach(const union bpf_attr *attr,
35 struct bpf_prog *prog);
36int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
37int netns_bpf_link_create(const union bpf_attr *attr,
38 struct bpf_prog *prog);
39#else
40static inline int netns_bpf_prog_query(const union bpf_attr *attr,
41 union bpf_attr __user *uattr)
42{
43 return -EOPNOTSUPP;
44}
45
46static inline int netns_bpf_prog_attach(const union bpf_attr *attr,
47 struct bpf_prog *prog)
48{
49 return -EOPNOTSUPP;
50}
51
52static inline int netns_bpf_prog_detach(const union bpf_attr *attr,
53 enum bpf_prog_type ptype)
54{
55 return -EOPNOTSUPP;
56}
57
58static inline int netns_bpf_link_create(const union bpf_attr *attr,
59 struct bpf_prog *prog)
60{
61 return -EOPNOTSUPP;
62}
63#endif
64
65#endif /* _BPF_NETNS_H */