0001
0002 #ifndef _BPF_NETNS_H
0003 #define _BPF_NETNS_H
0004
0005 #include <linux/mutex.h>
0006 #include <net/netns/bpf.h>
0007 #include <uapi/linux/bpf.h>
0008
0009 static inline enum netns_bpf_attach_type
0010 to_netns_bpf_attach_type(enum bpf_attach_type attach_type)
0011 {
0012 switch (attach_type) {
0013 case BPF_FLOW_DISSECTOR:
0014 return NETNS_BPF_FLOW_DISSECTOR;
0015 case BPF_SK_LOOKUP:
0016 return NETNS_BPF_SK_LOOKUP;
0017 default:
0018 return NETNS_BPF_INVALID;
0019 }
0020 }
0021
0022
0023 extern struct mutex netns_bpf_mutex;
0024
0025 union bpf_attr;
0026 struct bpf_prog;
0027
0028 #ifdef CONFIG_NET
0029 int netns_bpf_prog_query(const union bpf_attr *attr,
0030 union bpf_attr __user *uattr);
0031 int netns_bpf_prog_attach(const union bpf_attr *attr,
0032 struct bpf_prog *prog);
0033 int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype);
0034 int netns_bpf_link_create(const union bpf_attr *attr,
0035 struct bpf_prog *prog);
0036 #else
0037 static inline int netns_bpf_prog_query(const union bpf_attr *attr,
0038 union bpf_attr __user *uattr)
0039 {
0040 return -EOPNOTSUPP;
0041 }
0042
0043 static inline int netns_bpf_prog_attach(const union bpf_attr *attr,
0044 struct bpf_prog *prog)
0045 {
0046 return -EOPNOTSUPP;
0047 }
0048
0049 static inline int netns_bpf_prog_detach(const union bpf_attr *attr,
0050 enum bpf_prog_type ptype)
0051 {
0052 return -EOPNOTSUPP;
0053 }
0054
0055 static inline int netns_bpf_link_create(const union bpf_attr *attr,
0056 struct bpf_prog *prog)
0057 {
0058 return -EOPNOTSUPP;
0059 }
0060 #endif
0061
0062 #endif