Skip to content

Conversation

@enhaut
Copy link
Contributor

@enhaut enhaut commented May 2, 2025

This patch adds support for VLAN processing. All the directions are supported:

  • tagged network to tagged
  • tagged to untagged
  • untagged to tagged

However, this adds ~4% overhead, therefore it's disabled by default. To enabled it, xdp-forward needs to be recompiled with either VLANS_USERSPACE or VLANS_PATCHED based on desired mode. 2 modes are supported:

  • userspace - before loading xdp-forward, userspace part uses netlink to get all the VLAN interfaces on top of xdp-forward-enabled devices. The map that maps vlan ifindex to underlying physical ifindex+VLAN ID is then passed to XDP program. (bpf_fib_lookup returns VLAN interface ifindex when packet is forwarded to VLANed network, but VLAN interfaces does not implement xmit function for xdp. Therefore, packet needs to be sent out of physical inf). Limitation of this version is, that mapping map is not automatically updated, so when VLAN interface is changed (removed, added, vlan id) xdp-forward requires manual reload.
  • kernel patched - this is "native" mode which requires patched kernel with a patch, that extends bpf_fib_lookup for support of physical device lookup for vlan interfaces. (@tohojo is working on this patch)

Performance comparison:

vlans_compared

Before this patch, the performance of VLAN tagged traffic was even slower with xdp-forward enabled as it was just passing it to the stack but added some overhead.

enhaut added 2 commits May 2, 2025 16:32
This commit adds support for VLANs. All the scenarios
of packets forwarding from/to interfaces are supported:

* untagged inf -> untagged inf
* tagged inf -> tagged inf
* untagged inf -> tagged inf
* tagged inf -> untagged inf

Unfortunately, this adds roughly 4% performance overhead
for all the scenarios.

Since patch for kernel this is based on, hasn't been
merged yet this requires patching kernel manually. When
running this version of xdp-forward on unpached kernel
all the route lookups (`bpf_fib_lookup`) will return
`-EINVAL` and so, will be passed to regular kernel stack.
This patch extends previous one and it adds support for
802.1Q VLANs without mentioned kernel patch. VLAN
interfaces are detected via netlink as well as their ids.
These data are stored in BPF map and provided to XDP
program which then can handle VLAN packets the same way
as if there was kernel patch applied.

VLAN interfaces are detected via netlink and only
during startup. Therefore, packets forwarded to VLAN
interfaces added later won't have corresponding entries
in BPF map which forwards packets to regular kernel stack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant