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 459F812784; Sun, 31 Aug 2025 18:06:43 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 1BBD1126F8; Sun, 31 Aug 2025 18:06:41 +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_PASS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail.cyberchaos.dev (mail.cyberchaos.dev [195.39.247.168]) by atuin.qyliss.net (Postfix) with ESMTPS id 5137112774 for ; Sun, 31 Aug 2025 18:06:40 +0000 (UTC) Message-ID: <14ab4dbe-fb4f-4e7e-95b8-ebca0bfdedad@yuka.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yuka.dev; s=mail; t=1756663598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D2ow3wwnrTiO3wagWNcW9Y7y0HFdeMrCwPKVNJKlmgc=; b=v30j+pm7widmVa87169gGGuVpq0L8+MxLNmRWAI13/wEZoTCvo+5y8N8obFl0qS+TJ4bNI sLEbFdM11NcEUqOnTxA6ZayQ+RY3JEfB5b+VNF2Eej9pTZutUyWELeQUrSR8GGwhYwo2yU WCkL7uWWBw8P/saiwszo9K9FpQhqRRk= Date: Sun, 31 Aug 2025 20:06:38 +0200 MIME-Version: 1.0 From: Yureka Subject: Re: [DO_NOT_APPLY 1/2] integrate xdp-forwarder into net-vm To: Alyssa Ross References: <20250823222134.1772413-1-yureka@cyberchaos.dev> <20250823222134.1772413-2-yureka@cyberchaos.dev> <87bjnxt6qn.fsf@alyssa.is> <87h5xnxvqu.fsf@alyssa.is> Content-Language: en-US In-Reply-To: <87h5xnxvqu.fsf@alyssa.is> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: QBJAYD2JI3J5MD5QXR6I2WNL5HRYSHMM X-Message-ID-Hash: QBJAYD2JI3J5MD5QXR6I2WNL5HRYSHMM X-MailFrom: yuka@yuka.dev 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: On 8/31/25 19:10, Alyssa Ross wrote: > Alyssa Ross writes: > >>> diff --git a/vm/sys/net/xdp-forwarder/default.nix >>> b/vm/sys/net/xdp-forwarder/default.nix >>> new file mode 100644 >>> index 0000000..75b1d66 >>> --- /dev/null >>> +++ b/vm/sys/net/xdp-forwarder/default.nix >>> @@ -0,0 +1,35 @@ >>> +# SPDX-License-Identifier: MIT >>> +# SPDX-FileCopyrightText: 2025 Yureka Lilian >>> + >>> +{ lib, runCommand, stdenv, llvmPackages, libbpf, linux, bpftools }: >>> + >>> +stdenv.mkDerivation { >>> + pname = "xdp-forwarder"; >>> + version = "0"; >>> + >>> + src = lib.fileset.toSource { >>> + root = ./.; >>> + fileset = lib.fileset.fileFilter >>> + ({ hasExt, ... }: !(hasExt "nix") && !(hasExt "md")) ./.; >>> + }; >>> + >>> + buildInputs = [ libbpf ]; >>> + nativeBuildInputs = [ llvmPackages.clang-unwrapped bpftools ]; >>> + >>> + buildPhase = '' >>> + bpftool btf dump file ${linux.dev}/vmlinux format c > >>> include/vmlinux.h >> I guess we're still missing a vmlinux.h package in Nixpkgs? That would >> be much cleaner. > Actually, given discussion in #systemd:nixos.org yesterday, it sounds > like best practice is to declare just the structs and struct members we > use: > > https://nakryiko.com/posts/bpf-core-reference-guide/#defining-own-co-re-relocatable-type-definitions > > (Since on Spectrum we /can/ predict the kernel we'll be running on, it's > not a huge deal, but I'd still like to follow the principle of having > packages be portable.) I don't really understand how avoiding vmlinux.h would make our programb more portable. At the same time, I am very reliant on bpf/bpf_helpers.h from libbpf, and this requires a definition of __u64 and __u32, and I don't know where I would get those from if not vmlinux.h (and defining them myself feels wrong).