On 7/11/25 11:44 AM, Daniel Borkmann wrote: > Extend 'inhibit=on' setting with the option to specify a pinned XSK map > path along with a starting index (default 0) to push the created XSK > sockets into. Example usage: > > # ./build/qemu-system-x86_64 [...] \ > -netdev > af-xdp,ifname=enp2s0f0np0,id=net0,mode=native,queues=2,start-queue=14,inhibit=on,map-path=/sys/fs/bpf/xsks_map,map-start-index=14 > \ > -device virtio-net-pci,netdev=net0 [...] > > This is useful for the case where an existing XDP program with XSK map > is present on the AF_XDP supported phys device and the XSK map is not > yet populated. For example, the former could have been pre-loaded onto > the netdevice by a control plane, which later launches QEMU to populate > it with XSK sockets. > > Normally, the main idea behind 'inhibit=on' is that the QEMU instance > doesn't need to have a lot of privileges to use the pre-loaded program > and the pre-created sockets, but this mentioned use-case here is different > where QEMU still needs privileges to create the sockets. > > The 'map-start-index' parameter is optional and defaults to 0. It allows > flexible placement of the XSK sockets, and is up to the user to specify > when the XDP program with XSK map was already preloaded. In the simplest > case the queue-to-map-slot mapping is just 1:1 based on ctx->rx_queue_index > but the user might as well have a different scheme (or smaller map size, > e.g. ctx->rx_queue_index % max_size) to push the inbound traffic to one > of the XSK sockets. > > Note that the bpf_xdp_query_id() is now only tested for 'inhibit=off' > since only in the latter case the libxdp takes care of installing the > XDP program which was installed based on the s->xdp_flags pointing to > either driver or skb mode. For 'inhibit=on' we don't make any assumptions > and neither go down the path of probing all possible options in which > way the user installed the XDP program. > > Signed-off-by: Daniel Borkmann <dan...@iogearbox.net> > Cc: Ilya Maximets <i.maxim...@ovn.org> > Cc: Jason Wang <jasow...@redhat.com> > Cc: Anton Protopopov <as...@isovalent.com> > --- > net/af-xdp.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++--- > qapi/net.json | 29 +++++++++++------ > qemu-options.hx | 23 ++++++++++++-- > 3 files changed, 118 insertions(+), 17 deletions(-)
Still works. Thanks! Reviewed-by: Ilya Maximets <i.maxim...@ovn.org>