1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/mutex.h>
6 #include <uapi/linux/bpf.h>
8 enum netns_bpf_attach_type {
9 NETNS_BPF_INVALID = -1,
10 NETNS_BPF_FLOW_DISSECTOR = 0,
12 MAX_NETNS_BPF_ATTACH_TYPE
15 static inline enum netns_bpf_attach_type
16 to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
18 switch (attach_type) {
19 case BPF_FLOW_DISSECTOR:
20 return NETNS_BPF_FLOW_DISSECTOR;
22 return NETNS_BPF_SK_LOOKUP;
24 return NETNS_BPF_INVALID;
28 /* Protects updates to netns_bpf */
29 extern struct mutex netns_bpf_mutex;
35 int netns_bpf_prog_query(const union bpf_attr *attr,
36 union bpf_attr __user *uattr);
37 int netns_bpf_prog_attach(const union bpf_attr *attr,
38 struct bpf_prog *prog);
39 int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
40 int netns_bpf_link_create(const union bpf_attr *attr,
41 struct bpf_prog *prog);
43 static inline int netns_bpf_prog_query(const union bpf_attr *attr,
44 union bpf_attr __user *uattr)
49 static inline int netns_bpf_prog_attach(const union bpf_attr *attr,
50 struct bpf_prog *prog)
55 static inline int netns_bpf_prog_detach(const union bpf_attr *attr,
56 enum bpf_prog_type ptype)
61 static inline int netns_bpf_link_create(const union bpf_attr *attr,
62 struct bpf_prog *prog)
68 #endif /* _BPF_NETNS_H */