netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] vsock: forward all packets to the host when no H2G is registered
@ 2020-11-12 13:38 Stefano Garzarella
  2020-11-14 19:50 ` patchwork-bot+netdevbpf
  2020-11-19 14:03 ` Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Stefano Garzarella @ 2020-11-12 13:38 UTC (permalink / raw)
  To: netdev
  Cc: Jorgen Hansen, David S. Miller, Dexuan Cui, Anthony Liguori,
	David Duncan, Andra Paraschiv, Stefano Garzarella,
	Vitaly Kuznetsov, Jakub Kicinski, Stefan Hajnoczi, linux-kernel,
	Alexander Graf

Before commit c0cfa2d8a788 ("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: c0cfa2d8a788 ("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>
---
 net/vmw_vsock/af_vsock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index b4d7b8aba003..d10916ab4526 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -438,7 +438,7 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
 	case SOCK_STREAM:
 		if (vsock_use_local_transport(remote_cid))
 			new_transport = transport_local;
-		else if (remote_cid <= VMADDR_CID_HOST)
+		else if (remote_cid <= VMADDR_CID_HOST || !transport_h2g)
 			new_transport = transport_g2h;
 		else
 			new_transport = transport_h2g;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vsock: forward all packets to the host when no H2G is registered
  2020-11-12 13:38 [PATCH net] vsock: forward all packets to the host when no H2G is registered Stefano Garzarella
@ 2020-11-14 19:50 ` patchwork-bot+netdevbpf
  2020-11-19 14:03 ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-11-14 19:50 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: netdev, jhansen, davem, decui, aliguori, davdunc, andraprs,
	vkuznets, kuba, stefanha, linux-kernel, graf

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Thu, 12 Nov 2020 14:38:37 +0100 you wrote:
> Before commit c0cfa2d8a788 ("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.
> 
> [...]

Here is the summary with links:
  - [net] vsock: forward all packets to the host when no H2G is registered
    https://git.kernel.org/netdev/net/c/65b422d9b61b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vsock: forward all packets to the host when no H2G is registered
  2020-11-12 13:38 [PATCH net] vsock: forward all packets to the host when no H2G is registered Stefano Garzarella
  2020-11-14 19:50 ` patchwork-bot+netdevbpf
@ 2020-11-19 14:03 ` Stefan Hajnoczi
  2020-11-19 14:25   ` Alexander Graf
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Hajnoczi @ 2020-11-19 14:03 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: netdev, Jorgen Hansen, David S. Miller, Dexuan Cui,
	Anthony Liguori, David Duncan, Andra Paraschiv, Vitaly Kuznetsov,
	Jakub Kicinski, linux-kernel, Alexander Graf

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

On Thu, Nov 12, 2020 at 02:38:37PM +0100, Stefano Garzarella wrote:
> Before commit c0cfa2d8a788 ("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: c0cfa2d8a788 ("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>
> ---
>  net/vmw_vsock/af_vsock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vsock: forward all packets to the host when no H2G is registered
  2020-11-19 14:03 ` Stefan Hajnoczi
@ 2020-11-19 14:25   ` Alexander Graf
  2020-11-19 14:41     ` Stefano Garzarella
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2020-11-19 14:25 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella
  Cc: netdev, Jorgen Hansen, David S. Miller, Dexuan Cui,
	Anthony Liguori, David Duncan, Andra Paraschiv, Vitaly Kuznetsov,
	Jakub Kicinski, linux-kernel, Alexander Graf


On 19.11.20 15:03, Stefan Hajnoczi wrote:
> On Thu, Nov 12, 2020 at 02:38:37PM +0100, Stefano Garzarella wrote:
>> Before commit c0cfa2d8a788 ("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: c0cfa2d8a788 ("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>
>> ---
>>   net/vmw_vsock/af_vsock.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> Acked-by: Stefan Hajnoczi <stefanha@redhat.com>


Is there anything we have to do to also get this into the affected 
stable trees? :)

Alex





Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] vsock: forward all packets to the host when no H2G is registered
  2020-11-19 14:25   ` Alexander Graf
@ 2020-11-19 14:41     ` Stefano Garzarella
  0 siblings, 0 replies; 5+ messages in thread
From: Stefano Garzarella @ 2020-11-19 14:41 UTC (permalink / raw)
  To: Alexander Graf
  Cc: Stefan Hajnoczi, netdev, Jorgen Hansen, David S. Miller,
	Dexuan Cui, Anthony Liguori, David Duncan, Andra Paraschiv,
	Vitaly Kuznetsov, Jakub Kicinski, linux-kernel, Alexander Graf

On Thu, Nov 19, 2020 at 03:25:42PM +0100, Alexander Graf wrote:
>
>On 19.11.20 15:03, Stefan Hajnoczi wrote:
>>On Thu, Nov 12, 2020 at 02:38:37PM +0100, Stefano Garzarella wrote:
>>>Before commit c0cfa2d8a788 ("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: c0cfa2d8a788 ("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>
>>>---
>>>  net/vmw_vsock/af_vsock.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
>
>
>Is there anything we have to do to also get this into the affected 
>stable trees? :)
>

The patch is already queued by Jakub in the netdev stable queue:
https://patchwork.kernel.org/bundle/netdev/stable/?series=382773&state=*

Stefano


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-11-19 14:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 13:38 [PATCH net] vsock: forward all packets to the host when no H2G is registered Stefano Garzarella
2020-11-14 19:50 ` patchwork-bot+netdevbpf
2020-11-19 14:03 ` Stefan Hajnoczi
2020-11-19 14:25   ` Alexander Graf
2020-11-19 14:41     ` Stefano Garzarella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).