virtio_net: Don't enable NAPI when interface is down

[ Upstream commit 8be4d9a492 ]

Commit 4e09ff5362 ("virtio-net: disable NAPI only when enabled during
XDP set") tried to fix inappropriate NAPI enabling/disabling when
!netif_running(), but was not complete.

On error path virtio_net could enable NAPI even when !netif_running().
This can cause enabling NAPI twice on virtnet_open(), which would
trigger BUG_ON() in napi_enable().

Fixes: 4941d472bf ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Toshiaki Makita 2019-01-29 09:45:53 +09:00 коммит произвёл Greg Kroah-Hartman
Родитель eb31b906dc
Коммит e16d506fda
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -2034,8 +2034,10 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
return 0;
err:
for (i = 0; i < vi->max_queue_pairs; i++)
virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
if (netif_running(dev)) {
for (i = 0; i < vi->max_queue_pairs; i++)
virtnet_napi_enable(vi->rq[i].vq, &vi->rq[i].napi);
}
if (prog)
bpf_prog_sub(prog, vi->max_queue_pairs - 1);
return err;