]> git.baikalelectronics.ru Git - kernel.git/commit
vsock: forward all packets to the host when no H2G is registered
authorStefano Garzarella <sgarzare@redhat.com>
Thu, 12 Nov 2020 13:38:37 +0000 (14:38 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 14 Nov 2020 19:33:39 +0000 (11:33 -0800)
commitc202c652cf039d9aebef9c4bb0add24e15811911
tree7015dea1e8e13b1e7fd56cb8b9c72bb3135919cd
parent5a72aec4d522640e3c2a319e225de2ce3c44becd
vsock: forward all packets to the host when no H2G is registered

Before commit e29ab509ea9a ("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 <jhansen@vmware.com>
Cc: Dexuan Cui <decui@microsoft.com>
Fixes: e29ab509ea9a ("vsock: add multi-transports support")
Reported-by: Andra Paraschiv <andraprs@amazon.com>
Tested-by: Andra Paraschiv <andraprs@amazon.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201112133837.34183-1-sgarzare@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/vmw_vsock/af_vsock.c