bpf: add devmap, a map for storing net device references
Device map (devmap) is a BPF map, primarily useful for networking applications, that uses a key to lookup a reference to a netdevice. The map provides a clean way for BPF programs to build virtual port to physical port maps. Additionally, it provides a scoping function for the redirect action itself allowing multiple optimizations. Future patches will leverage the map to provide batching at the XDP layer. Another optimization/feature, that is not yet implemented, would be to support multiple netdevices per key to support efficient multicast and broadcast support. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
5acaee0a89
commit
546ac1ffb7
@@ -1276,6 +1276,14 @@ static int check_map_func_compatibility(struct bpf_map *map, int func_id)
|
||||
func_id != BPF_FUNC_current_task_under_cgroup)
|
||||
goto error;
|
||||
break;
|
||||
/* devmap returns a pointer to a live net_device ifindex that we cannot
|
||||
* allow to be modified from bpf side. So do not allow lookup elements
|
||||
* for now.
|
||||
*/
|
||||
case BPF_MAP_TYPE_DEVMAP:
|
||||
if (func_id == BPF_FUNC_map_lookup_elem)
|
||||
goto error;
|
||||
break;
|
||||
case BPF_MAP_TYPE_ARRAY_OF_MAPS:
|
||||
case BPF_MAP_TYPE_HASH_OF_MAPS:
|
||||
if (func_id != BPF_FUNC_map_lookup_elem)
|
||||
|
Reference in New Issue
Block a user