]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Always return target ifindex in bpf_fib_lookup
authorToke Høiland-Jørgensen <toke@redhat.com>
Fri, 9 Oct 2020 18:42:34 +0000 (20:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:50:33 +0000 (12:50 +0100)
commite71814d2021e892a84f61039f0420278b4df52af
tree60f337a32358f76c6d2085d88a4f858e9ea82abd
parent021105d07e87d3644321af8a130b0663a7dfb0ed
bpf: Always return target ifindex in bpf_fib_lookup

commit c5064aeb6f40df47907b42364a3be4e5f254c32f upstream.

The bpf_fib_lookup() helper performs a neighbour lookup for the destination
IP and returns BPF_FIB_LKUP_NO_NEIGH if this fails, with the expectation
that the BPF program will pass the packet up the stack in this case.
However, with the addition of bpf_redirect_neigh() that can be used instead
to perform the neighbour lookup, at the cost of a bit of duplicated work.

For that we still need the target ifindex, and since bpf_fib_lookup()
already has that at the time it performs the neighbour lookup, there is
really no reason why it can't just return it in any case. So let's just
always return the ifindex if the FIB lookup itself succeeds.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Link: https://lore.kernel.org/bpf/20201009184234.134214-1-toke@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/filter.c