Re: make XDP program aware of multi buffer

Toke Høiland-Jørgensen <[email protected]> Wed, 30 Nov 2022 14:11:03 +0100
Newsgroups org.kernel.vger.xdp-newbies
Message-ID <[email protected]>
Henning Fehrmann <[email protected]> writes:

>> You just replace:
>> 
>> SEC("xdp")
>> 
>> with
>> 
>> SEC("xdp.frags")
>> 
>> in your source file and, assuming your libbpf version is up-to-date,
>> that should be it as far as the kernel is concerned.
>
> Nice. It loads now. I appreciate the work done for multi buffer packets.

Cool!

>> However, you obviously also need to make sure there are no semantic
>> issues in your program before doing this. I.e., data_end is no longer
>> the end of your packet, so if you are using data_end-data to calculate
>> the packet len, that will no longer be accurate. If you need to access
>> data beyond the first frag you'll need to use the
>> xdp_{load,store}_bytes() helpers.
>
> I guess, this is not the case or does bpf_redirect needs it if I have
> multi frame packets?
> I realized that redirection actually doesn't happen if the packets
> exceed the page size.

No, XDP_REDIRECT is not supported at all for multi-frame packets:
https://elixir.bootlin.com/linux/latest/source/net/core/filter.c#L4278

Cc Lorenzo who was looking into enabling this at some point...

-Toke