Parav Pandit
2023-Feb-02 05:00 UTC
[PATCH 0/2] virtio-net: close() to follow mirror of open()
Hi, This two small patches improves ndo_close() callback to follow the mirror sequence of ndo_open() callback. This improves the code auditing and also ensure that xdp rxq info is not unregistered while NAPI on RXQ is ongoing. Please review. Patch summary: patch-1 ensures that xdp rq info is unregistered after rq napi is disabled patch-2 keeps the mirror sequence for close() be mirror of open() Parav Pandit (2): virtio-net: Keep stop() to follow mirror sequence of open() virtio-net: Maintain reverse cleanup order drivers/net/virtio_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.26.2
Parav Pandit
2023-Feb-02 05:00 UTC
[PATCH 1/2] virtio-net: Keep stop() to follow mirror sequence of open()
Cited commit in fixes tag frees rxq xdp info while RQ NAPI is still enabled and packet processing may be ongoing. Follow the mirror sequence of open() in the stop() callback. This ensures that when rxq info is unregistered, no rx packet processing is ongoing. Fixes: 754b8a21a96d ("virtio_net: setup xdp_rxq_info") Signed-off-by: Parav Pandit <parav at nvidia.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7e1a98430190..b7d0b54c3bb0 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2279,8 +2279,8 @@ static int virtnet_close(struct net_device *dev) cancel_delayed_work_sync(&vi->refill); for (i = 0; i < vi->max_queue_pairs; i++) { - xdp_rxq_info_unreg(&vi->rq[i].xdp_rxq); napi_disable(&vi->rq[i].napi); + xdp_rxq_info_unreg(&vi->rq[i].xdp_rxq); virtnet_napi_tx_disable(&vi->sq[i].napi); } -- 2.26.2
To easily audit the code, better to keep the device stop() sequence to be mirror of the device open() sequence. Signed-off-by: Parav Pandit <parav at nvidia.com> --- drivers/net/virtio_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index b7d0b54c3bb0..1f8168e0f64d 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -2279,9 +2279,9 @@ static int virtnet_close(struct net_device *dev) cancel_delayed_work_sync(&vi->refill); for (i = 0; i < vi->max_queue_pairs; i++) { + virtnet_napi_tx_disable(&vi->sq[i].napi); napi_disable(&vi->rq[i].napi); xdp_rxq_info_unreg(&vi->rq[i].xdp_rxq); - virtnet_napi_tx_disable(&vi->sq[i].napi); } return 0; -- 2.26.2
Michael S. Tsirkin
2023-Feb-02 10:56 UTC
[PATCH 0/2] virtio-net: close() to follow mirror of open()
On Thu, Feb 02, 2023 at 07:00:36AM +0200, Parav Pandit wrote:> Hi, > > This two small patches improves ndo_close() callback to follow > the mirror sequence of ndo_open() callback. This improves the code auditing > and also ensure that xdp rxq info is not unregistered while NAPI on > RXQ is ongoing.Acked-by: Michael S. Tsirkin <mst at redhat.com> I'm guessing -net and 1/2 for stable?> Please review. > > Patch summary: > patch-1 ensures that xdp rq info is unregistered after rq napi is disabled > patch-2 keeps the mirror sequence for close() be mirror of open() > > Parav Pandit (2): > virtio-net: Keep stop() to follow mirror sequence of open() > virtio-net: Maintain reverse cleanup order > > drivers/net/virtio_net.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > -- > 2.26.2
Apparently Analagous Threads
- [PATCH net v3] virtio_net: Fix error unwinding of XDP initialization
- [PATCH net v2] virtio_net: Fix error unwinding of XDP initialization
- [PATCH net v2] virtio_net: Fix error unwinding of XDP initialization
- [PATCH net v3] virtio_net: Fix error unwinding of XDP initialization
- [PATCH net v1 1/2] virtio_net: Fix error unwinding of XDP initialization