On 25/06/2021 00.39, Alexei Starovoitov wrote:
On Thu, Jun 24, 2021 at 3:18 PM Desouza, Ederson
<ederson.desouza@xxxxxxxxx> wrote:
Wait - it may be done in user space by libbpf, but it needs the
instrumented object code. It won't work for pure user space
applications, like those which use AF_XDP. Unless we're going to build
them in a special way, like we do for the kernel side of BPF
applications.
It can be made to work. See my reply to Magnus.
It's not a lot of code to make that happen.
I agree with Alexei, it will not be a lot of code to interpret the BTF
info in userspace.
In userspace AF_XDP code, we could simply decode the offset of e.g.
member named "rxhash32" and validate that the expected size is 32 bit (4
bytes). Then we store the offset associated with rxhash32 for a given
BTF-ID. When AF_XDP program see BTF-ID it can lookup the offset of
rxhash32 and move those 4-bytes into a variable for rxhash32.
Implementation details (sorry to complicate this slightly): Because
metadata area grows with a negative offset seen from ctx->data, and
AF_XDP descriptor don't know the size of metadata area (like XDP does).
Then the offset we store (e.g. associated with rxhash32) need to be
converted to a negative offset from packet ctx->data start.
--Jesper