[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <814a49f7-68b5-e796-7254-2a4ce9c0af74@fb.com>
Date: Thu, 9 Apr 2020 23:09:39 -0700
From: Yonghong Song <yhs@...com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
CC: Andrii Nakryiko <andriin@...com>, <bpf@...r.kernel.org>,
Martin KaFai Lau <kafai@...com>, <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>, <kernel-team@...com>
Subject: Re: [RFC PATCH bpf-next 05/16] bpf: create file or anonymous dumpers
On 4/9/20 8:00 PM, Alexei Starovoitov wrote:
> On Wed, Apr 08, 2020 at 04:25:26PM -0700, Yonghong Song wrote:
>> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
>> index 0f1cbed446c1..b51d56fc77f9 100644
>> --- a/include/uapi/linux/bpf.h
>> +++ b/include/uapi/linux/bpf.h
>> @@ -354,6 +354,7 @@ enum {
>> /* Flags for accessing BPF object from syscall side. */
>> BPF_F_RDONLY = (1U << 3),
>> BPF_F_WRONLY = (1U << 4),
>> + BPF_F_DUMP = (1U << 5),
> ...
>> static int bpf_obj_pin(const union bpf_attr *attr)
>> {
>> - if (CHECK_ATTR(BPF_OBJ) || attr->file_flags != 0)
>> + if (CHECK_ATTR(BPF_OBJ) || attr->file_flags & ~BPF_F_DUMP)
>> return -EINVAL;
>>
>> + if (attr->file_flags == BPF_F_DUMP)
>> + return bpf_dump_create(attr->bpf_fd,
>> + u64_to_user_ptr(attr->dumper_name));
>> +
>> return bpf_obj_pin_user(attr->bpf_fd, u64_to_user_ptr(attr->pathname));
>> }
>
> I think kernel can be a bit smarter here. There is no need for user space
> to pass BPF_F_DUMP flag to kernel just to differentiate the pinning.
> Can prog attach type be used instead?
Good point. Yes, no need for BPF_F_DUMP, expected_attach_type
is enough. Will change.
Powered by blists - more mailing lists