Skip to content

bpf: bidirectional VLAN support for bpf_fib_lookup()

Avinash Duduskar bpf linux-kselftest lkml netdev 6 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest3 patches 0 repliesApplied 3/3
  2. v63 patches 6 repliesSuperseded
  3. v53 patches 14 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v43 patches4 repliesSuperseded
v33 patches1 replySuperseded
v24 patches4 repliesSuperseded

Changes in v7 from the cover letter

- Patch 1 (BPF_FIB_LOOKUP_VLAN: resolve a VLAN egress to its real device plus the tag): uapi doc clarified, repeating the lookup after BPF_FIB_LKUP_RET_VLAN_FAILURE needs a re-initialized params, since output fields overwrite the inputs they share storage with. No functional change.
- Patch 2 (BPF_FIB_LOOKUP_VLAN_INPUT: run the lookup as if the tagged frame arrived on the matching VLAN subinterface): no code change; a commit message correction (an invalid proto returns -EINVAL under !CONFIG_VLAN_8021Q too).
- Patch 3 (selftests for both flags, tc and XDP paths): local defines for the netns subtest addresses (Emil's review); the netns input arm brings the moved device up first, so the namespace check is the only condition it can fail on; the live-frames subtest uses its own netns name (no collision under test_progs -j) and counts only the test's TCP frames, so background traffic cannot satisfy the delivery assertion; a stale mtu comment corrected.

Patches in v7 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: Add BPF_FIB_LOOKUP_VLAN flag to bpf_fib_lookup() helperinclude/uapi/linux/bpf.h net/core/filter.c tools/include/uapi/linux/bpf.h+93 -60 repliesApplied
2/3bpf: Add BPF_FIB_LOOKUP_VLAN_INPUT flag to bpf_fib_lookup() helperinclude/uapi/linux/bpf.h net/core/filter.c tools/include/uapi/linux/bpf.h+101 -70 repliesApplied
3/3selftests/bpf: Add bpf_fib_lookup() VLAN flag teststools/testing/selftests/bpf/prog_tests/fib_lookup.c tools/testing/selftests/bpf/progs/fib_lookup.c+773 -40 repliesApplied

Reviews trailers per patch

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

PatchToke Høiland-JørgensenDavid AhernEmil Tsalapatis
1/3R-b A-b R-b
2/3R-b R-b
3/3R-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 v7 thread

Cover letter [PATCH bpf-next v7 0/3] bpf: bidirectional VLAN support for bpf_fib_lookup()

This series adds VLAN awareness to bpf_fib_lookup() in both directions. BPF_FIB_LOOKUP_VLAN resolves a VLAN egress to its underlying real device plus the VLAN tag (XDP programs need this because VLAN devices have no XDP xmit), and BPF_FIB_LOOKUP_VLAN_INPUT runs the lookup as if a tagged frame had arrived on the matching VLAN subinterface, for iif policy routing and VRF table selection.

BPF_FIB_LOOKUP_VLAN opts in to replacing params->ifindex, whose value existing programs consume since d1c362e1dd68 ("bpf: Always return target ifindex in bpf_fib_lookup"); without it the output is unchanged.

An egress that does not reduce to a real device plus one tag (a QinQ stack, or a parent in another network namespace) returns BPF_FIB_LKUP_RET_VLAN_FAILURE with params->ifindex left at the input; repeating the lookup without the flag, with a re-initialized params, returns the VLAN device's own ifindex. A VLAN on a bond reduces to the bond, which picks its egress slave at xmit.

The new return code is appended after BPF_FIB_LKUP_RET_NO_SRC_ADDR (nothing renumbered, tools/ mirror updated) and is returned only when the flag is set, so no existing caller can observe it.

Changes v6 -> v7:

- Patch 1 (BPF_FIB_LOOKUP_VLAN: resolve a VLAN egress to its real device plus the tag): uapi doc clarified, repeating the lookup after BPF_FIB_LKUP_RET_VLAN_FAILURE needs a re-initialized params, since output fields overwrite the inputs they share storage with. No functional change.
- Patch 2 (BPF_FIB_LOOKUP_VLAN_INPUT: run the lookup as if the tagged frame arrived on the matching VLAN subinterface): no code change; a commit message correction (an invalid proto returns -EINVAL under !CONFIG_VLAN_8021Q too).
- Patch 3 (selftests for both flags, tc and XDP paths): local defines for the netns subtest addresses (Emil's review); the netns input arm brings the moved device up first, so the namespace check is the only condition it can fail on; the live-frames subtest uses its own netns name (no collision under test_progs -j) and counts only the test's TCP frames, so background traffic cannot satisfy the delivery assertion; a stale mtu comment corrected.

v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Avinash Duduskar (3):
bpf: Add BPF_FIB_LOOKUP_VLAN flag to bpf_fib_lookup() helper
bpf: Add BPF_FIB_LOOKUP_VLAN_INPUT flag to bpf_fib_lookup() helper selftests/bpf: Add bpf_fib_lookup() VLAN flag tests

 include/uapi/linux/bpf.h                      |  52 +-
 net/core/filter.c                             |  97 ++-
 tools/include/uapi/linux/bpf.h                |  52 +-
 .../selftests/bpf/prog_tests/fib_lookup.c     | 720 +++++++++++++++++-
 .../testing/selftests/bpf/progs/fib_lookup.c  |  57 ++
 5 files changed, 964 insertions(+), 14 deletions(-)

base-commit: a975094bf98ca97be9146f9d3b5681a6f9cf5ce3

Signature · 1 line
2.54.0