Skip to content

Commit 65b422d

Browse files
stefano-garzarellakuba-moo
authored andcommitted
vsock: forward all packets to the host when no H2G is registered
Before commit c0cfa2d ("vsock: add multi-transports support"), if a G2H transport was loaded (e.g. virtio transport), every packets was forwarded to the host, regardless of the destination CID. The H2G transports implemented until then (vhost-vsock, VMCI) always responded with an error, if the destination CID was not VMADDR_CID_HOST. From that commit, we are using the remote CID to decide which transport to use, so packets with remote CID > VMADDR_CID_HOST(2) are sent only through H2G transport. If no H2G is available, packets are discarded directly in the guest. Some use cases (e.g. Nitro Enclaves [1]) rely on the old behaviour to implement sibling VMs communication, so we restore the old behavior when no H2G is registered. It will be up to the host to discard packets if the destination is not the right one. As it was already implemented before adding multi-transport support. Tested with nested QEMU/KVM by me and Nitro Enclaves by Andra. [1] Documentation/virt/ne_overview.rst Cc: Jorgen Hansen <[email protected]> Cc: Dexuan Cui <[email protected]> Fixes: c0cfa2d ("vsock: add multi-transports support") Reported-by: Andra Paraschiv <[email protected]> Tested-by: Andra Paraschiv <[email protected]> Signed-off-by: Stefano Garzarella <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9230706 commit 65b422d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
438438
case SOCK_STREAM:
439439
if (vsock_use_local_transport(remote_cid))
440440
new_transport = transport_local;
441-
else if (remote_cid <= VMADDR_CID_HOST)
441+
else if (remote_cid <= VMADDR_CID_HOST || !transport_h2g)
442442
new_transport = transport_g2h;
443443
else
444444
new_transport = transport_h2g;

0 commit comments

Comments
 (0)