virtio_net: Differentiate sk_buff and xdp_frame on freeing
authorToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Tue, 29 Jan 2019 00:45:59 +0000 (09:45 +0900)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Jan 2019 22:02:43 +0000 (14:02 -0800)
commit5050471d35d1316ba32dfcbb409978337eb9e75e
treec10f040dd73559e01d2511127d7bac7b55aa7249
parent07b344f494ddda9f061b396407c96df8c46c82b5
virtio_net: Differentiate sk_buff and xdp_frame on freeing

We do not reset or free up unused buffers when enabling/disabling XDP,
so it can happen that xdp_frames are freed after disabling XDP or
sk_buffs are freed after enabling XDP on xdp tx queues.
Thus we need to handle both forms (xdp_frames and sk_buffs) regardless
of XDP setting.
One way to trigger this problem is to disable XDP when napi_tx is
enabled. In that case, virtnet_xdp_set() calls virtnet_napi_enable()
which kicks NAPI. The NAPI handler will call virtnet_poll_cleantx()
which invokes free_old_xmit_skbs() for queues which have been used by
XDP.

Note that even with this change we need to keep skipping
free_old_xmit_skbs() from NAPI handlers when XDP is enabled, because XDP
tx queues do not aquire queue locks.

- v2: Use napi_consume_skb() instead of dev_consume_skb_any()

Fixes: 4941d472bf95 ("virtio-net: do not reset during XDP set")
Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/virtio_net.c