[Devel] [PATCH RHEL7 COMMIT] ms/vsock: move vsock_insert_unbound() in the vsock_create()

Vasily Averin vvs at virtuozzo.com
Wed Apr 21 17:52:55 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.21.1.vz7.174.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.21.1.vz7.174.10
------>
commit 518d9d25fd717218abb8d070000a13f047de85ea
Author: Stefano Garzarella <sgarzare at redhat.com>
Date:   Wed Apr 21 17:52:54 2021 +0300

    ms/vsock: move vsock_insert_unbound() in the vsock_create()
    
    vsock_insert_unbound() was called only when 'sock' parameter of
    __vsock_create() was not null. This only happened when
    __vsock_create() was called by vsock_create().
    
    In order to simplify the multi-transports support, this patch
    moves vsock_insert_unbound() at the end of vsock_create().
    
    Reviewed-by: Dexuan Cui <decui at microsoft.com>
    Reviewed-by: Stefan Hajnoczi <stefanha at redhat.com>
    Reviewed-by: Jorgen Hansen <jhansen at vmware.com>
    Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
    Signed-off-by: David S. Miller <davem at davemloft.net>
    
    https://jira.sw.ru/browse/PSBM-128702
    (cherry picked from commit 55f3e149b69004b95be47c891da50327ea8c0eb4)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 net/vmw_vsock/af_vsock.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9d14bd7..4d3947b 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -659,9 +659,6 @@ static struct sock *__vsock_create(struct net *net,
 		return NULL;
 	}
 
-	if (sock)
-		vsock_insert_unbound(vsk);
-
 	return sk;
 }
 
@@ -1898,6 +1895,8 @@ static const struct proto_ops vsock_stream_ops = {
 static int vsock_create(struct net *net, struct socket *sock,
 			int protocol, int kern)
 {
+	struct sock *sk;
+
 	if (!sock)
 		return -EINVAL;
 
@@ -1917,7 +1916,13 @@ static int vsock_create(struct net *net, struct socket *sock,
 
 	sock->state = SS_UNCONNECTED;
 
-	return __vsock_create(net, sock, NULL, GFP_KERNEL, 0) ? 0 : -ENOMEM;
+	sk = __vsock_create(net, sock, NULL, GFP_KERNEL, 0);
+	if (!sk)
+		return -ENOMEM;
+
+	vsock_insert_unbound(vsock_sk(sk));
+
+	return 0;
 }
 
 static const struct net_proto_family vsock_family_ops = {


More information about the Devel mailing list