diff mbox series

[v2] net/virtio: fix crash when device reconnecting

Message ID 20200506150724.37170-1-yong.liu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers show
Series [v2] net/virtio: fix crash when device reconnecting | expand

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Marvin Liu May 6, 2020, 3:07 p.m. UTC
When doing virtio device initialization, virtqueues will be reset in
server mode if ring type is packed. It will cause issue because queues
have been freed in the beginning of device initialization.

Fix this issue by checking whether device has been initialized before
reset. If device hasn't been initialized, there's no need to reset
queues.

Fixes: 6ebbf4109f35 ("net/virtio-user: fix packed ring server mode")

Signed-off-by: Marvin Liu <yong.liu@intel.com>

Comments

Maxime Coquelin May 7, 2020, 10:53 a.m. UTC | #1
On 5/6/20 5:07 PM, Marvin Liu wrote:
> When doing virtio device initialization, virtqueues will be reset in
> server mode if ring type is packed. It will cause issue because queues
> have been freed in the beginning of device initialization.
> 
> Fix this issue by checking whether device has been initialized before
> reset. If device hasn't been initialized, there's no need to reset
> queues.
> 
> Fixes: 6ebbf4109f35 ("net/virtio-user: fix packed ring server mode")
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
Maxime Coquelin May 7, 2020, 2:18 p.m. UTC | #2
On 5/6/20 5:07 PM, Marvin Liu wrote:
> When doing virtio device initialization, virtqueues will be reset in
> server mode if ring type is packed. It will cause issue because queues
> have been freed in the beginning of device initialization.
> 
> Fix this issue by checking whether device has been initialized before
> reset. If device hasn't been initialized, there's no need to reset
> queues.
> 
> Fixes: 6ebbf4109f35 ("net/virtio-user: fix packed ring server mode")
> 
> Signed-off-by: Marvin Liu <yong.liu@intel.com>

Applied to dpdk-next-virtio/master

Thanks,
Maxime
Wang, Yinan May 8, 2020, 1:54 a.m. UTC | #3
Tested-by: Wang, Yinan <yinan.wang@intel.com>


> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Maxime Coquelin
> Sent: 2020年5月7日 22:18
> To: Liu, Yong <yong.liu@intel.com>; Ye, Xiaolong <xiaolong.ye@intel.com>;
> Wang, Zhihong <zhihong.wang@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] net/virtio: fix crash when device
> reconnecting
> 
> 
> 
> On 5/6/20 5:07 PM, Marvin Liu wrote:
> > When doing virtio device initialization, virtqueues will be reset in
> > server mode if ring type is packed. It will cause issue because queues
> > have been freed in the beginning of device initialization.
> >
> > Fix this issue by checking whether device has been initialized before
> > reset. If device hasn't been initialized, there's no need to reset
> > queues.
> >
> > Fixes: 6ebbf4109f35 ("net/virtio-user: fix packed ring server mode")
> >
> > Signed-off-by: Marvin Liu <yong.liu@intel.com>
> 
> Applied to dpdk-next-virtio/master
> 
> Thanks,
> Maxime
diff mbox series

Patch

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index c54698ad1..55bd81f0b 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -89,7 +89,8 @@  virtio_user_server_reconnect(struct virtio_user_dev *dev)
 	dev->features &= dev->device_features;
 
 	/* For packed ring, resetting queues is required in reconnection. */
-	if (vtpci_packed_queue(hw)) {
+	if (vtpci_packed_queue(hw) &&
+	   (vtpci_get_status(hw) & VIRTIO_CONFIG_STATUS_DRIVER_OK)) {
 		PMD_INIT_LOG(NOTICE, "Packets on the fly will be dropped"
 				" when packed ring reconnecting.");
 		virtio_user_reset_queues_packed(eth_dev);