diff options
author | Louis DeLosSantos <louis.delos.devel@gmail.com> | 2023-05-31 15:38:48 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-06-01 19:58:44 +0200 |
commit | 8ad77e72caae22a1ddcfd0c03f2884929e93b7a4 (patch) | |
tree | 0b60605cc17b9f88b9cfb38a5b6ec51a69f33cec /tools/testing/selftests/bpf/prog_tests/fib_lookup.c | |
parent | 60548b825b082cedf89b275c21c28b1e1d030e50 (diff) | |
download | linux-stable-8ad77e72caae22a1ddcfd0c03f2884929e93b7a4.tar.gz linux-stable-8ad77e72caae22a1ddcfd0c03f2884929e93b7a4.tar.bz2 linux-stable-8ad77e72caae22a1ddcfd0c03f2884929e93b7a4.zip |
bpf: Add table ID to bpf_fib_lookup BPF helper
Add ability to specify routing table ID to the `bpf_fib_lookup` BPF
helper.
A new field `tbid` is added to `struct bpf_fib_lookup` used as
parameters to the `bpf_fib_lookup` BPF helper.
When the helper is called with the `BPF_FIB_LOOKUP_DIRECT` and
`BPF_FIB_LOOKUP_TBID` flags the `tbid` field in `struct bpf_fib_lookup`
will be used as the table ID for the fib lookup.
If the `tbid` does not exist the fib lookup will fail with
`BPF_FIB_LKUP_RET_NOT_FWDED`.
The `tbid` field becomes a union over the vlan related output fields
in `struct bpf_fib_lookup` and will be zeroed immediately after usage.
This functionality is useful in containerized environments.
For instance, if a CNI wants to dictate the next-hop for traffic leaving
a container it can create a container-specific routing table and perform
a fib lookup against this table in a "host-net-namespace-side" TC program.
This functionality also allows `ip rule` like functionality at the TC
layer, allowing an eBPF program to pick a routing table based on some
aspect of the sk_buff.
As a concrete use case, this feature will be used in Cilium's SRv6 L3VPN
datapath.
When egress traffic leaves a Pod an eBPF program attached by Cilium will
determine which VRF the egress traffic should target, and then perform a
FIB lookup in a specific table representing this VRF's FIB.
Signed-off-by: Louis DeLosSantos <louis.delos.devel@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230505-bpf-add-tbid-fib-lookup-v2-1-0a31c22c748c@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/fib_lookup.c')
0 files changed, 0 insertions, 0 deletions