Thread (7 messages) flat view 7 messages, 3 authors, 2025-02-03

Re: [PATCH 1/1] net: tun: add XDP metadata support

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2025-02-03 01:39:47
Also in: bpf, lkml

quoted
quoted
quoted
+		metasize = metasize > 0 ? metasize : 0;
Why is this part needed?
When an xdp_buff was initialized withouth metadata support (meta_valid
argument of xdp_prepare_buff is false), then data_meta == data + 1.
So this check makes sure that metadata was supported for the given xdp_buff
and metasize is not -1 (data - data_meta).

But you have a good point here: Because we have control over the
initialization of xdp_buff in the tun_build_skb function (first code path),
we know, that metadata is always supported for that buffer and metasize
is never < 0. So this check is redundant and I'll remove it.

But in the tun_xdp_one function (second code path), I'd prefer to keep that
check, as the xdp_buff is externally passed to tun_sendmsg and the tun driver
should probably not make assumptions about the metadata support of buffers
created by other drivers (e.g. vhost_net).

Thank you for taking a look, I hope things are more clear now.
Please use min()
Err.. max.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help