Article View: linux.kernel.netdev
Article #19332[PATCH iproute2-next v2 6/7] lib/bpf: check for missing bpf fs mount point
From: Stephen Hemminger
Date: Thu, 19 Nov 2026 19:02
Date: Thu, 19 Nov 2026 19:02
89 lines
14025 bytes
14025 bytes
bpf_get_work_dir() returns NULL when it cannot provide a usable
work directory. It does so even after finding a valid bpffs mount,
because bpf_gen_hierarchy() fails if the tc/ subdirectory cannot be
created: running unprivileged against the default mode=700 mount,
or as root against a read-only one.
iproute2_get_root_path() passed that NULL straight to snprintf("%s"),
which glibc renders as "(null)":
$ tc filter add dev lo parent ffff: bpf obj prog.o sec egress
mkdir /sys/fs/bpf/tc/ failed: Permission denied
Continuing without mounted eBPF fs. Too old kernel?
mkdir (null)/globals failed: No such file or directory
Unable to load program
Check for NULL and report it instead. Also check the snprintf()
return, since root_path is handed to libbpf as pin_root_path and a
silently truncated pin root is worse than a hard failure.
The "Continuing without mounted eBPF fs" warning in bpf_init_env()
goes away with it. The legacy loader could carry on without bpffs,
which is what that message described, but the only remaining caller
needs the pin root and now fails, so the warning no longer matched
what happens next. The "Too old kernel?" guess was misleading as
well: the mount is usually present and simply not writable.
Removing the warning also removes the bpf_get_work_dir() call that
primed its cache, and the per-program-type subdirectory was only
appended on the cached path. Apply it on the first call too, so a
cls program keeps pinning under tc/ instead of at the mount root.
Fixes: 6d61a2b55799 ("lib: add libbpf support")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/bpf_util.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/lib/bpf_util.c b/lib/bpf_util.c
index e58e54be..7ce8f52f 100644
--- a/lib/bpf_util.c
+++ b/lib/bpf_util.c
@@ -767,6 +767,11 @@ static const char *bpf_get_work_dir(enum bpf_prog_type type)
mnt = bpf_wrk_dir;
out:
bpf_mnt_cached = true;
+ if (mnt && type) {
+ snprintf(bpf_tmp, sizeof(bpf_tmp), "%s%s/",
+ mnt, bpf_prog_to_subdir(type));
+ return bpf_tmp;
+ }
return mnt;
}
@@ -1068,20 +1073,27 @@ static void bpf_init_env(void)
/* Don't bother in case we fail! */
setrlimit(RLIMIT_MEMLOCK, &limit);
-
- if (!bpf_get_work_dir(BPF_PROG_TYPE_UNSPEC))
- fprintf(stderr, "Continuing without mounted eBPF fs. Too old kernel?\n");
}
int iproute2_get_root_path(enum bpf_prog_type type, char *root_path,
size_t len)
{
+ const char *wrk_dir;
int ret;
bpf_init_env();
- snprintf(root_path, len, "%s/%s",
- bpf_get_work_dir(type), BPF_DIR_GLOBALS);
+ wrk_dir = bpf_get_work_dir(type);
+ if (!wrk_dir) {
+ fprintf(stderr, "No mounted eBPF fs to pin maps under\n");
+ return -1;
+ }
+
+ if ((size_t)snprintf(root_path, len, "%s/%s",
+ wrk_dir, BPF_DIR_GLOBALS) >= len) {
+ fprintf(stderr, "Pin root path for %s too long\n", wrk_dir);
+ return -1;
+ }
ret = mkdir(root_path, S_IRWXU);
if (ret && errno != EEXIST) {
--
2.53.0
Technical Details
Message-ID:
<20261119190312.578885-7-stephen@networkplumber.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367265-linux-kernel-netdev=dewy.ruReferences:
<20261119190312.578885-1-stephen@networkplumber.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367265-linux-kernel-netdev=dewy.ru
From: stephen@networkplumber.org (Stephen Hemminger)
Newsgroups: linux.kernel.netdev
Subject: [PATCH iproute2-next v2 6/7] lib/bpf: check for missing bpf fs mount point
Date: Thu, 19 Nov 2026 11:02:41 -0800
Organization: Usenet Network
Message-ID: <20261119190312.578885-7-stephen@networkplumber.org>
References: <20261119190312.578885-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2958010"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3mlPSyydz7UJMymImVdL9vRl7Vw= sha256:2NtCbwJGUQEqUzeuOLfAYTiI9zMe9wyc9hP//h4Egs4=
sha1:iMwY0YHg8ko2NBlUOKO3R1/2xmg= sha256:eipx2+TvYeTbQqWtNChjrx+jhYCOoQ7dd2YwsAp1EXk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 156DE115748; Thu, 19 Nov 2026 22:03:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=networkplumber-org.20260707.gappssmtp.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id yHgnGMZZFlfh;
Thu, 19 Nov 2026 22:03:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-367265-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=quarantine dis=none) header.from=networkplumber.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id AF45211574B; Thu, 19 Nov 2026 22:03:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id B39AA61DD15; Thu, 19 Nov 2026 19:03:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795115002;
b=nc5i3cvrnK9r0jfM/AUm+791qitV+c5rNlhcQnTH2duGST7XjxTAF1Y4m03HwnS+MKfa
p6UqvYtCI1gwffZjvr0BO7hyVy2JCyGSDzlA+AW4VgobVVQG1ccfeABDi+56lIGSulhOF
zSFGy662iUfiWryU89ArTwA7cOYZAlP4fYzsRS1VSAhbppMKyduttv7uel63em28RSdaE
7GLYKuubrhUKjUr5NF4mx5QVnQe0fghR4nc3qbqiivuNhYDHzpK7UG1CBCncps3NRsTug
j3nVzNVieCvD1PxN7Yte9G4dz5JGZo8IqJjK74QgIkOF/nUhKRtCv4bp6caFJUTCCyA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795115002;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=bpLEycpua3oiW6PlqY9cG9z3XMx3iW2RiC0gfi/0zkY=;
b=GPMdrdIz8PZ2oTIckAUSazuUsz6qaD04Cx3lzMvaiAA0fxQDI2WhcKVie1DghDpJhOKg
JozkAWPXEPKwj2+joUEz/29ooLYurdprCxA1wPBs3aV0it405wcr98EdPlRYlL50QPZ3z
SPAp2bD3d+qMglmMoe8O9yNUaS4iAuUAkvLFnhh0XhJUznDPZw1052YPS9n9EU2REQnO6
YZ6z0DTwbjYiZeAc7qEQsPIko3GbgFEvMbEAOSZ42RqCi3ELYh8Wn/MBefe7075aZy8UP
iLOUA0N+XvmWPGDTtujn8e+lX+CUO1ZdjcNSBORyOSCpIayM7zymFbePBMWnOxzzP+A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=a1xVWpuk;
dmarc=pass header.from=networkplumber.org;
spf=pass smtp.mailfrom=networkplumber.org;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A3E2606A333;
Thu, 19 Nov 2026 19:03:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=a1xVWpuk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.174
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795115001;
b=n/wdPb5XP5Q0QAz/BtXk+6bk0ONvU6TbV3vFJ5jrKMx/t29WIRjav9lF1ukA2VjyD5iB
RYOeu0PvhTBjfBFKGh8LjGK1hZKdN4Iwf89TwbQ3emdNllbMJ92c3p8cHnJHAs9zPfZtC
1bIRxPksawJFHl4jG4xWQ0TdjAcXP/2T4EbKXNqP8O2+ncw7GnfYBZSPTINnByrm5J28b
AWW7tzhEjLaAUuUus59hiV+fh6Vabqho5dnxKq546l7a8gwoDeIgySE2J7kFg2lRMMVmB
9ri38a+KkVXmL6PueU9uKEwCQf0sHSjth0NDZlLxcoExcsdPEwV+Ud8szSNIwi3r4Fg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795115001;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=bpLEycpua3oiW6PlqY9cG9z3XMx3iW2RiC0gfi/0zkY=;
b=gFW384mdXv4ybrNgvausVgDzfQUc8V23lPV0+BSj1S5oojaZkeeeftV3VvIDmz+IQRii
NeBe5EkOC0n79Qs35lHWdpPTBT5RVpDfQ/ceUSU44yhDtv16FgGq32R3Qx2B/AdR7WneJ
yuiiENL4C/6ZhSiJ1F1sfX+m16kI/+zCgEBdPSZn7p1IwCzYZevHqNRhADu7DEnhWI94f
hAQRtFw6NRECvk1luN+yDqJ33Lb+QCN1tBaB08xVquvoOkmzYG7hwiAQStgwFtNdQe6C3
d4B7UK/NzoVsxY1WA+oruI/cFw/iFUeg+LRiAY/oaei+ctWC5WcosBtiYW4xl4SZtXA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=networkplumber.org;
spf=pass smtp.mailfrom=networkplumber.org;
dkim=pass header.d=networkplumber-org.20260707.gappssmtp.com header.i=@networkplumber-org.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=a1xVWpuk;
arc=none smtp.remote-ip=209.85.214.174
X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 416EA60A2609
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 19:03:21 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 416EA60A2609
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org
X-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2f03eeda984so329155ad.2
for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 11:03:21 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=networkplumber-org.20260707.gappssmtp.com; s=20260707; t=1795115000; x=1795719800; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=bpLEycpua3oiW6PlqY9cG9z3XMx3iW2RiC0gfi/0zkY=;
b=a1xVWpukVGvUbGtbxnG1+ydUx1xW+lt1/+QPN6tn0hCIPQyVzgFP8cvUOz/w262AI+
UIQlK9+x9XjORJ7J86L/cEwWfCO/J4LjxpRPg+pbWqFM74GJdrOdjo+1owjDo1NDzW6C
vGzPvJwzn1oui4luLl8uMoUANHDIPXFaDCakyIh5FJ5THWIA6YeTCix0SwqVnxg9W2hL
O8kJ+TACeiX3aSJwPr4zzpJGEsvILwmSk6fiZciJoJr3UTeOsgbpkoJYxD7J8ys7RlQI
9So1QAhTDniN27LBcXf70WsKPJcSYltvyjuCa3xkQn9cnfVzPek+FYBhkYvc4xN6y2GO
HYLw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795115000; x=1795719800;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=bpLEycpua3oiW6PlqY9cG9z3XMx3iW2RiC0gfi/0zkY=;
b=BWHlgc9uU13wV1wo5FnNE1sEzsUtYpAifZioG4zHd8knwLACOwbo4hjHlEXZ0yUfL/
gTqZ7QHJVfVnn1sACJHy7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nny/OWks2bSEinQQ==
X-Received: by 2002:a17:902:d503:b0:2ef:d8a0:9e4e with SMTP id d9443c01a7336-2f03f1971ccmr8957185ad.22.1795115000491;
Thu, 19 Nov 2026 11:03:20 -0800 (PST)
X-Received: from phoenix.lan (204-195-112-43.wavecable.com. [204.195.112.43])
by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f0de00asm3750225ad.35.2026.11.19.11.03.19
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 19 Nov 2026 11:03:20 -0800 (PST)
X-Cc: dsahern@kernel.org,
Stephen Hemminger <stephen@networkplumber.org>,
Toke Høiland-Jørgensen <toke@redhat.com>,
Hangbin Liu <haliu@redhat.com>
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <20261119190312.578885-1-stephen@networkplumber.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list