netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf,v3 0/4] Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings.
@ 2023-04-26  8:51 Gilad Sever
  2023-04-26  8:51 ` [PATCH bpf,v3 1/4] bpf: factor out socket lookup functions for the TC hookpoint Gilad Sever
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Gilad Sever @ 2023-04-26  8:51 UTC (permalink / raw)
  To: dsahern, martin.lau, daniel, john.fastabend, ast, andrii, song,
	yhs, kpsingh, sdf, haoluo, jolsa, davem, edumazet, kuba, pabeni,
	mykolal, shuah, hawk, joe
  Cc: eyal.birger, shmulik.ladkani, bpf, netdev, linux-kselftest,
	Gilad Sever

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.
---
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

 net/core/filter.c                             | 132 +++++--
 .../bpf/prog_tests/vrf_socket_lookup.c        | 327 ++++++++++++++++++
 .../selftests/bpf/progs/vrf_socket_lookup.c   |  88 +++++
 3 files changed, 526 insertions(+), 21 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

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-04-27 18:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-26  8:51 [PATCH bpf,v3 0/4] Socket lookup BPF API from tc/xdp ingress does not respect VRF bindings Gilad Sever
2023-04-26  8:51 ` [PATCH bpf,v3 1/4] bpf: factor out socket lookup functions for the TC hookpoint Gilad Sever
2023-04-27 18:03   ` Stanislav Fomichev
2023-04-26  8:51 ` [PATCH bpf,v3 2/4] bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via " Gilad Sever
2023-04-27 18:03   ` Stanislav Fomichev
2023-04-26  8:51 ` [PATCH bpf,v3 3/4] bpf: fix bpf socket lookup from tc/xdp to respect socket VRF bindings Gilad Sever
2023-04-27 18:03   ` Stanislav Fomichev
2023-04-26  8:51 ` [PATCH bpf,v3 4/4] selftests/bpf: Add vrf_socket_lookup tests Gilad Sever
2023-04-27 17:31   ` Stanislav Fomichev

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).