Re: [RFC PATCH bpf-next 11/16] bpf: implement query for target_proto and file dumper prog_id

Yonghong Song
2020-04-10T06:11:56Z

On 4/9/20 8:10 PM, Alexei Starovoitov wrote:
> On Wed, Apr 08, 2020 at 04:25:33PM -0700, Yonghong Song wrote:
>> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
>> index a245f0df53c4..fc2157e319f1 100644
>> --- a/tools/include/uapi/linux/bpf.h
>> +++ b/tools/include/uapi/linux/bpf.h
>> @@ -113,6 +113,7 @@ enum bpf_cmd {
>> BPF_MAP_DELETE_BATCH,
>> BPF_LINK_CREATE,
>> BPF_LINK_UPDATE,
>> + BPF_DUMP_QUERY,
>> };
>>
>> enum bpf_map_type {
>> @@ -594,6 +595,18 @@ union bpf_attr {
>> __u32 old_prog_fd;
>> } link_update;
>>
>> + struct {
>> + __u32 query_fd;
>> + __u32 flags;
>> + union {
>> + struct {
>> + __aligned_u64 target_proto;
>> + __u32 proto_buf_len;
>> + };
>> + __u32 prog_id;
>> + };
>> + } dump_query;
>
> I think it would be cleaner to use BPF_OBJ_GET_INFO_BY_FD instead of
> introducing new command.

Right, using BPF_OBJ_GET_INFO_BY_FD should be good. Previously, I
am using target/dumper name to query and later I changed to fd,
but still used BPF_DUMP_QUERY...