Re: qemu-kvm XDP forwarding with virtio_net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/20/18 7:18 AM, Pavel Popa wrote:
> Hi all,
> 
> I've implemented a XDP forwarding program using the bpf_fib_lookup()
> helper, and loaded it in the kernel as XDP driver mode (i.e. executed
> at the virtio_net driver level). The only problem is that the
> receiving virtio network interface seems to drop the XDP packet after
> successfully executing my XDP program.
> Kernel: 4.18.10
> 
> my_xdp_fwd_kern.c:
> /* made sure this returns 0 (i.e. BPF_FIB_LKUP_RET_SUCCESS) */
> rc = bpf_fib_lookup(ctx, &fib_params, sizeof(fib_params),
> BPF_FIB_LOOKUP_DIRECT);
> /* made sure this returns 4 (i.e. XDP_REDIRECT) */
> rc = bpf_redirect_map(&dev_map, fib_params.ifindex, 0);
> return rc;
> 
> I checked that rc is indeed XDP_REDIRECT and that fib_params.ifindex
> is the correct dev index from FIB lookup.
> dev_map is setup by the userspace my_xdp_fwd_user.c component as follows:
> for (i = 1; i < 64; i++)
>     bpf_map_update_elem(devmap_fd, &i, &i, BPF_ANY);
> 
> I'm passing the following to the qemu cmd line for the 2 devices I
> want to run XDP on (as stated here
> https://marc.info/?l=xdp-newbies&m=149486931113651&w=2):
> -device virtio-net-pci,mq=on,vectors=18,rx_queue_size=1024,tx_queue_size=512,
> ... ,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off,guest_ufo=off
> \
> -device virtio-net-pci,mq=on,vectors=18,rx_queue_size=1024,tx_queue_size=512,
> ... ,gso=off,guest_tso4=off,guest_tso6=off,guest_ecn=off,guest_ufo=off
> \
> 
> In the guest enabling also the MultiQueue feature, as stated here
> https://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature.
> What I'm left with is debugging the virtio_net kernel module by adding
> a bunch of printk() and see what happens, especially here
> https://elixir.bootlin.com/linux/v4.18.10/source/drivers/net/virtio_net.c#L667.
> 
> Am I doing something wrong here? What I'm missing?
> 

I believe at this point you can drop the gso,tso,ufo and ecn args. I use
virtio for development and these days start my VMs with only:

...,mq=on,guest_csum=off,...

After that are you installing the xdp program on all interfaces that can
be used for forwarding? ie., if it transmits a packet in XDP mode it
needs the xdp program loaded. For example I use:

xdp_fwd eth1 eth2 eth3 eth4


>From there:

echo 1 > /sys/kernel/debug/tracing/events/xdp/enable
cat /sys/kernel/debug/tracing/trace_pipe




[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux