[Devel] [PATCH RHEL7 COMMIT] ms/vsock: fix bind() behaviour taking care of CID
Vasily Averin
vvs at virtuozzo.com
Wed Apr 21 17:53:43 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 e2507ebc2195b86cf42d1716b87e8e1050ce7675
Author: Stefano Garzarella <sgarzare at redhat.com>
Date: Wed Apr 21 17:53:43 2021 +0300
ms/vsock: fix bind() behaviour taking care of CID
When we are looking for a socket bound to a specific address,
we also have to take into account the CID.
This patch is useful with multi-transports support because it
allows the binding of the same port with different CID, and
it prevents a connection to a wrong socket bound to the same
port, but with different CID.
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 36c5b48b91ac56762ef87e4af76350ed50f119b5)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
net/vmw_vsock/af_vsock.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index eeb7564..90f9f4eb 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -234,10 +234,16 @@ static struct sock *__vsock_find_bound_socket(struct sockaddr_vm *addr)
{
struct vsock_sock *vsk;
- list_for_each_entry(vsk, vsock_bound_sockets(addr), bound_table)
- if (addr->svm_port == vsk->local_addr.svm_port)
+ list_for_each_entry(vsk, vsock_bound_sockets(addr), bound_table) {
+ if (vsock_addr_equals_addr(addr, &vsk->local_addr))
return sk_vsock(vsk);
+ if (addr->svm_port == vsk->local_addr.svm_port &&
+ (vsk->local_addr.svm_cid == VMADDR_CID_ANY ||
+ addr->svm_cid == VMADDR_CID_ANY))
+ return sk_vsock(vsk);
+ }
+
return NULL;
}
More information about the Devel
mailing list