From: Kui-Feng Lee <sinquersw@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Kui-Feng Lee <thinker.li@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev,
yhs@meta.com, song@kernel.org, kernel-team@meta.com,
andrii@kernel.org, Kui-Feng Lee <kuifeng@meta.com>,
Quentin Monnet <quentin@isovalent.com>
Subject: Re: [PATCH bpf-next v2] bpftool: Show map IDs along with struct_ops links.
Date: Fri, 21 Apr 2023 09:21:02 -0700 [thread overview]
Message-ID: <5f23696d-d7bd-774d-c45a-8a6bb13b9cb5@gmail.com> (raw)
In-Reply-To: <CAEf4BzY3DOYZOQBfvvOEGdKaUF+M8DS8Q33devTWzjcEHkOuQg@mail.gmail.com>
On 4/20/23 16:41, Andrii Nakryiko wrote:
> On Tue, Apr 18, 2023 at 5:37 PM Kui-Feng Lee <thinker.li@gmail.com> wrote:
>>
>> A new link type, BPF_LINK_TYPE_STRUCT_OPS, was added to attach
>> struct_ops to links. (226bc6ae6405) It would be helpful for users to
>> know which map is associated with the link.
>>
>> The assumption was that every link is associated with a BPF program, but
>> this does not hold true for struct_ops. It would be better to display
>> map_id instead of prog_id for struct_ops links. However, some tools may
>> rely on the old assumption and need a prog_id. The discussion on the
>> mailing list suggests that tools should parse JSON format. We will maintain
>> the existing JSON format by adding a map_id without removing prog_id. As
>> for plain text format, we will remove prog_id from the header line and add
>> a map_id for struct_ops links.
>>
>> Signed-off-by: Kui-Feng Lee <kuifeng@meta.com>
>> Reviewed-by: Quentin Monnet <quentin@isovalent.com>
>> ---
>> tools/bpf/bpftool/link.c | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c
>> index f985b79cca27..8eb8520bd7b4 100644
>> --- a/tools/bpf/bpftool/link.c
>> +++ b/tools/bpf/bpftool/link.c
>> @@ -195,6 +195,10 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
>> info->netns.netns_ino);
>> show_link_attach_type_json(info->netns.attach_type, json_wtr);
>> break;
>> + case BPF_LINK_TYPE_STRUCT_OPS:
>> + jsonw_uint_field(json_wtr, "map_id",
>> + info->struct_ops.map_id);
>> + break;
>> default:
>> break;
>> }
>> @@ -227,7 +231,10 @@ static void show_link_header_plain(struct bpf_link_info *info)
>> else
>> printf("type %u ", info->type);
>>
>> - printf("prog %u ", info->prog_id);
>> + if (info->type == BPF_LINK_TYPE_STRUCT_OPS)
>> + printf("map_id %u ", info->struct_ops.map_id);
>> + else
>> + printf("prog %u ", info->prog_id);
>
> if we output "prog %u" for prog_id, shouldn't we just output "map %u"
> for map_id?
"map" make sense to me.
>
>> }
>>
>> static void show_link_attach_type_plain(__u32 attach_type)
>> --
>> 2.34.1
>>
prev parent reply other threads:[~2023-04-21 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 0:36 [PATCH bpf-next v2] bpftool: Show map IDs along with struct_ops links Kui-Feng Lee
2023-04-19 23:25 ` Quentin Monnet
2023-04-20 0:23 ` Kui-Feng Lee
2023-04-20 23:41 ` Andrii Nakryiko
2023-04-21 16:21 ` Kui-Feng Lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f23696d-d7bd-774d-c45a-8a6bb13b9cb5@gmail.com \
--to=sinquersw@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@meta.com \
--cc=kuifeng@meta.com \
--cc=martin.lau@linux.dev \
--cc=quentin@isovalent.com \
--cc=song@kernel.org \
--cc=thinker.li@gmail.com \
--cc=yhs@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox