Re: [PATCH bpf-next 1/2] bpf: add bpf_dynptr_memset() kfunc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/19/25 10:19 AM, Eduard Zingerman wrote:
On Thu, 2025-06-19 at 10:09 -0700, Ihor Solodrai wrote:

[...]

But then, does memset even make sense for xdp/skb buffers?

Why not?

I was thinking that in a BPF program you'd usually be reading xdp/skb
and not writing to it, especially not via memset. But never mind, I am
likely wrong.


Maybe -ENOTSUPP is more appropriate?

I'd appreciate any hints.

I think Mykyta has kernel/trace/bpf_trace.c:__bpf_dynptr_copy_str() in mind.

Thanks for the pointer. So it looks like memset can use
bpf_dynptr_slice_rdwr() to handle xdp/skb cases. Something like:

    void *ptr = bpf_dynptr_slice_rdwr(&dynptr, 0, buffer, sizeof(buffer));
    if (!ptr)
        return -EINVAL;

    memset(ptr, val, n);

    if (ptr == buffer)
        bpf_dynptr_write(&dynptr, 0, buffer, sizeof(buffer), 0);








[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux