History

bpf: Add support to attach bpf program to a devmap entry

Add BPF_XDP_DEVMAP attach type for use with programs associated with a DEVMAP entry. Allow DEVMAPs to associate a program with a device entry by adding a bpf_prog.fd to 'struct bpf_devmap_val'. Values read show the program id, so the fd and id are a union. bpf programs can get access to the struct via vmlinux.h. The program associated with the fd must have type XDP with expected attach type BPF_XDP_DEVMAP. When a program is associated with a device index, the program is run on an XDP_REDIRECT and before the buffer is added to the per-cpu queue. At this point rxq data is still valid; the next patch adds tx device information allowing the prorgam to see both ingress and egress device indices. XDP generic is skb based and XDP programs do not work with skb's. Block the use case by walking maps used by a program that is to be attached via xdpgeneric and fail if any of them are DEVMAP / DEVMAP_HASH with Block attach of BPF_XDP_DEVMAP programs to devices.

David Ahern committed 6 years ago

Commit fbee97f1 parent 7f1c0425 files · +109 −4Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/bpf.h+1−0
@@ -225,6 +225,7 @@ enum bpf_attach_type { · 224 unmodified lines
225 BPF_CGROUP_INET6_GETPEERNAME,225 BPF_CGROUP_INET6_GETPEERNAME,
226 BPF_CGROUP_INET4_GETSOCKNAME,226 BPF_CGROUP_INET4_GETSOCKNAME,
227 BPF_CGROUP_INET6_GETSOCKNAME,227 BPF_CGROUP_INET6_GETSOCKNAME,
228 BPF_XDP_DEVMAP,
228 __MAX_BPF_ATTACH_TYPE229 __MAX_BPF_ATTACH_TYPE
229};230};
230 231