Am 23.01.25 um 20:51 schrieb Stanislav Fomichev:
On 01/23, Marcus Wichelmann wrote:
Am 23.01.25 um 17:38 schrieb Toke Høiland-Jørgensen:
Marcus Wichelmann <marcus.wichelmann@xxxxxxxxxxxxxxxx> writes:
There is probably a check missing somewhere that prevents the use of
these kfuncs in the scope of do_xdp_generic?
Heh, yeah, we should definitely block device-bound programs from being
attached in generic mode. Something like the below, I guess. Care to
test that out?
-Toke
Ah, thanks for the quick patch. ;)
I have tested your patch with the 6.12 branch I'm currently working with and this does the job.
# bpftool prog load crash.o /sys/fs/bpf/crash xdpmeta_dev mlx5-conx5-1
# bpftool net attach xdpgeneric pinned /sys/fs/bpf/crash dev mlx5-conx5-1
libbpf: Kernel error message: Can't attach device-bound programs in generic mode
Error: interface xdpgeneric attach failed: Invalid argument
The do_xdp_generic is also used by the tun driver as a fallback in some cases, so, to my understanding,
even programs attached in driver-mode may take the generic XDP path. How can this be handled there?
[..]
Currently, it's not an issue, because the tun driver does not implement the xdp_metadata_ops yet, but
it may become one in the future.
We can solve it if/when we add metadata_ops to the tun driver, right?
Not sure we need any immediate action right now.
Yeah, that's not needed for now.
I'm currently playing around with implementing a "bpf_xdp_metadata_rx_vnethdr" RX metadata kfunc that allows
to retrieve the virtio_net_hdr from an XDP program attached to the tun driver (to trigger the TX offloads
requested by a VM). That's why I discovered this.
But that's probably a story for another day. ;) I'll submit a patch when I have something working so it can be
discussed and we can see if that has a chance to be upstreamable.
Marcus