[DO_NOT_APPLY 0/2] xdp-forwarder

Yureka Lilian
2025-08-23T22:22:00Z

Hi all,

Since this worsens the networking situation unless combined with the
userspace Router (which is to-be-done), I am formally sending this out
for comments without expecting it to be applied for now.

The net-vm's purpose is running the Linux drivers for any physical
interfaces on the spectrum system.

A net-vm (there could be multiple, one per IOMMU-group) will load the
included XDP programs on the passed-through physical interfaces as well
as the downstream virtio interface going into the router (recognized by
its special MAC address) using mdev events.

The net-vm needs to multiplex between the physical interfaces, as there
might be several interfaces in the same IOMMU-group.

For this, the XDP program loaded on the physical interfaces applies a
VLAN tag corresponding to the interface id, and redirects the packets to
the router interface (identified by the router_iface bpf map).
In the other direction the XDP program loaded on the router interface
removes one layer of VLAN tagging, and redirects the packets to the
interface read from the VLAN tag.

I have verified that when running a wpa_supplicant / iwd in the
interface, a WiFi interface can correctly function as a physical
interface with the XDP forwarder, assuming that the router sends
packets with the correct source MAC address.

Yureka Lilian (2):
integrate xdp-forwarder into net-vm
temporary changes for testing

lib/nixpkgs.default.nix | 4 +-
vm/sys/net/Makefile | 8 +-
vm/sys/net/default.nix | 38 +++++--
vm/sys/net/etc/fstab | 1 +
vm/sys/net/etc/mdev/iface | 23 +---
vm/sys/net/etc/nftables.conf | 8 --
vm/sys/net/etc/s6-rc/connman/dependencies | 4 -
vm/sys/net/etc/s6-rc/connman/type | 1 -
vm/sys/net/etc/s6-rc/connman/type.license | 2 -
vm/sys/net/etc/s6-rc/nftables/type | 1 -
vm/sys/net/etc/s6-rc/nftables/type.license | 2 -
vm/sys/net/etc/s6-rc/nftables/up | 6 -
vm/sys/net/xdp-forwarder/README.md | 9 ++
vm/sys/net/xdp-forwarder/default.nix | 35 ++++++
.../xdp-forwarder/include/parsing_helpers.h | 38 +++++++
.../xdp-forwarder/include/rewrite_helpers.h | 103 ++++++++++++++++++
vm/sys/net/xdp-forwarder/load_physical | 4 +
vm/sys/net/xdp-forwarder/load_router | 6 +
vm/sys/net/xdp-forwarder/prog_physical.c | 28 +++++
vm/sys/net/xdp-forwarder/prog_router.c | 34 ++++++
vm/sys/net/xdp-forwarder/set_router_iface.c | 31 ++++++
21 files changed, 325 insertions(+), 61 deletions(-)
delete mode 100644 vm/sys/net/etc/nftables.conf
delete mode 100644 vm/sys/net/etc/s6-rc/connman/dependencies
delete mode 100644 vm/sys/net/etc/s6-rc/connman/type
delete mode 100644 vm/sys/net/etc/s6-rc/connman/type.license
delete mode 100644 vm/sys/net/etc/s6-rc/nftables/type
delete mode 100644 vm/sys/net/etc/s6-rc/nftables/type.license
delete mode 100644 vm/sys/net/etc/s6-rc/nftables/up
create mode 100644 vm/sys/net/xdp-forwarder/README.md
create mode 100644 vm/sys/net/xdp-forwarder/default.nix
create mode 100644 vm/sys/net/xdp-forwarder/include/parsing_helpers.h
create mode 100644 vm/sys/net/xdp-forwarder/include/rewrite_helpers.h
create mode 100755 vm/sys/net/xdp-forwarder/load_physical
create mode 100755 vm/sys/net/xdp-forwarder/load_router
create mode 100644 vm/sys/net/xdp-forwarder/prog_physical.c
create mode 100644 vm/sys/net/xdp-forwarder/prog_router.c
create mode 100644 vm/sys/net/xdp-forwarder/set_router_iface.c

--
2.50.1