[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250211071922.2311873-3-junnan01.wu@samsung.com>
Date: Tue, 11 Feb 2025 15:19:22 +0800
From: Junnan Wu <junnan01.wu@...sung.com>
To: stefanha@...hat.com, sgarzare@...hat.com, mst@...hat.com,
jasowang@...hat.com, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com
Cc: xuanzhuo@...ux.alibaba.com, eperezma@...hat.com, horms@...nel.org,
kvm@...r.kernel.org, virtualization@...ts.linux.dev, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, q1.huang@...sung.com, ying01.gao@...sung.com,
ying123.xu@...sung.com, lei19.wang@...sung.com, Junnan Wu
<junnan01.wu@...sung.com>
Subject: [Patch net 2/2] vsock/virtio: Don't reset the created SOCKET during
suspend to ram
Function virtio_vsock_vqs_del will be invoked in 2 cases
virtio_vsock_remove() and virtio_vsock_freeze().
And when driver freeze, the connected socket will be set to TCP_CLOSE
and it will cause that socket can not be unusable after resume.
Refactor function virtio_vsock_vqs_del to differentiate the 2 use cases.
Co-developed-by: Ying Gao <ying01.gao@...sung.com>
Signed-off-by: Ying Gao <ying01.gao@...sung.com>
Signed-off-by: Junnan Wu <junnan01.wu@...sung.com>
---
net/vmw_vsock/virtio_transport.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
index f0e48e6911fc..909048c9069b 100644
--- a/net/vmw_vsock/virtio_transport.c
+++ b/net/vmw_vsock/virtio_transport.c
@@ -716,14 +716,20 @@ static void virtio_vsock_vqs_start(struct virtio_vsock *vsock)
queue_work(virtio_vsock_workqueue, &vsock->send_pkt_work);
}
-static void virtio_vsock_vqs_del(struct virtio_vsock *vsock)
+static void virtio_vsock_vqs_del(struct virtio_vsock *vsock, bool vsock_reset)
{
struct virtio_device *vdev = vsock->vdev;
struct sk_buff *skb;
- /* Reset all connected sockets when the VQs disappear */
- vsock_for_each_connected_socket(&virtio_transport.transport,
- virtio_vsock_reset_sock);
+ /* When driver is removed, reset all connected
+ * sockets because the VQs disappear.
+ * When driver is just freezed, don't do that because the connected
+ * socket still need to use after restore.
+ */
+ if (vsock_reset) {
+ vsock_for_each_connected_socket(&virtio_transport.transport,
+ virtio_vsock_reset_sock);
+ }
/* Stop all work handlers to make sure no one is accessing the device,
* so we can safely call virtio_reset_device().
@@ -831,7 +837,7 @@ static void virtio_vsock_remove(struct virtio_device *vdev)
rcu_assign_pointer(the_virtio_vsock, NULL);
synchronize_rcu();
- virtio_vsock_vqs_del(vsock);
+ virtio_vsock_vqs_del(vsock, true);
/* Other works can be queued before 'config->del_vqs()', so we flush
* all works before to free the vsock object to avoid use after free.
@@ -856,7 +862,7 @@ static int virtio_vsock_freeze(struct virtio_device *vdev)
rcu_assign_pointer(the_virtio_vsock, NULL);
synchronize_rcu();
- virtio_vsock_vqs_del(vsock);
+ virtio_vsock_vqs_del(vsock, false);
mutex_unlock(&the_virtio_vsock_mutex);
--
2.34.1
Powered by blists - more mailing lists