From: Louis DeLosSantos <louis.delos.devel@gmail.com>
To: bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Stanislav Fomichev <sdf@google.com>,
razor@blackwall.org,
Louis DeLosSantos <louis.delos.devel@gmail.com>
Subject: [PATCH 0/2] bpf: utilize table ID in bpf_fib_lookup helper
Date: Thu, 25 May 2023 10:27:58 -0400 [thread overview]
Message-ID: <20230505-bpf-add-tbid-fib-lookup-v1-0-fd99f7162e76@gmail.com> (raw)
This patchset adds the ability to specify a table ID to the
`bpf_fib_lookup` BPF helper.
A new `tbid` field is added to `struct fib_bpf_lookup`.
When the `fib_bpf_lookup` helper is called with the
`BPF_FIB_LOOKUP_DIRECT` flag and the `tbid` is set to an integer greater
then 0, the `tbid` field will be interpreted as the table ID to use for
the fib lookup.
If the `tbid` specifies a table that does not exist the lookup fails
with `BPF_FIB_LKUP_RET_NOT_FWDED`
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.
The existing `fib_lookup.c` bpf selftest was appended several test cases
to ensure this feature works as expected.
```
$ sudo ./test_progs -a "*fib*"
Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
```
Signed-off-by: Louis DeLosSantos <louis.delos.devel@gmail.com>
---
Louis DeLosSantos (2):
bpf: add table ID to bpf_fib_lookup BPF helper
bpf: test table ID fib lookup BPF helper
include/uapi/linux/bpf.h | 17 +++++--
net/core/filter.c | 12 +++++
tools/include/uapi/linux/bpf.h | 17 +++++--
.../testing/selftests/bpf/prog_tests/fib_lookup.c | 58 +++++++++++++++++++---
4 files changed, 90 insertions(+), 14 deletions(-)
---
base-commit: fbc0b0253001c397a481d258a88ce5f08996574f
change-id: 20230505-bpf-add-tbid-fib-lookup-aa46fa098603
Best regards,
--
Louis DeLosSantos <louis.delos.devel@gmail.com>
next reply other threads:[~2023-05-25 14:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 14:27 Louis DeLosSantos [this message]
2023-05-25 14:27 ` [PATCH 1/2] bpf: add table ID to bpf_fib_lookup BPF helper Louis DeLosSantos
2023-05-26 6:01 ` Yonghong Song
2023-05-26 14:11 ` Louis DeLosSantos
2023-05-26 6:48 ` John Fastabend
2023-05-26 14:07 ` Louis DeLosSantos
2023-05-26 16:58 ` Yonghong Song
2023-05-25 14:28 ` [PATCH 2/2] bpf: test table ID fib lookup " Louis DeLosSantos
2023-05-26 6:02 ` Yonghong Song
2023-05-26 14:23 ` Louis DeLosSantos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230505-bpf-add-tbid-fib-lookup-v1-0-fd99f7162e76@gmail.com \
--to=louis.delos.devel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=razor@blackwall.org \
--cc=sdf@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).