🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7088

Re: [PATCH bpf-next v4 4/6] libbpf: Factor out __sys_bpf_fd helper

#7088
From: bot+bpf-ci
Date: Sat, 24 Oct 2026 16:13
91 lines
11847 bytes
--===============8738876045916716804==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit

> libbpf: Factor out __sys_bpf_fd helper

TL;DR: Nit only, not a bug: the new libbpf helper __sys_bpf_fd() has a
misleading name and a different argument order (cmd not first) than
sys_bpf_fd(); a name like sys_bpf_fd_log() is suggested.

> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index b49822d212ae..9a2107d4f6d8 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -203,6 +203,30 @@ int bump_rlimit_memlock(void)
>  	return 0;
>  }
>
> +static int __sys_bpf_fd(union bpf_attr *attr, const size_t attr_sz, enum bpf_cmd cmd,
> +			struct bpf_log_opts *log_opts)
> +{
> +	const size_t attr_common_sz = sizeof(struct bpf_common_attr);
> +	struct bpf_common_attr attr_common;
> +	int fd;
> +
> +	if (!OPTS_VALID(log_opts, bpf_log_opts))
> +		return libbpf_err(-EINVAL);
> +
> +	if (log_opts && feat_supported(NULL, FEAT_BPF_SYSCALL_COMMON_ATTRS)) {
> +		memset(&attr_common, 0, attr_common_sz);
> +		attr_common.log_buf = ptr_to_u64(OPTS_GET(log_opts, buf, NULL));
> +		attr_common.log_size = OPTS_GET(log_opts, size, 0);
> +		attr_common.log_level = OPTS_GET(log_opts, level, 0);
> +		fd = sys_bpf_ext_fd(cmd, attr, attr_sz, &attr_common, attr_common_sz);
> +		OPTS_SET(log_opts, true_size, attr_common.log_true_size);
> +	} else {
> +		fd = sys_bpf_fd(cmd, attr, attr_sz);
> +		OPTS_SET(log_opts, true_size, 0);
> +	}
> +	return fd;
> +}
> +

[ ... ]

> @@ -248,20 +270,7 @@ int bpf_map_create(enum bpf_map_type map_type,
>  	attr.excl_prog_hash_size = OPTS_GET(opts, excl_prog_hash_size, 0);
>
>  	log_opts = OPTS_GET(opts, log_opts, NULL);
> -	if (!OPTS_VALID(log_opts, bpf_log_opts))
> -		return libbpf_err(-EINVAL);
> -
> -	if (log_opts && feat_supported(NULL, FEAT_BPF_SYSCALL_COMMON_ATTRS)) {
> -		memset(&attr_common, 0, attr_common_sz);
> -		attr_common.log_buf = ptr_to_u64(OPTS_GET(log_opts, buf, NULL));
> -		attr_common.log_size = OPTS_GET(log_opts, size, 0);
> -		attr_common.log_level = OPTS_GET(log_opts, level, 0);
> -		fd = sys_bpf_ext_fd(BPF_MAP_CREATE, &attr, attr_sz, &attr_common, attr_common_sz);
> -		OPTS_SET(log_opts, true_size, attr_common.log_true_size);
> -	} else {
> -		fd = sys_bpf_fd(BPF_MAP_CREATE, &attr, attr_sz);
> -		OPTS_SET(log_opts, true_size, 0);
> -	}
> +	fd = __sys_bpf_fd(&attr, attr_sz, BPF_MAP_CREATE, log_opts);
>  	return libbpf_err_errno(fd);
>  }

This isn't a bug, but __sys_bpf_fd() is a higher-level wrapper that
dispatches to sys_bpf_fd() or sys_bpf_ext_fd() after validating log_opts and
probing FEAT_BPF_SYSCALL_COMMON_ATTRS, while a leading double underscore
usually marks the lower-level variant of a function.

The helper also takes (attr, attr_sz, cmd, log_opts), whereas sys_bpf(),
sys_bpf_fd(), sys_bpf_ext() and sys_bpf_ext_fd() all take cmd first, so the
new call reads differently from the nearby calls:

    fd = __sys_bpf_fd(&attr, attr_sz, BPF_MAP_CREATE, log_opts);

