Article View: linux.kernel.netdev
Article #6049Re: [PATCH bpf-next v2 5/6] libbpf: Add bpf_link_create_log API
From: Leon Hwang
Date: Wed, 21 Oct 2026 15:26
Date: Wed, 21 Oct 2026 15:26
81 lines
12322 bytes
12322 bytes
On 2026/10/21 07:25, Andrii Nakryiko wrote:
> On Mon, Oct 19, 2026 at 8:37 AM Leon Hwang <leon.hwang@linux.dev> wrote:
[...]
>> --- a/tools/lib/bpf/bpf.h
>> +++ b/tools/lib/bpf/bpf.h
>> @@ -484,6 +484,11 @@ LIBBPF_API int bpf_link_create(int prog_fd, int target_fd,
>> enum bpf_attach_type attach_type,
>> const struct bpf_link_create_opts *opts);
>>
>> +LIBBPF_API int bpf_link_create_log(int prog_fd, int target_fd,
>> + enum bpf_attach_type attach_type,
>> + const struct bpf_link_create_opts *opts,
>> + struct bpf_log_opts *log_opts);
>
> Leon,
>
> how about instead of adding this new API, we try to repurpose
> bpf_link_create_opts' iter_info to be used as log opts? we have this
> right now:
>
> union bpf_iter_link_info; /* defined in up-to-date linux/bpf.h */
> struct bpf_link_create_opts {
> size_t sz; /* size of this struct for forward/backward compatibility */
> __u32 flags;
> union bpf_iter_link_info *iter_info;
> __u32 iter_info_len;
> __u32 target_btf_id;
> union {
>
>
> that iter_info/iter_info_len is a bit of a legacy before we had
> per-attach type union, what if we add iter section into the union,
> wrap iter_info with union and put log_opts there, mark iter_info
> deprecated or something.
>
> I'm not sure anyone is actually using iter_info (I didn't find any
> uses in Meta code base, for instance), but we can detect its use by
> checking iter_info_len: if it's non-zero, then iter_info must be a
> real bpf_iter_link_info. so we should be able to detect this just
> fine, the only downside is that you can't use log_opts and iter_info
> simultaneously, but I think that's fine: you can update your code to
> use new iter.info fields instead, if you need log_opts + iter_info.
>
> WDYT?
>
IIUC, the struct bpf_link_create_opts will be changed to
struct bpf_link_create_opts {
size_t sz; /* size of this struct for forward/backward compatibility */
__u32 flags;
union {
union bpf_iter_link_info *iter_info;
struct bpf_log_opts *log_opts;
};
__u32 iter_info_len;
__u32 target_btf_id;
union {
/* ... */
struct {
union bpf_iter_link_info *info;
__u32 len;
} iter;
};
};
Thereafter, iter.info is preferred against iter_info. And to keep
backward compatibility, iter_info is used only when iter_info_len is
set. But iter_info_len and iter.len are not allowed to be set at the
same time.
With this change, the bpf_link_create_log API can be dropped.
I'd like to drop the bpf_link_create_log API first, then add iter.info
in the series of log support for iter link_create in the future.
Thanks,
Leon
Technical Details
Message-ID:
<d4fc4fcd-3691-4122-8b3e-a75447956255@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350078-linux-kernel-netdev=dewy.ruReferences:
<20261019153628.15912-1-leon.hwang@linux.dev> <20261019153628.15912-6-leon.hwang@linux.dev> <CAEf4Bzbr46UkiE1sbb+Zwcs0S1ejpKmtTGjNCAkWD-J6FRcPGQ@mail.gmail.com>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-350078-linux-kernel-netdev=dewy.ru From: leon.hwang@linux.dev (Leon Hwang) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf-next v2 5/6] libbpf: Add bpf_link_create_log API Date: Wed, 21 Oct 2026 23:26:53 +0800 Organization: Usenet Network Message-ID: <d4fc4fcd-3691-4122-8b3e-a75447956255@linux.dev> References: <20261019153628.15912-1-leon.hwang@linux.dev> <20261019153628.15912-6-leon.hwang@linux.dev> <CAEf4Bzbr46UkiE1sbb+Zwcs0S1ejpKmtTGjNCAkWD-J6FRcPGQ@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4183076"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:h0CmCKd9aAzoMZJBz+Jx8uF2Jrs= sha256:l/QFgl2NYilF0c8e/0gyqxgy8Gg4Zw2VjLxfOWOMiBo= sha1:tgr6iocUaR0dcM0IP5ZkhnrYLwQ= sha256:XWym1fjQlxspVdp7akx80o1hb7KAeWJlxG8K3sQnvKA= Content-Language: en-US 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 F20E2111054; Wed, 21 Oct 2026 18:35:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.149 X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev 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 YSBq1ioCdIEB; Wed, 21 Oct 2026 18:35:01 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-350078-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id E4A6C111051; Wed, 21 Oct 2026 18:34:50 +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 526E260BF57; Wed, 21 Oct 2026 15:27:23 +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=1792596429; b=rfDts/XLuvjoa+OL2uF+ifFBp9T3PjH8VZe9lKqejk8SaeXIhtM9wivTDIH8wZ9eBN4u W0ue64ft9oKAQXna+VoeCwy6WjEgXoqnbIyZPAGzBTldStaQE9cJDbsTCnxhnAac6mMJd HN3J7774IySMs77UEW48nkw4OHokWtwbXGi5T1uDsaJ5Mr7NIApvup5UIbALdsS14V/i7 pVPXaeKrtZ9cokZyJMSVJml3XK5K9wPZwCI3FDvh4OALX6INjdkgkCzKNvCNA0Ab60uXx JoKTDglogNX2goOZ4jmThJ0bduXXDolPmmyFqx2UV0nj6xbubEiFD2tdC0U4jSAdOUA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792596429; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=7u12V9IkOC6OCXkyrR+5JkrF5I55CVZGjObxU6YEcfE=; b=rS8OZGDI7W1ecvsf95DGgSVamRT46S2DQ8cGvHXh4Mvd+s3/BfqxZ40mfxvB/QvD9Jy+ iKQ0Dwhq0XUEx/4BZHhnoPe6anEEDpY4/i4mvLaDyb09F6xkfJbXNR6J72phBHhunvbqf G/15lT9EafoXanNdVN+oO2zE4vJt/83qm/MjkfzX++vkTnVjuN5yoG1PaPPGfDopnC38k V2zyiGz+9dpjQWO3DRe02e5s0UJmliJ7hAUvHJ8KYGvSIn0XYZoKe7EQvtZ21s4wa6xu8 vgZkU4FXLCMEVmymxtwDYvo40S2O5xOOGR3jETbB0QK8Y7LaHmh6pyOhJQNFumYYohQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=drBWN0f6; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 44421606A335; Wed, 21 Oct 2026 15:27:09 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=drBWN0f6 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.216 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792596428; b=P5m6NUPVlVnmyU/OMOnXtT8kAqfy/s3M8uB73fSOS/iFcauSYaQ6ScX4ML+d5bFrlOJv 1ISEEus+fN+w0b573SLBLtoeN73mzZ3hshnF7gZygc8snQRPEHFznpcW+PZcs31nVTEdq BuD/lqXsLmYQtWo3kbImbLgIaePe73sy2XQ/xNsgVdeOV1GulGVQYP3OGIz3CrvObqia3 c0Sdklbv9AjUut3JfE72efz4mzDcSAvQpuT0GbbgdzIlAns7E2tp+EVoWT1UpHDtx39g1 vJC8bUhccgolQLhSJrjorhAWmma9TTlAPR5y8DwtgAfuEjWzX2B/MyTlz8hZFA0mp+w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792596428; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=7u12V9IkOC6OCXkyrR+5JkrF5I55CVZGjObxU6YEcfE=; b=3Kk8Bj8VpjbWgyl7jODmh5KFTB7E3lLSc/HKC9HQzPjkSMEW/fmvT8HkKdP4a8ZS8ZD6 yyBb9Tl8ZhHNJ9QSn3H2ZGWzlYTUgzeByJel8Z8fsGjQTMinXkvM/T9kPsTCqPc3463Ia zscrK2g5umdTFg0gYSEVMDcfLbzeqcg96YtYH2m61M/pg4zLp3dkYK5nwZWpu18bPWl2j VsEanbuw5v6yBEXwNCTCxw7v7o7XnXJ8QqLNiT4pQMTaJbj8dcgvcQX8dP7ZoTo0szKFl GLGXRtb843mSg8uC/3VlmNpxElrn+VFh7Xqe8b/62MK2VvWUAIsw0FvgoaSlh2sPpKw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=drBWN0f6; arc=none smtp.remote-ip=91.218.175.216 X-Received: from mta0.migadu.com (out-216.mta0.migadu.com [91.218.175.216]) (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 B5C78606A31B for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 15:27:07 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B5C78606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=+P6E8QMJjylqUM1Utclh5doG1xiwTif64c3j63D7imU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792596425; v=1; x=1793201225; b=drBWN0f61iezmAUCy9GyBFw7OcdUaebMKu/KkuGdg5Av9x58dmjth6iJx7SQNuALWismj2Cq JGbKemdCPxYcDFA4lPK9AKB0/3l9l4xKkw4Qu3IP4pFyDDgJRVNPTiyRtu6+/v6buRjQBimx2+B wqEspHJiY5v5l5YFtkMZ+1BE= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 177ceabd93ead9d1; Wed, 21 Oct 2026 15:27:05 +0000 X-Mizu-Trace-ID: 177ceabd93ead9d1 X-Migadu-Flow: FLOW_OUT 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-User-Agent: Mozilla Thunderbird X-Cc: bpf@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, Jesper Dangaard Brouer <hawk@kernel.org>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Shuah Khan <shuah@kernel.org>, Kuniyuki Iwashima <kuniyu@google.com>, Hangbin Liu <liuhangbin@gmail.com>, Martin Karsten <mkarsten@uwaterloo.ca>, Masashi Honma <masashi.honma@gmail.com>, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org X-In-Reply-To: <CAEf4Bzbr46UkiE1sbb+Zwcs0S1ejpKmtTGjNCAkWD-J6FRcPGQ@mail.gmail.com>