linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andra Paraschiv <andraprs@amazon.com>
To: netdev <netdev@vger.kernel.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	David Duncan <davdunc@amazon.com>,
	Dexuan Cui <decui@microsoft.com>, Alexander Graf <graf@amazon.de>,
	Jorgen Hansen <jhansen@vmware.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Stefano Garzarella <sgarzare@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Andra Paraschiv <andraprs@amazon.com>
Subject: [PATCH net-next v1 2/3] virtio_transport_common: Set sibling VMs flag on the receive path
Date: Tue, 1 Dec 2020 17:25:04 +0200	[thread overview]
Message-ID: <20201201152505.19445-3-andraprs@amazon.com> (raw)
In-Reply-To: <20201201152505.19445-1-andraprs@amazon.com>

The vsock flag can be set during the connect() setup logic, when
initializing the vsock address data structure variable. Then the vsock
transport is assigned, also considering this flag.

The vsock transport is also assigned on the (listen) receive path. The
flag needs to be set considering the use case.

Set the vsock flag of the remote address to the one targeted for sibling
VMs communication if the following conditions are met:

* The source CID of the packet is higher than VMADDR_CID_HOST.
* The destination CID of the packet is higher than VMADDR_CID_HOST.

Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
---
 net/vmw_vsock/virtio_transport_common.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 5956939eebb78..871c84e0916b1 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -1062,6 +1062,14 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt,
 	vsock_addr_init(&vchild->remote_addr, le64_to_cpu(pkt->hdr.src_cid),
 			le32_to_cpu(pkt->hdr.src_port));
 
+	/* If the packet is coming with the source and destination CIDs higher
+	 * than VMADDR_CID_HOST, then a vsock channel should be established for
+	 * sibling VMs communication.
+	 */
+	if (vchild->local_addr.svm_cid > VMADDR_CID_HOST &&
+	    vchild->remote_addr.svm_cid > VMADDR_CID_HOST)
+		vchild->remote_addr.svm_flag = VMADDR_FLAG_SIBLING_VMS_COMMUNICATION;
+
 	ret = vsock_assign_transport(vchild, vsk);
 	/* Transport assigned (looking at remote_addr) must be the same
 	 * where we received the request.
-- 
2.20.1 (Apple Git-117)




Amazon Development Center (Romania) S.R.L. registered office: 27A Sf. Lazar Street, UBC5, floor 2, Iasi, Iasi County, 700045, Romania. Registered in Romania. Registration number J22/2621/2005.


  parent reply	other threads:[~2020-12-01 15:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-01 15:25 [PATCH net-next v1 0/3] vsock: Add flag field in the vsock address Andra Paraschiv
2020-12-01 15:25 ` [PATCH net-next v1 1/3] vm_sockets: Include flag field in the vsock address data structure Andra Paraschiv
2020-12-01 16:09   ` Stefano Garzarella
2020-12-01 18:15     ` Paraschiv, Andra-Irina
2020-12-02  8:32       ` Stefano Garzarella
2020-12-03  9:21   ` Stefan Hajnoczi
2020-12-03 10:32     ` Paraschiv, Andra-Irina
2020-12-03 13:38       ` Stefano Garzarella
2020-12-03 14:04         ` Paraschiv, Andra-Irina
2020-12-01 15:25 ` Andra Paraschiv [this message]
2020-12-01 16:22   ` [PATCH net-next v1 2/3] virtio_transport_common: Set sibling VMs flag on the receive path Stefano Garzarella
2020-12-01 19:01     ` Paraschiv, Andra-Irina
2020-12-02  8:53       ` Stefano Garzarella
2020-12-01 15:25 ` [PATCH net-next v1 3/3] af_vsock: Assign the vsock transport considering the vsock address flag Andra Paraschiv
2020-12-01 16:23   ` Stefano Garzarella
2020-12-01 19:06     ` Paraschiv, Andra-Irina
2020-12-01 16:27 ` [PATCH net-next v1 0/3] vsock: Add flag field in the vsock address Stefano Garzarella
2020-12-01 18:02   ` Paraschiv, Andra-Irina
2020-12-02 13:37 ` Stefano Garzarella
2020-12-02 16:18   ` Paraschiv, Andra-Irina
2020-12-03  8:51     ` Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201201152505.19445-3-andraprs@amazon.com \
    --to=andraprs@amazon.com \
    --cc=davdunc@amazon.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=graf@amazon.de \
    --cc=jhansen@vmware.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).