at v5.13 1.6 kB view raw
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 NETNS_BPF_SK_LOOKUP, 12 MAX_NETNS_BPF_ATTACH_TYPE 13}; 14 15static inline enum netns_bpf_attach_type 16to_netns_bpf_attach_type(enum bpf_attach_type attach_type) 17{ 18 switch (attach_type) { 19 case BPF_FLOW_DISSECTOR: 20 return NETNS_BPF_FLOW_DISSECTOR; 21 case BPF_SK_LOOKUP: 22 return NETNS_BPF_SK_LOOKUP; 23 default: 24 return NETNS_BPF_INVALID; 25 } 26} 27 28/* Protects updates to netns_bpf */ 29extern struct mutex netns_bpf_mutex; 30 31union bpf_attr; 32struct bpf_prog; 33 34#ifdef CONFIG_NET 35int netns_bpf_prog_query(const union bpf_attr *attr, 36 union bpf_attr __user *uattr); 37int netns_bpf_prog_attach(const union bpf_attr *attr, 38 struct bpf_prog *prog); 39int netns_bpf_prog_detach(const union bpf_attr *attr, enum bpf_prog_type ptype); 40int netns_bpf_link_create(const union bpf_attr *attr, 41 struct bpf_prog *prog); 42#else 43static inline int netns_bpf_prog_query(const union bpf_attr *attr, 44 union bpf_attr __user *uattr) 45{ 46 return -EOPNOTSUPP; 47} 48 49static inline int netns_bpf_prog_attach(const union bpf_attr *attr, 50 struct bpf_prog *prog) 51{ 52 return -EOPNOTSUPP; 53} 54 55static inline int netns_bpf_prog_detach(const union bpf_attr *attr, 56 enum bpf_prog_type ptype) 57{ 58 return -EOPNOTSUPP; 59} 60 61static inline int netns_bpf_link_create(const union bpf_attr *attr, 62 struct bpf_prog *prog) 63{ 64 return -EOPNOTSUPP; 65} 66#endif 67 68#endif /* _BPF_NETNS_H */