From: "Longpeng(Mike)" <longpeng2@huawei.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <arei.gonglei@huawei.com>, <subo7@huawei.com>,
"Longpeng(Mike)" <longpeng2@huawei.com>,
"David S . Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
Stefano Garzarella <sgarzare@redhat.com>,
"Jorgen Hansen" <jhansen@vmware.com>,
Norbert Slusarek <nslusarek@gmx.net>,
"Andra Paraschiv" <andraprs@amazon.com>,
Colin Ian King <colin.king@canonical.com>,
David Brazdil <dbrazdil@google.com>,
Alexander Popov <alex.popov@linux.com>,
lixianming <lixianming5@huawei.com>
Subject: [RFC] vsock: notify server to shutdown when client has pending signal
Date: Tue, 11 May 2021 17:41:27 +0800 [thread overview]
Message-ID: <20210511094127.724-1-longpeng2@huawei.com> (raw)
The client's sk_state will be set to TCP_ESTABLISHED if the
server replay the client's connect request.
However, if the client has pending signal, its sk_state will
be set to TCP_CLOSE without notify the server, so the server
will hold the corrupt connection.
client server
1. sk_state=TCP_SYN_SENT |
2. call ->connect() |
3. wait reply |
| 4. sk_state=TCP_ESTABLISHED
| 5. insert to connected list
| 6. reply to the client
7. sk_state=TCP_ESTABLISHED |
8. insert to connected list |
9. *signal pending* <--------------------- the user kill client
10. sk_state=TCP_CLOSE |
client is exiting... |
11. call ->release() |
virtio_transport_close
if (!(sk->sk_state == TCP_ESTABLISHED ||
sk->sk_state == TCP_CLOSING))
return true; <------------- return at here
As a result, the server cannot notice the connection is corrupt.
So the client should notify the peer in this case.
Cc: David S. Miller <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Stefano Garzarella <sgarzare@redhat.com>
Cc: Jorgen Hansen <jhansen@vmware.com>
Cc: Norbert Slusarek <nslusarek@gmx.net>
Cc: Andra Paraschiv <andraprs@amazon.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: David Brazdil <dbrazdil@google.com>
Cc: Alexander Popov <alex.popov@linux.com>
Signed-off-by: lixianming <lixianming5@huawei.com>
Signed-off-by: Longpeng(Mike) <longpeng2@huawei.com>
---
net/vmw_vsock/af_vsock.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 92a72f0..d5df908 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1368,6 +1368,7 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
lock_sock(sk);
if (signal_pending(current)) {
+ vsock_send_shutdown(sk, SHUTDOWN_MASK);
err = sock_intr_errno(timeout);
sk->sk_state = TCP_CLOSE;
sock->state = SS_UNCONNECTED;
--
1.8.3.1
next reply other threads:[~2021-05-11 9:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 9:41 Longpeng(Mike) [this message]
2021-05-13 9:41 ` [RFC] vsock: notify server to shutdown when client has pending signal Stefano Garzarella
2021-05-13 10:35 ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-05-17 2:18 ` Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
2021-05-17 10:10 ` Stefano Garzarella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210511094127.724-1-longpeng2@huawei.com \
--to=longpeng2@huawei.com \
--cc=alex.popov@linux.com \
--cc=andraprs@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=colin.king@canonical.com \
--cc=davem@davemloft.net \
--cc=dbrazdil@google.com \
--cc=jhansen@vmware.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixianming5@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=nslusarek@gmx.net \
--cc=sgarzare@redhat.com \
--cc=subo7@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).