VSOCK: bind to random port for VMADDR_PORT_ANY
authorLepton Wu <ytht.net@gmail.com>
Tue, 11 Dec 2018 19:12:55 +0000 (11:12 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 14:37:24 +0000 (15:37 +0100)
commit5c92b652d8126399f45286ce656683b9076f91f9
tree8355f5743d7e62d65d09608083e23b798ac85b87
parentbf208699455507006166c19e21a09d0e8c39eead
VSOCK: bind to random port for VMADDR_PORT_ANY

[ Upstream commit 8236b08cf50f85bbfaf48910a0b3ee68318b7c4b ]

The old code always starts from fixed port for VMADDR_PORT_ANY. Sometimes
when VMM crashed, there is still orphaned vsock which is waiting for
close timer, then it could cause connection time out for new started VM
if they are trying to connect to same port with same guest cid since the
new packets could hit that orphaned vsock. We could also fix this by doing
more in vhost_vsock_reset_orphans, but any way, it should be better to start
from a random local port instead of a fixed one.

Signed-off-by: Lepton Wu <ytht.net@gmail.com>
Reviewed-by: Jorgen Hansen <jhansen@vmware.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/vmw_vsock/af_vsock.c