smp, irq_work: Continue smp_call_function*() and irq_work*() integration
[sfrench/cifs-2.6.git] / include / linux / bpf-netns.h
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
8 enum netns_bpf_attach_type {
9         NETNS_BPF_INVALID = -1,
10         NETNS_BPF_FLOW_DISSECTOR = 0,
11         MAX_NETNS_BPF_ATTACH_TYPE
12 };
13
14 static inline enum netns_bpf_attach_type
15 to_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 */
26 extern struct mutex netns_bpf_mutex;
27
28 union bpf_attr;
29 struct bpf_prog;
30
31 #ifdef CONFIG_NET
32 int netns_bpf_prog_query(const union bpf_attr *attr,
33                          union bpf_attr __user *uattr);
34 int netns_bpf_prog_attach(const union bpf_attr *attr,
35                           struct bpf_prog *prog);
36 int netns_bpf_prog_detach(const union bpf_attr *attr);
37 int netns_bpf_link_create(const union bpf_attr *attr,
38                           struct bpf_prog *prog);
39 #else
40 static inline int netns_bpf_prog_query(const union bpf_attr *attr,
41                                        union bpf_attr __user *uattr)
42 {
43         return -EOPNOTSUPP;
44 }
45
46 static inline int netns_bpf_prog_attach(const union bpf_attr *attr,
47                                         struct bpf_prog *prog)
48 {
49         return -EOPNOTSUPP;
50 }
51
52 static inline int netns_bpf_prog_detach(const union bpf_attr *attr)
53 {
54         return -EOPNOTSUPP;
55 }
56
57 static inline int netns_bpf_link_create(const union bpf_attr *attr,
58                                         struct bpf_prog *prog)
59 {
60         return -EOPNOTSUPP;
61 }
62 #endif
63
64 #endif /* _BPF_NETNS_H */