From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 5D36819435; Mon, 08 Sep 2025 07:57:07 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id EBA4E193D3; Mon, 08 Sep 2025 07:57:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-b4-smtp.messagingengine.com (fout-b4-smtp.messagingengine.com [202.12.124.147]) by atuin.qyliss.net (Postfix) with ESMTPS id 7AC83193D2 for ; Mon, 08 Sep 2025 07:57:02 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id BCC581D000F4; Mon, 8 Sep 2025 03:57:00 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 08 Sep 2025 03:57:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1757318220; x=1757404620; bh=hBnU6NXxfF gcDIx1a+4lTUu6VahuGLD8rBcgxQPzB2o=; b=NRWGyMVcB+MpKsXvwNV2eHjehH S4aQBTA067Cm75kRhOQ2YZR0LXaVs7VgolFComZXrU5Ie4JRqj3utJl8yTAoZYjf NozdEaRAJ5xNQdWvYjqiCWGPkaGdQK/iWmrge3N5DNkzI0E5A7r5/RCau88/WkCS /HjnFtqBWyr6fikCNyAS/NXI/KJAZNXgY6Al/peLKYLYPB002cEeeAqIyuxxPuqG qOYxKoK3s4jzSg41ouDkPaXozERa5eD6W8kasj+xK98q73H5U8M5wG9fIjlhb6uE eMkG91NWBWszC5pyhbmbELsuR0CIO0w9Adf7BeAsbiGbEh+ycc8VSq6wpzQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1757318220; x=1757404620; bh=hBnU6NXxfFgcDIx1a+4lTUu6VahuGLD8rBc gxQPzB2o=; b=IT5XAIXqqb2RoQWlMfK56+FPEhD0Xe4uULanoy8DuixInyy9aVa mBAjc9v99xUi3MVs18NYYS45nlZ9vO8sAccBJPSpxtVuzRAOkBKWS+e322UECN3s xN/glBrYMs9cQLK+0P30Fj7T6ol+yLXVkxzxNr4BY627R2Ttkpnhf1NdfL4k/GF9 KQD3KvNgJWPNQK6s66Fg+k36zyJIxwrlMMgzNKbpuSLm6V0WDkHwMwSGKFUAEWJY zGBS5B+i9iuB+aycJ32iHovc0xizznDumtRKGusivXetTn/iIYtuIJK8QI2PPmdF Zf9Aiu6GKeqRhIcFKdxowMIBeS80Yd7oe0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduieellecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufgjfhffkfggtgesghdtreertddttdenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepkeefhfdtff eliefhiefflefhieeujeetkeetvdeuveetheekvedujefggeffieeunecuffhomhgrihhn pehsthguvghnvhdrtggtpdhgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspghr tghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohephihurhgvkhgrse gthigsvghrtghhrghoshdruggvvhdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhu mhdqohhsrdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 8 Sep 2025 03:56:59 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 5003A1673A83; Mon, 08 Sep 2025 09:56:56 +0200 (CEST) From: Alyssa Ross To: Yureka Lilian Subject: Re: [PATCH] tools: add xdp-forwarder In-Reply-To: <20250906141228.2357630-1-yureka@cyberchaos.dev> References: <20250906141228.2357630-1-yureka@cyberchaos.dev> Date: Mon, 08 Sep 2025 09:56:53 +0200 Message-ID: <87ecsh8ji2.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: QICOZMZIJ3OWBWED5XZIZ7DVYOF4EQ74 X-Message-ID-Hash: QICOZMZIJ3OWBWED5XZIZ7DVYOF4EQ74 X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: devel@spectrum-os.org X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. > > Signed-off-by: Yureka Lilian > --- > pkgs/default.nix | 5 + > tools/default.nix | 15 +- > tools/meson.build | 5 + > tools/meson_options.txt | 4 + > tools/xdp-forwarder/include/parsing_helpers.h | 273 ++++++++++++++++++ > tools/xdp-forwarder/include/rewrite_helpers.h | 145 ++++++++++ > tools/xdp-forwarder/meson.build | 38 +++ > tools/xdp-forwarder/prog_physical.c | 37 +++ > tools/xdp-forwarder/prog_router.c | 43 +++ > tools/xdp-forwarder/set_router_iface.c | 29 ++ > 10 files changed, 591 insertions(+), 3 deletions(-) > create mode 100644 tools/xdp-forwarder/include/parsing_helpers.h > create mode 100644 tools/xdp-forwarder/include/rewrite_helpers.h > create mode 100644 tools/xdp-forwarder/meson.build > create mode 100644 tools/xdp-forwarder/prog_physical.c > create mode 100644 tools/xdp-forwarder/prog_router.c > create mode 100644 tools/xdp-forwarder/set_router_iface.c > > diff --git a/pkgs/default.nix b/pkgs/default.nix > index 3b81339..76b2a5c 100644 > --- a/pkgs/default.nix > +++ b/pkgs/default.nix > @@ -1,4 +1,5 @@ > # SPDX-FileCopyrightText: 2023-2024 Alyssa Ross > +# SPDX-FileCopyrightText: 2025 Yureka Lilian > # SPDX-License-Identifier: MIT >=20=20 > { ... } @ args: > @@ -42,6 +43,10 @@ let > guestSupport =3D false; > hostSupport =3D true; > }; > + spectrum-driver-tools =3D self.callSpectrumPackage ../tools { > + guestSupport =3D false; > + driverSupport =3D true; > + }; > xdg-desktop-portal-spectrum-host =3D > self.callSpectrumPackage ../tools/xdg-desktop-portal-spectrum-host= {}; >=20=20 Probably not copyrightable, since it's not really doing anything new compared to the other entries. > diff --git a/tools/default.nix b/tools/default.nix > index 95d76a1..e664f47 100644 > --- a/tools/default.nix > +++ b/tools/default.nix > @@ -1,13 +1,16 @@ > # SPDX-License-Identifier: MIT > # SPDX-FileCopyrightText: 2022-2025 Alyssa Ross > +# SPDX-FileCopyrightText: 2025 Yureka Lilian >=20=20 > import ../lib/call-package.nix ( > { src, lib, stdenv, fetchCrate, fetchurl, runCommand, buildPackages > , meson, ninja, pkg-config, rustc > , clang-tools, clippy > , dbus > +, clang, libbpf > , guestSupport ? true > , hostSupport ? false > +, driverSupport ? false > }: >=20=20 > let > @@ -70,15 +73,18 @@ stdenv.mkDerivation (finalAttrs: { > ./lsvm > ./start-vmm > ./subprojects > + ] ++ lib.optionals driverSupport [ > + ./xdp-forwarder > ])); > }; > sourceRoot =3D "source/tools"; >=20=20 > depsBuildBuild =3D lib.optionals hostSupport [ buildPackages.stdenv.cc= ]; > nativeBuildInputs =3D [ meson ninja ] > - ++ lib.optionals guestSupport [ pkg-config ] > - ++ lib.optionals hostSupport [ rustc ]; > - buildInputs =3D lib.optionals guestSupport [ dbus ]; > + ++ lib.optionals (guestSupport || driverSupport) [ pkg-config ] > + ++ lib.optionals hostSupport [ rustc ] > + ++ lib.optionals driverSupport [ clang ]; > + buildInputs =3D lib.optionals guestSupport [ dbus ] ++ lib.optionals d= riverSupport [ libbpf ]; >=20=20 > postPatch =3D lib.optionals hostSupport (lib.concatMapStringsSep "\n" = (crate: '' > mkdir -p subprojects/packagecache > @@ -88,12 +94,15 @@ stdenv.mkDerivation (finalAttrs: { > mesonFlags =3D [ > (lib.mesonBool "guest" guestSupport) > (lib.mesonBool "host" hostSupport) > + (lib.mesonBool "driver" driverSupport) > "-Dhostfsrootdir=3D/run/virtiofs/virtiofs0" > "-Dtests=3Dfalse" > "-Dunwind=3Dfalse" > "-Dwerror=3Dtrue" > ]; >=20=20 > + hardeningDisable =3D lib.optionals driverSupport [ "zerocallusedregs" = ]; > + > passthru.tests =3D { > clang-tidy =3D finalAttrs.finalPackage.overrideAttrs ( > { name, src, nativeBuildInputs ? [], ... }: > diff --git a/tools/meson.build b/tools/meson.build > index 9cebd03..e49f27c 100644 > --- a/tools/meson.build > +++ b/tools/meson.build > @@ -1,5 +1,6 @@ > # SPDX-License-Identifier: EUPL-1.2+ > # SPDX-FileCopyrightText: 2024 Alyssa Ross > +# SPDX-FileCopyrightText: 2025 Yureka Lilian >=20=20 > project('spectrum-tools', 'c', > default_options : { > @@ -26,3 +27,7 @@ endif > if get_option('guest') > subdir('xdg-desktop-portal-spectrum') > endif > + > +if get_option('driver') > + subdir('xdp-forwarder') > +endif Same here. > diff --git a/tools/meson_options.txt b/tools/meson_options.txt > index 4af0031..887e388 100644 > --- a/tools/meson_options.txt > +++ b/tools/meson_options.txt > @@ -1,5 +1,6 @@ > # SPDX-License-Identifier: EUPL-1.2+ > # SPDX-FileCopyrightText: 2022-2024 Alyssa Ross > +# SPDX-FileCopyrightText: 2025 Yureka Lilian >=20=20 > option('host', type : 'boolean', value : false, > description : 'Build tools for the Spectrum host') > @@ -7,6 +8,9 @@ option('host', type : 'boolean', value : false, > option('guest', type : 'boolean', > description : 'Build tools for Spectrum guests') >=20=20 > +option('driver', type : 'boolean', > + description : 'Build tools for Spectrum driver VMs') > + > option('hostfsrootdir', type : 'string', value : '/run/host', > description : 'Path where the virtio-fs provided by the host will be m= ounted') >=20=20 Same here. > diff --git a/tools/xdp-forwarder/include/parsing_helpers.h b/tools/xdp-fo= rwarder/include/parsing_helpers.h > new file mode 100644 > index 0000000..3d240cd > --- /dev/null > +++ b/tools/xdp-forwarder/include/parsing_helpers.h > @@ -0,0 +1,273 @@ > +/* SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-clause) */ > +/* Vendored from https://github.com/xdp-project/xdp-tutorial/blob/d3d3ee= d6ea9a63d1302bfa8b5a8e93862bfe11f0/common/parsing_helpers.h */ Here I don't see any copyright header at all. Is release/checks/reuse.nix happy? > diff --git a/tools/xdp-forwarder/meson.build b/tools/xdp-forwarder/meson.= build > new file mode 100644 > index 0000000..7e60c11 > --- /dev/null > +++ b/tools/xdp-forwarder/meson.build > @@ -0,0 +1,38 @@ > +# SPDX-License-Identifier: EUPL-1.2+ > +# SPDX-FileCopyrightText: 2025 Yureka Lilian > + > +libbpf =3D dependency('libbpf', version : '1.6.2') > + > +executable('set_router_iface', 'set_router_iface.c', > + dependencies : libbpf, > + install : true) Minor thing: can we call this set-router-iface? It's just more common to see executables with dashes in them than underscares. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaL6MRQAKCRBbRZGEIw/w onjjAP9rFCFo22eLK2R8guBmcAJLFQqieYEfTpbh1cPI9SWGSQD/ehX+kXilmIrM hYbsAdhGcz4xTc9JI3tRaXIhnpBcRA4= =speu -----END PGP SIGNATURE----- --=-=-=--