Would a name that describes what the helper adds (for example something like
sys_bpf_fd_log()), with cmd as the first argument like the other sys_bpf*()
wrappers, read more naturally next to sys_bpf_fd() and sys_bpf_ext_fd()?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/40108748084
--===============8738876045916716804==--
Technical Details
Message-ID: <5d94730579f232c7be1c83bc7287e91af9a858bcea83765e58bdd2fc3956a229@mail.kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351419-linux-kernel-netdev=dewy.ru
References: <20261024153608.58569-5-leon.hwang@linux.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351419-linux-kernel-netdev=dewy.ru
From: bot+bpf-ci@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf-next v4 4/6] libbpf: Factor out __sys_bpf_fd helper
Date: Sat, 24 Oct 2026 16:13:52 +0000 (UTC)
Organization: Usenet Network
Message-ID: <5d94730579f232c7be1c83bc7287e91af9a858bcea83765e58bdd2fc3956a229@mail.kernel.org>
References: <20261024153608.58569-5-leon.hwang@linux.dev>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============8738876045916716804=="
Injection-Info: usenet.network;
	logging-data="801969"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:D9vL5QTuKiWBKAjgxk/l0H+C0w8= sha256:3pwjEoi1Lh7etLIApdpzlRU4JeodBv4JKhI8xJVZFdU=
	sha1:qEMBDSoVrr14R6lhSrt01Vd2wWs= sha256:jz8jgl/vmR+9rGvVus12xO70sByBM70hZIRKXd64keI=
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 6E11011167D; Sat, 24 Oct 2026 19:15:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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=kernel.org
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 EIwbmlh506Rw;
	Sat, 24 Oct 2026 19:15:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351419-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id DBDC0111642; Sat, 24 Oct 2026 19:15:08 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id C683B37511; Sat, 24 Oct 2026 16:14:04 +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=1792858444;
	b=Cu/IULvlIdW/gDhJQgXXrbQ7014BLVzCGBUVzcjC8IY+7/3LzqkUxA/WVuqwN6U0q4h+
	 rSt8lYaM5pJdHCGiBLSFIrvPfUy1EJwYs6JF5r2yZvy9284RUVpmNOjQgJyE/goxz9a40
	 M5Bi/rvdrvjIiM1LaUUWQqXw6qax/jZAmNthFGX7e1vbzUt4HDDgb7A4XfR8Ibhgsmgru
	 21SKhxtOg7iWUZg/yMwjvxt1mYu1L84x/meyAERIsMF7Nv8Tjds4d/a3aWiWmucGB4Ftr
	 RUI83vx2YpRIwEj5G2T8PnKfjBm6DXe2B2Y1QYPMeEK/pmvpjwzJYJ2dj7VHKRZruHw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792858444;
	h=X-Original-To:Received:Received:DKIM-Signature:Content-Type:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id:
	 In-Reply-To:References:Subject:From:To:Cc:Date;
	bh=Py+Z5I/MajAjJGZNOZOZq0i/a4XelqMNOHlME6I2PwE=;
	b=jtkpW1V7bvQIy8d7ulVILX8L5utfnh8AD0xeBDoYEGbYAFeqx+1O0UfR2T7XZ6skUpNG
	 XNkv4oLUpW79hWXHHDGbuNzyE0b5/4u45IDQRPr3jb5s5YHK/zVrWYfSNGWMgEoNTZ5MO
	 qQAu3d682fL0+meiIx3GR/VK0BTGTVGQ4sRq267oN1W7ro14CJqOl6L9Y4XgKNKbOusod
	 9UY5JIrKcpqaXFHx/BUYsB4aIBjB2SkRNXbcJjyenk0FRBxzxOw9E0S0VpNPS0nKaW+UA
	 6yJRutAWbw1yY0i9p+EUUih1C7tl+HneI8iZVxKIMBh0N/+mNZwDtgpfoB2cbcm97SQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KCgrczlB;
	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 9CC19606A322;
	Sat, 24 Oct 2026 16:14:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KCgrczlB
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792858433;
	b=FAC9chK0eotIqAUmU4LVdDCnm5vnSGTuLq5dSlBOUYAGMRnQXhK1d/vB1SG4t04ynW/A
	 39EEBAoa/38sxBZypr1KUikAYCy9cGbAcGSuNKttgSKDcGW2JAKXFgzQyGyKxMGgjtWjb
	 W1OxaYmzGlYXqQNm+ydSp/FJw0cDvqTDqYARTHhz5nIj/9RPOL8wfA+dnaqTysEigDEWs
	 ticdeBBst8OAEnko1uxEQUUzFQQex6KYg3y89puXqHXMjve/T5/LYmZBvC7moCc7af3Sf
	 /wRz1S+X0TfKfVqBg6lJ73mBgz9cbTGk/nzm32gHEEpoMji2DAANBTPoG3BZG8nTiWQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792858433;
	h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id:
	 In-Reply-To:References:Subject:From:To:Cc:Date;
	bh=Py+Z5I/MajAjJGZNOZOZq0i/a4XelqMNOHlME6I2PwE=;
	b=1yck0dQ04RA9RSoTT17mDfm5UMu8EpUw6ThAEuokSTjCxAEVdyw7fUDUjfRCwh/t9rDl
	 tzrCo00j6IZvP+JzupGho+WGUPoxHNrI2PgFzi9r3Ek+xw9ZyztxRwdVxHc1Eu+Sr2NFI
	 0pVbPo/f7wqVfewx/+NTS/o6vUopfUn7c3ERdIBQW0jOeI6aSUnYD6yEjm0Xx4clap521
	 kSOKT6TdxjBx6MvvQq/sX665pfg98C9LsuM8uAulyJm9A6oOKFo/lmlboO6Do8KVX7EMk
	 2KeYV5i2TPXGXhkZLdOVIjF8UsWyd/pNUTE2q/cz6v0jCqtx89y8VP1wJf6U63wHxEg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KCgrczlB;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7240D606A31B;
	Sat, 24 Oct 2026 16:13:53 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 571F71F01825;
	Sat, 24 Oct 2026 16:13:52 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792858433;
	bh=Py+Z5I/MajAjJGZNOZOZq0i/a4XelqMNOHlME6I2PwE=;
	h=In-Reply-To:References:Subject:From:To:Cc:Date;
	b=KCgrczlBlVN3/eYHL022erEAjqNxIylKBS+rv1PIHUkoS9gtD6TGfU8UCr1khuvQK
	 XfnHVDnrKZV4H4uoC8X5lGUvJFbrOta+CwKc62U//3rWHT5vGR1+I49KVEpm6lNzdA
	 s1DrJuAj4fTfFFAQ1NPEp2WpLa1zA7OX8jmIOYybhoi3CurGDEiWwjWwAxRkyldTi0
	 9uWVSkBBFSg9RxAOpllTsvkflpndKWbeXIQfEotQkhxcYod6LCx0agY+MaiBJa7eIn
	 4XLaVFgUfTgeh4S+Wjy6knO/vrCyjAGc3ljYEUtt+lSobTeJf/YviD9T5ZxEJksy+z
	 tRrfirMa0E+KA==
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
X-In-Reply-To: <20261024153608.58569-5-leon.hwang@linux.dev>
X-Cc: andrew+netdev@lunn.ch,davem@davemloft.net,edumazet@kernel.org,kuba@kernel.org,pabeni@redhat.com,horms@kernel.org,ast@kernel.org,daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,hawk@kernel.org,john.fastabend@gmail.com,sdf@fomichev.me,rostedt@goodmis.org,mhiramat@kernel.org,mathieu.desnoyers@efficios.com,shuah@kernel.org,kuniyu@google.com,liuhangbin@gmail.com,mkarsten@uwaterloo.ca,masashi.honma@gmail.com,linux-kernel@vger.kernel.org,netdev@vger.kernel.org,linux-trace-kernel@vger.kernel.org,linux-kselftest@vger.kernel.org,leon.hwang@linux.dev,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev