aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bpf.h
diff options
context:
space:
mode:
authorToke Høiland-Jørgensen <toke@redhat.com>2019-07-26 12:06:55 -0400
committerAlexei Starovoitov <ast@kernel.org>2019-07-29 16:50:48 -0400
commit6f9d451ab1a33728adb72d7ff66a7b374d665176 (patch)
tree770905d84a709ad9407b82d445d4a88343f3c9c6 /include/linux/bpf.h
parentfca16e51078e8e5c0af839426b3d2dcd2bede135 (diff)
xdp: Add devmap_hash map type for looking up devices by hashed index
A common pattern when using xdp_redirect_map() is to create a device map where the lookup key is simply ifindex. Because device maps are arrays, this leaves holes in the map, and the map has to be sized to fit the largest ifindex, regardless of how many devices actually are actually needed in the map. This patch adds a second type of device map where the key is looked up using a hashmap, instead of being used as an array index. This allows maps to be densely packed, so they can be smaller. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Acked-by: Yonghong Song <yhs@fb.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r--include/linux/bpf.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index bfdb54dd2ad1..f9a506147c8a 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -713,6 +713,7 @@ struct xdp_buff;
713struct sk_buff; 713struct sk_buff;
714 714
715struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key); 715struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key);
716struct bpf_dtab_netdev *__dev_map_hash_lookup_elem(struct bpf_map *map, u32 key);
716void __dev_map_flush(struct bpf_map *map); 717void __dev_map_flush(struct bpf_map *map);
717int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp, 718int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_buff *xdp,
718 struct net_device *dev_rx); 719 struct net_device *dev_rx);
@@ -799,6 +800,12 @@ static inline struct net_device *__dev_map_lookup_elem(struct bpf_map *map,
799 return NULL; 800 return NULL;
800} 801}
801 802
803static inline struct net_device *__dev_map_hash_lookup_elem(struct bpf_map *map,
804 u32 key)
805{
806 return NULL;
807}
808
802static inline void __dev_map_flush(struct bpf_map *map) 809static inline void __dev_map_flush(struct bpf_map *map)
803{ 810{
804} 811}