From: Stefan Hajnoczi <stefanha@gmail.com>
To: Peng Tao <bergwolf@gmail.com>
Cc: netdev@vger.kernel.org, Jorgen Hansen <jhansen@vmware.com>,
kvm@vger.kernel.org, Stefan Hajnoczi <stefanha@redhat.com>,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH v2 4/4] vsock: cancel packets when failing to connect
Date: Thu, 8 Dec 2016 09:24:46 +0000 [thread overview]
Message-ID: <20161208092446.GB10780@stefanha-x1.localdomain> (raw)
In-Reply-To: <1481123652-80603-5-git-send-email-bergwolf@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 4076 bytes --]
On Wed, Dec 07, 2016 at 11:14:12PM +0800, Peng Tao wrote:
> Otherwise we'll leave the packets queued until releasing vsock device.
> E.g., if guest is slow to start up, resulting ETIMEDOUT on connect, guest
> will get the connect requests from failed host sockets.
>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> Signed-off-by: Peng Tao <bergwolf@gmail.com>
> ---
> include/linux/virtio_vsock.h | 7 +++++++
> net/vmw_vsock/af_vsock.c | 7 +++++++
> net/vmw_vsock/virtio_transport_common.c | 7 -------
> 3 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h
> index b92e88d..ff6850a 100644
> --- a/include/linux/virtio_vsock.h
> +++ b/include/linux/virtio_vsock.h
> @@ -156,4 +156,11 @@ void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct virtio_vs
> u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
> void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
>
> +static inline const struct virtio_transport *virtio_transport_get_ops(void)
> +{
> + const struct vsock_transport *t = vsock_core_get_transport();
> +
> + return container_of(t, struct virtio_transport, transport);
> +}
> +
> #endif /* _LINUX_VIRTIO_VSOCK_H */
> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> index 8a398b3..ebb50d6 100644
> --- a/net/vmw_vsock/af_vsock.c
> +++ b/net/vmw_vsock/af_vsock.c
> @@ -104,6 +104,7 @@
> #include <linux/unistd.h>
> #include <linux/wait.h>
> #include <linux/workqueue.h>
> +#include <linux/virtio_vsock.h>
> #include <net/sock.h>
> #include <net/af_vsock.h>
>
> @@ -1105,6 +1106,7 @@ static void vsock_connect_timeout(struct work_struct *work)
> {
> struct sock *sk;
> struct vsock_sock *vsk;
> + int cancel = 0;
>
> vsk = container_of(work, struct vsock_sock, dwork.work);
> sk = sk_vsock(vsk);
> @@ -1115,8 +1117,11 @@ static void vsock_connect_timeout(struct work_struct *work)
> sk->sk_state = SS_UNCONNECTED;
> sk->sk_err = ETIMEDOUT;
> sk->sk_error_report(sk);
> + cancel = 1;
> }
> release_sock(sk);
> + if (cancel)
> + virtio_transport_get_ops()->cancel_pkt(vsk);
This doesn't work with the VMCI transport. Remember af_vsock.c is
common code shared by all transports.
You need to add a struct vsock_transport->cancel_pkt() callback instead
os a struct virtio_transport->cancel_pkt() callback. And you need to
handle the case where cancel_pkt == NULL if you don't implement it for
VMCI.
>
> sock_put(sk);
> }
> @@ -1223,11 +1228,13 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
> err = sock_intr_errno(timeout);
> sk->sk_state = SS_UNCONNECTED;
> sock->state = SS_UNCONNECTED;
> + virtio_transport_get_ops()->cancel_pkt(vsk);
> goto out_wait;
> } else if (timeout == 0) {
> err = -ETIMEDOUT;
> sk->sk_state = SS_UNCONNECTED;
> sock->state = SS_UNCONNECTED;
> + virtio_transport_get_ops()->cancel_pkt(vsk);
> goto out_wait;
> }
>
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index cc1eeb5..72c5dff 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -25,13 +25,6 @@
> /* How long to wait for graceful shutdown of a connection */
> #define VSOCK_CLOSE_TIMEOUT (8 * HZ)
>
> -static const struct virtio_transport *virtio_transport_get_ops(void)
> -{
> - const struct vsock_transport *t = vsock_core_get_transport();
> -
> - return container_of(t, struct virtio_transport, transport);
> -}
> -
> struct virtio_vsock_pkt *
> virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
> size_t len,
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2016-12-08 9:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-07 15:14 [PATCH v2 0/4] vsock: cancel connect packets when failing to connect Peng Tao
2016-12-07 15:14 ` [PATCH v2 1/4] vsock: track pkt owner vsock Peng Tao
2016-12-08 9:30 ` Stefan Hajnoczi
2016-12-08 10:37 ` Peng Tao
2016-12-07 15:14 ` [PATCH v2 2/4] vhost-vsock: add pkt cancel capability Peng Tao
2016-12-08 9:51 ` Stefan Hajnoczi
2016-12-07 15:14 ` [PATCH v2 3/4] vsock: " Peng Tao
2016-12-08 9:54 ` Stefan Hajnoczi
2016-12-07 15:14 ` [PATCH v2 4/4] vsock: cancel packets when failing to connect Peng Tao
2016-12-08 9:24 ` Stefan Hajnoczi [this message]
2016-12-08 10:37 ` Peng Tao
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=20161208092446.GB10780@stefanha-x1.localdomain \
--to=stefanha@gmail.com \
--cc=bergwolf@gmail.com \
--cc=jhansen@vmware.com \
--cc=kvm@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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