Skip to content

Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings.

Gilad Sever bpf linux-kselftest netdev 6 versions – Applied

Status from this message: Applied, thanks! Btw, the above looks now way uglier than before, so I fixed this

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest4 patches 1 replyApplied
  2. v54 patches 1 replySuperseded
  3. v44 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v34 patches4 repliesSuperseded
v24 patches8 repliesSuperseded
v14 patches0 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/4bpf: factor out socket lookup functions for the TC hookpoint.net/core/filter.c+60 -30 replies
2/4bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC hookpointnet/core/filter.c+18 -60 replies
3/4bpf: fix bpf socket lookup from tc/xdp to respect socket VRF bindingsinclude/linux/netdevice.h net/core/filter.c+63 -301 reply
4/4selftests/bpf: Add vrf_socket_lookup teststools/testing/selftests/bpf/prog_tests/vrf_socket_lookup.c tools/testing/selftests/bpf/progs/vrf_socket_lookup.c+400 -00 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchStanislav FomichevShmulik LadkaniEyal Birger
1/4A-b R-b R-b
2/4A-b R-b R-b
3/4A-b R-b R-b
4/4A-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH bpf,v6 0/4] Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings.

When calling socket lookup from L2 (tc, xdp), VRF boundaries aren't respected. This patchset fixes this by regarding the incoming device's VRF attachment when performing the socket lookups from tc/xdp.

The first two patches are coding changes which factor out the tc helper's logic which was shared with cg/sk_skb (which operate correctly).

This refactoring is needed in order to avoid affecting the cgroup/sk_skb flows as there does not seem to be a strict criteria for discerning which flow the helper is called from based on the net device or packet information.

The third patch contains the actual bugfix.

The fourth patch adds bpf tests for these lookup functions.
---
v6: - Remove redundant IS_ENABLED as suggested by Daniel Borkmann
- Declare net_device variable and use it as suggested by Daniel Borkmann

v5: Use reverse xmas tree indentation

v4: - Move dev_sdif() to include/linux/netdevice.h as suggested by Stanislav Fomichev
- Remove SYS and SYS_NOFAIL duplicate definitions

v3: - Rename bpf_l2_sdif() to dev_sdif() as suggested by Stanislav Fomichev
- Added xdp tests as suggested by Daniel Borkmann
- Use start_server() to avoid duplicate code as suggested by Stanislav Fomichev

v2: Fixed uninitialized var in test patch (4).

Gilad Sever (4):
bpf: factor out socket lookup functions for the TC hookpoint.
bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC
hookpoint
bpf: fix bpf socket lookup from tc/xdp to respect socket VRF bindings selftests/bpf: Add vrf_socket_lookup tests

 include/linux/netdevice.h                     |   9 +
 net/core/filter.c                             | 141 ++++++--
 .../bpf/prog_tests/vrf_socket_lookup.c        | 312 ++++++++++++++++++
 .../selftests/bpf/progs/vrf_socket_lookup.c   |  88 +++++
 4 files changed, 526 insertions(+), 24 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/vrf_socket_lookup.c
 create mode 100644 tools/testing/selftests/bpf/progs/vrf_socket_lookup.c
Signature · 1 line
2.34.1