bpf: introduce new bpf AF_XDP map type BPF_MAP_TYPE_XSKMAP
The xskmap is yet another BPF map, very much inspired by dev/cpu/sockmap, and is a holder of AF_XDP sockets. A user application adds AF_XDP sockets into the map, and by using the bpf_redirect_map helper, an XDP program can redirect XDP frames to an AF_XDP socket. Note that a socket that is bound to certain ifindex/queue index will *only* accept XDP frames from that netdev/queue index. If an XDP program tries to redirect from a netdev/queue index other than what the socket is bound to, the frame will not be received on the socket. A socket can reside in multiple maps. v3: Fixed race and simplified code. v2: Removed one indirection in map lookup. Signed-off-by:Björn Töpel <bjorn.topel@intel.com> Signed-off-by:
Alexei Starovoitov <ast@kernel.org>
Showing
- include/linux/bpf.h 25 additions, 0 deletionsinclude/linux/bpf.h
- include/linux/bpf_types.h 3 additions, 0 deletionsinclude/linux/bpf_types.h
- include/net/xdp_sock.h 7 additions, 0 deletionsinclude/net/xdp_sock.h
- include/uapi/linux/bpf.h 1 addition, 0 deletionsinclude/uapi/linux/bpf.h
- kernel/bpf/Makefile 3 additions, 0 deletionskernel/bpf/Makefile
- kernel/bpf/verifier.c 6 additions, 2 deletionskernel/bpf/verifier.c
- kernel/bpf/xskmap.c 239 additions, 0 deletionskernel/bpf/xskmap.c
- net/xdp/xsk.c 5 additions, 0 deletionsnet/xdp/xsk.c
Loading
Please register or sign in to comment