]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: devmap: Implement devmap prog execution for generic XDP
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Fri, 2 Jul 2021 11:18:24 +0000 (16:48 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 8 Jul 2021 03:01:45 +0000 (20:01 -0700)
commitbca54653c536cf2f8ad9375d76bca67475df27ba
treed46f57c8c60639c3c3d67fefcb387a779c1e62db
parent81e0fa070ef9df1ad2a626c47df3417f8fa9b2a5
bpf: devmap: Implement devmap prog execution for generic XDP

This lifts the restriction on running devmap BPF progs in generic
redirect mode. To match native XDP behavior, it is invoked right before
generic_xdp_tx is called, and only supports XDP_PASS/XDP_ABORTED/
XDP_DROP actions.

We also return 0 even if devmap program drops the packet, as
semantically redirect has already succeeded and the devmap prog is the
last point before TX of the packet to device where it can deliver a
verdict on the packet.

This also means it must take care of freeing the skb, as
xdp_do_generic_redirect callers only do that in case an error is
returned.

Since devmap entry prog is supported, remove the check in
generic_xdp_install entirely.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20210702111825.491065-5-memxor@gmail.com
include/linux/bpf.h
kernel/bpf/devmap.c
net/core/dev.c