On 6/19/25 10:57 AM, Eduard Zingerman wrote:
On Thu, 2025-06-19 at 10:55 -0700, Ihor Solodrai wrote:
[...]
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);
I think so. In a loop.
But allocating and copying buffers for memset...
It should be possible to walk through fragments like
net/core/filter.c:bpf_xdp_copy_buf does.
Any reasons it's a bad idea?