A few more things I just found. Happy to just make the fixes myself when I apply the patch if you prefer — just let me know what you think. Yureka Lilian writes: > The xdp-forwarder's purpose is implementing the functionality needed > within the net-vm (a VM running the Linux drivers for any physical > interfaces on the spectrum system). > > In the future, the net-vm 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). > > 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 > (`prog_physical.o`) 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 (`prog_router.o`) removes one layer of VLAN tagging > and redirects the packets to the interface read from the VLAN tag. > > The helper program `set_router_iface` is used to update the `router_iface` > bpf map to point to the interface passed as argument to the program. > > Co-authored-by: Demi Marie Obenour > Signed-off-by: Yureka Lilian > Signed-off-by: Demi Marie Obenour > --- > pkgs/default.nix | 4 + > release/checks/pkg-tests.nix | 1 + > tools/default.nix | 21 +- tools/shell.nix should also set driverSupport = true so libbpf is available in the development shell. > tools/meson.build | 4 + > tools/meson_options.txt | 3 + > tools/xdp-forwarder/meson.build | 48 +++++ > tools/xdp-forwarder/parsing_helpers.h | 274 +++++++++++++++++++++++++ > tools/xdp-forwarder/prog_physical.c | 39 ++++ > tools/xdp-forwarder/prog_router.c | 42 ++++ > tools/xdp-forwarder/rewrite_helpers.h | 146 +++++++++++++ > tools/xdp-forwarder/set_router_iface.c | 30 +++ > 11 files changed, 608 insertions(+), 4 deletions(-) > create mode 100644 tools/xdp-forwarder/meson.build > create mode 100644 tools/xdp-forwarder/parsing_helpers.h > create mode 100644 tools/xdp-forwarder/prog_physical.c > create mode 100644 tools/xdp-forwarder/prog_router.c > create mode 100644 tools/xdp-forwarder/rewrite_helpers.h > create mode 100644 tools/xdp-forwarder/set_router_iface.c > diff --git a/tools/xdp-forwarder/meson.build b/tools/xdp-forwarder/meson.build > new file mode 100644 > index 0000000..9b70ce3 > --- /dev/null > +++ b/tools/xdp-forwarder/meson.build > @@ -0,0 +1,48 @@ > +# SPDX-License-Identifier: EUPL-1.2+ > +# SPDX-FileCopyrightText: 2025 Yureka Lilian > +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour > + > +libbpf = dependency('libbpf', version : '1.6.2') This is an exact version match, which means we'll have to change it every time libbpf updates in Nixpkgs. Do you know what a more appropriate version constraint would be? > + > +executable('set-router-iface', 'set_router_iface.c', > + dependencies : libbpf, > + install : true) > + > +clang = find_program('clang', native: true) > + > +bpf_o_cmd = [ > + clang.full_path(), > + '-fno-stack-protector', > + '-fno-strict-aliasing', > + '-fwrapv', '-fwrapv-pointer', > + '-Wall', > + '-Wextra', When I built in a Nix shell I got warnings from -Wcompare-distinct-pointer-types and -Wsign-compare, coming from the vendored headers. Should I just silence those? (A quick look at the kernel suggests the distinct pointer type comparison is probably fine, but that the sign comparison issue should probably be fixed upstream.) > + '-O2', > + '-target', 'bpf', > + '-I', meson.current_source_dir() + '/include', > + '-g', > + '-c', > + '-o', '@OUTPUT@', > + '-MD', > + '-MP', > + '-MF', '@DEPFILE@', > + '--', > + '@INPUT@', > +] > + > +prog_router_o = custom_target( > + input : 'prog_router.c', > + output : 'prog_router.o', > + depfile : 'prog_router.o.dep', > + command : bpf_o_cmd, > + install: true, > + install_dir: 'lib/xdp') > + > +prog_physical_o = custom_target( > + input : 'prog_physical.c', > + output : 'prog_physical.o', > + depfile : 'prog_physical.o.dep', > + command : bpf_o_cmd, > + install: true, > + install_dir: 'lib/xdp') > +