#include <linux/bpf.h>
#include <net/xdp.h>
#include <linux/filter.h>
#include <trace/events/xdp.h>
#include <linux/btf_ids.h>
#define DEV_CREATE_FLAG_MASK …
struct xdp_dev_bulk_queue { … };
struct bpf_dtab_netdev { … };
struct bpf_dtab { … };
static DEFINE_SPINLOCK(dev_map_lock);
static LIST_HEAD(dev_map_list);
static struct hlist_head *dev_map_create_hash(unsigned int entries,
int numa_node)
{ … }
static inline struct hlist_head *dev_map_index_hash(struct bpf_dtab *dtab,
int idx)
{ … }
static int dev_map_alloc_check(union bpf_attr *attr)
{ … }
static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
{ … }
static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
{ … }
static void dev_map_free(struct bpf_map *map)
{ … }
static int dev_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
{ … }
static void *__dev_map_hash_lookup_elem(struct bpf_map *map, u32 key)
{ … }
static int dev_map_hash_get_next_key(struct bpf_map *map, void *key,
void *next_key)
{ … }
static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,
struct xdp_frame **frames, int n,
struct net_device *dev)
{ … }
static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
{ … }
void __dev_flush(struct list_head *flush_list)
{ … }
static void *__dev_map_lookup_elem(struct bpf_map *map, u32 key)
{ … }
static void bq_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
struct net_device *dev_rx, struct bpf_prog *xdp_prog)
{ … }
static inline int __xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
struct net_device *dev_rx,
struct bpf_prog *xdp_prog)
{ … }
static u32 dev_map_bpf_prog_run_skb(struct sk_buff *skb, struct bpf_dtab_netdev *dst)
{ … }
int dev_xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf,
struct net_device *dev_rx)
{ … }
int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_frame *xdpf,
struct net_device *dev_rx)
{ … }
static bool is_valid_dst(struct bpf_dtab_netdev *obj, struct xdp_frame *xdpf)
{ … }
static int dev_map_enqueue_clone(struct bpf_dtab_netdev *obj,
struct net_device *dev_rx,
struct xdp_frame *xdpf)
{ … }
static inline bool is_ifindex_excluded(int *excluded, int num_excluded, int ifindex)
{ … }
static int get_upper_ifindexes(struct net_device *dev, int *indexes)
{ … }
int dev_map_enqueue_multi(struct xdp_frame *xdpf, struct net_device *dev_rx,
struct bpf_map *map, bool exclude_ingress)
{ … }
int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,
struct bpf_prog *xdp_prog)
{ … }
static int dev_map_redirect_clone(struct bpf_dtab_netdev *dst,
struct sk_buff *skb,
struct bpf_prog *xdp_prog)
{ … }
int dev_map_redirect_multi(struct net_device *dev, struct sk_buff *skb,
struct bpf_prog *xdp_prog, struct bpf_map *map,
bool exclude_ingress)
{ … }
static void *dev_map_lookup_elem(struct bpf_map *map, void *key)
{ … }
static void *dev_map_hash_lookup_elem(struct bpf_map *map, void *key)
{ … }
static void __dev_map_entry_free(struct rcu_head *rcu)
{ … }
static long dev_map_delete_elem(struct bpf_map *map, void *key)
{ … }
static long dev_map_hash_delete_elem(struct bpf_map *map, void *key)
{ … }
static struct bpf_dtab_netdev *__dev_map_alloc_node(struct net *net,
struct bpf_dtab *dtab,
struct bpf_devmap_val *val,
unsigned int idx)
{ … }
static long __dev_map_update_elem(struct net *net, struct bpf_map *map,
void *key, void *value, u64 map_flags)
{ … }
static long dev_map_update_elem(struct bpf_map *map, void *key, void *value,
u64 map_flags)
{ … }
static long __dev_map_hash_update_elem(struct net *net, struct bpf_map *map,
void *key, void *value, u64 map_flags)
{ … }
static long dev_map_hash_update_elem(struct bpf_map *map, void *key, void *value,
u64 map_flags)
{ … }
static long dev_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
{ … }
static long dev_hash_map_redirect(struct bpf_map *map, u64 ifindex, u64 flags)
{ … }
static u64 dev_map_mem_usage(const struct bpf_map *map)
{ … }
BTF_ID_LIST_SINGLE(dev_map_btf_ids, struct, bpf_dtab)
const struct bpf_map_ops dev_map_ops = …;
const struct bpf_map_ops dev_map_hash_ops = …;
static void dev_map_hash_remove_netdev(struct bpf_dtab *dtab,
struct net_device *netdev)
{ … }
static int dev_map_notification(struct notifier_block *notifier,
ulong event, void *ptr)
{ … }
static struct notifier_block dev_map_notifier = …;
static int __init dev_map_init(void)
{ … }
subsys_initcall(dev_map_init);