Re: No direct copy from ctx to map possible, why?

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

 



Have you tried bpf_xdp_output() helper ?
I haven't. Can I use that helper even though my program isn't related to perf at all?
I'll definitely give it a try. Thanks

On 4/16/24 7:12 AM, Hengqi Chen wrote:
On Mon, Apr 15, 2024 at 5:41 AM Fabian Pfitzner
<f.pfitzner@xxxxxxxxxxxxxxxxxx> wrote:
Hello,

is there a specific reason why it is not allowed to copy data from ctx
directly into a map via the bpf_map_update_elem helper?
I develop a XDP program where I need to store incoming packets
(including the whole payload) into a map in order to buffer them.
I thought I could simply put them into a map via the mentioned helper
function, but the verifier complains about expecting another type as
"ctx" (R3 type=ctx expected=fp, pkt, pkt_meta, .....).

I was able to circumvent this error by first putting the packet onto the
stack (via xdp->data) and then write it into the map.
The only limitation with this is that I cannot store packets larger than
512 bytes due to the maximum stack size.

I was also able to circumvent this by slicing chunks, that are smaller
than 512 bytes, out of the packet so that I can use the stack as a
clipboard before putting them into the map. This is a really ugly
solution, but I have not found a better one yet.

Have you tried bpf_xdp_output() helper ?

So my question is: Why does this limitation exist? I am not sure if its
only related to XDP programs as this restriction is defined inside of
the bpf_map_update_elem_proto struct (arg3_type restricts this), so I
think it is a general limitation that affects all program types.

Best regards,
Fabian Pfitzner








[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