mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lin Feng <linf@wangsu.com>
To: Daniel Borkmann <daniel@iogearbox.net>, ast@kernel.org
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	yonghong.song@linux.dev, Hou Tao <houtao1@huawei.com>,
	Brian Vazquez <brianvv@google.com>
Subject: Re: [PATCH] bpf: fix excessively checking for elem_flags in batch update mode
Date: Mon, 22 Jul 2024 09:54:38 +0800	[thread overview]
Message-ID: <6a8b1a57-c7b6-81c6-5e77-759cb041a77b@wangsu.com> (raw)
In-Reply-To: <7d351341-fefe-a40f-f62a-d9505432d056@iogearbox.net>

Hi Daniel,

Thanks for your reply! Without basic knowledge of rules of thumb for patch in
bpf, I didn't expect a single line change need that many more considerations,
and will do some more work on it following your sugguestion!

Thanks,
linfeng

On 7/20/24 00:22, Daniel Borkmann wrote:
> On 7/17/24 1:15 PM, Lin Feng wrote:
>> Currently generic_map_update_batch will reject all valid command flags for
>> BPF_MAP_UPDATE_ELEM other than BPF_F_LOCK, which is overkill, map updating
>> semantic does allow specify BPF_NOEXIST or BPF_EXIST even for batching
>> update.
>>
>> Signed-off-by: Lin Feng <linf@wangsu.com>
> 
> [ +Hou/Brian ]
> 
> Please also add a BPF selftest along with this extension which exercises the
> batch update and validates the behavior for the various flags which are now enabled.
> 
> Also, please discuss the semantics in the commit msg.. errors due to BPF_EXIST and
> BPF_NOEXIST will cause bpf_map_update_value() to fail and then break the loop. It's
> probably fine given batch.count (cp) will be propagated back to user space to tell
> how many elements could actually get updated.
> 
>> ---
>>   kernel/bpf/syscall.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>> index 869265852d51..d85361f9a9b8 100644
>> --- a/kernel/bpf/syscall.c
>> +++ b/kernel/bpf/syscall.c
>> @@ -1852,7 +1852,7 @@ int generic_map_update_batch(struct bpf_map *map, struct file *map_file,
>>   	void *key, *value;
>>   	int err = 0;
>>   
>> -	if (attr->batch.elem_flags & ~BPF_F_LOCK)
>> +	if ((attr->batch.elem_flags & ~BPF_F_LOCK) > BPF_EXIST)
>>   		return -EINVAL;
>>   
>>   	if ((attr->batch.elem_flags & BPF_F_LOCK) &&
>>
> 


  reply	other threads:[~2024-07-22  1:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 11:15 Lin Feng
2024-07-19 16:22 ` Daniel Borkmann
2024-07-22  1:54   ` Lin Feng [this message]
2024-07-23  1:21   ` Hou Tao
2024-07-23  1:44     ` Lin Feng

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=6a8b1a57-c7b6-81c6-5e77-759cb041a77b@wangsu.com \
    --to=linf@wangsu.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brianvv@google.com \
    --cc=daniel@iogearbox.net \
    --cc=houtao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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

all inboxes | Powered by JetHome®