[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <7a5067a7-2a76-45d3-8995-87eff3e5996d@app.fastmail.com>
Date: Sat, 07 Dec 2024 15:15:34 -0800
From: "Daniel Xu" <dxu@...uu.xyz>
To: "Martin KaFai Lau" <martin.lau@...ux.dev>
Cc: "Alexei Starovoitov" <ast@...nel.org>, "Jakub Kicinski" <kuba@...nel.org>,
"Andrii Nakryiko" <andrii@...nel.org>,
"Jesper Dangaard Brouer" <hawk@...nel.org>, qmo@...nel.org,
"John Fastabend" <john.fastabend@...il.com>,
"David Miller" <davem@...emloft.net>,
"Daniel Borkmann" <daniel@...earbox.net>,
"Eduard Zingerman" <eddyz87@...il.com>, "Song Liu" <song@...nel.org>,
"Yonghong Song" <yonghong.song@...ux.dev>, "KP Singh" <kpsingh@...nel.org>,
"Stanislav Fomichev" <sdf@...ichev.me>, "Hao Luo" <haoluo@...gle.com>,
"Jiri Olsa" <jolsa@...nel.org>, "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
"Antony Antony" <antony@...nome.org>,
Toke Høiland-Jørgensen <toke@...nel.org>
Subject: Re: [PATCH bpf-next] bpftool: btf: Support dumping a single type from file
On Fri, Dec 6, 2024, at 5:50 PM, Martin KaFai Lau wrote:
> On 12/6/24 3:29 PM, Daniel Xu wrote:
>> diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c
>> index d005e4fd6128..668ff0d10469 100644
>> --- a/tools/bpf/bpftool/btf.c
>> +++ b/tools/bpf/bpftool/btf.c
>> @@ -953,6 +953,7 @@ static int do_dump(int argc, char **argv)
>> NEXT_ARG();
>> } else if (is_prefix(src, "file")) {
>> const char sysfs_prefix[] = "/sys/kernel/btf/";
>> + char *end;
>>
>> if (!base_btf &&
>> strncmp(*argv, sysfs_prefix, sizeof(sysfs_prefix) - 1) == 0 &&
>> @@ -967,6 +968,17 @@ static int do_dump(int argc, char **argv)
>> goto done;
>> }
>> NEXT_ARG();
>> +
>> + if (argc && is_prefix(*argv, "root_id")) {
>> + NEXT_ARG();
>> + root_type_ids[root_type_cnt++] = strtoul(*argv, &end, 0);
>
> I only looked at the do_dump(). Other existing root_type_ids are from
> the kernel
> map_get_info and they should be valid. I haven't looked at the
> dump_btf_*, so
> ask a lazy question, is an invalid root_id handled properly?
>
> Others lgtm.
Good question. Passing an invalid btf ID results in half the
boilerplate being printed to terminal before an early exit and
an unclean return code.
Probably not be the best way to error. I'll send v2 with an
earlier error check.
Thanks,
Daniel
Powered by blists - more mailing lists