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 8B1EEE373; Sat, 06 Sep 2025 12:05:50 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 6AA46E368; Sat, 06 Sep 2025 12:05:48 +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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) by atuin.qyliss.net (Postfix) with ESMTPS id AFD86E38E for ; Sat, 06 Sep 2025 12:05:46 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id C4FEE7A03CB; Sat, 6 Sep 2025 08:05:44 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Sat, 06 Sep 2025 08:05:44 -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=1757160344; x=1757246744; bh=E/bIIFH8WW RyAhsTGIDcge7fNNqjUUSlMAPL+qs0ug8=; b=M/W/fzNSest1heUKkiHFnrJm72 O3SwdXwEJF3HhmXDysYf2YnJQINpO4Ha7xFtIJ9ifihl/RaW0n9K022Uj0yrWhxa Q/LcOQ5L4RwxWXn7sb06fi6f+5wv1vPFdDxXovmUZ48CWAS5byznoXmWiuoGLXOO vnQT5MALv077fiUOcBgdVL/KrtCndpJXgxDgwV9niL/TeB/7uBH5/bsGWv7jon0g zkLpnjRhliMWg2kj5qiwNIi6w1OAken+6HVjpWlvqcctGF5UO5TCoY5Aqt7L+yJ4 bMl7WkqwTPnEefO4od2cY2XJH2cLY4GxR6XsBicr7tR3AGWFxghnlZu/L0Sw== 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= 1757160344; x=1757246744; bh=E/bIIFH8WWRyAhsTGIDcge7fNNqjUUSlMAP L+qs0ug8=; b=ibprn4bN3QChV/xXBkYVGAB2g5WdL02iHl7Vfo8GRjTMcxyx6SM 5TuWwXieBzHNi+3dBNl8zC5IJZc9xEcXeoMHAjQXJTXcjO0HHUhYi13JqbpkjRSW hyAAbT4YeY6CotOC7wxdYwfBeCe6s3CsymexKH8B3cAXmVv8G0NXS83JRaitd0bd 6GcoDybhKDFpPp1ggkPnRMFrgHnhRmWntAxNWNUruaTyUMwJ3loiNNfb3u5UdBGo dfBfkT9DAlw4SXyTEd7ZhpuFe6ZrgAfL8Q4qDGU9a3wySfvqp0r4T8q3cG/302OC 6y7wDsPXYWcK1pZUL9ngn3GZVNbCm6Vze8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduudejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufgjfhffkfggtgesghdtreertddttdenucfhrhhomheptehlhihsshgrucft ohhsshcuoehhihesrghlhihsshgrrdhisheqnecuggftrfgrthhtvghrnhepiefhtdfgje ellefghffhgfetkefhteeuleeggeeljeetleekhfevgedtieffveejnecuffhomhgrihhn pehsthguvghnvhdrtggtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhephhhisegrlhihshhsrgdrihhspdhnsggprhgtphhtthhopedvpdhmohgu vgepshhmthhpohhuthdprhgtphhtthhopeihuhhrvghkrgestgihsggvrhgthhgrohhsrd guvghvpdhrtghpthhtohepuggvvhgvlhesshhpvggtthhruhhmqdhoshdrohhrgh X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 6 Sep 2025 08:05:43 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 08BD31657968; Sat, 06 Sep 2025 14:05:41 +0200 (CEST) From: Alyssa Ross To: Yureka Lilian Subject: Re: [DO_NOT_APPLY v3 1/3] add xdp-forwarder In-Reply-To: <20250901201248.19794-2-yureka@cyberchaos.dev> References: <20250901201248.19794-1-yureka@cyberchaos.dev> <20250901201248.19794-2-yureka@cyberchaos.dev> Date: Sat, 06 Sep 2025 14:05:33 +0200 Message-ID: <87wm6b946q.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: J2LHFY55UNMB5EKFGUYYWRHXRVEITR45 X-Message-ID-Hash: J2LHFY55UNMB5EKFGUYYWRHXRVEITR45 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: > Signed-off-by: Yureka Lilian When you submit this for real, make sure to format the commit message like other Spectrum commits (e.g. "tools: add xdp-forwarder"), and maybe add a little background info, since it's not documented yet. > --- > 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/prog_physical.c | 37 +++ > tools/xdp-forwarder/prog_router.c | 43 +++ > tools/xdp-forwarder/set_router_iface.c | 32 ++ Shouldn't there be a tools/xdp-forwarder/meson.build? > 9 files changed, 556 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/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/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" = ]; > + Should we use the unwrapped compiler? The wrapper doesn't give us anything useful for other targets, and makes us need things like this. > passthru.tests =3D { > clang-tidy =3D finalAttrs.finalPackage.overrideAttrs ( > { name, src, nativeBuildInputs ? [], ... }: > 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') > + Should be grouped with host and guest (no blank line between). > diff --git a/tools/xdp-forwarder/set_router_iface.c b/tools/xdp-forwarder= /set_router_iface.c > new file mode 100644 > index 0000000..f1a2bac > --- /dev/null > +++ b/tools/xdp-forwarder/set_router_iface.c > @@ -0,0 +1,32 @@ > +// SPDX-License-Identifier: EUPL-1.2+ > +// SPDX-FileCopyrightText: 2025 Yureka Lilian > + > +#include > +#include > +#include > + > +int main(int argc, char **argv) > +{ > + if (argc < 2) { > + fprintf(stderr, "missing interface name\n"); > + return 1; > + } > + > + int router_idx =3D if_nametoindex(argv[1]); > + if (router_idx <=3D 0) { > + perror("error getting router interface"); > + return 1; Can we use err(EXIT_FAILURE, "error getting router interface") like we do elsewhere in Spectrum? > + } > + > + int map_fd =3D bpf_obj_get("/sys/fs/bpf/router_iface"); Do we want to namespace this at all? Is there a convention? > + if (map_fd < 0) { > + perror("failed to open bpf map"); > + return 1; > + } > + > + int id =3D 0; > + if (bpf_map_update_elem(map_fd, &id, &router_idx, 0) < 0) { > + perror("failed to update bpf map"); > + return 1; > + } > +} > --=20 > 2.50.1 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaLwjjQAKCRBbRZGEIw/w oo0hAPwMuF/AKrnU6mfe/bjGoe7NlWb7odsQN76m+tiWFOmt7wD/S7yiYUd+nTe1 0hlUq6BMs2vJ3YN17s7TD4BiT+M2vwQ= =mdja -----END PGP SIGNATURE----- --=-=-=--