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 3/3] af_vsock: Assign the vsock transport considering the vsock address flag
Date: Tue, 1 Dec 2020 17:25:05 +0200	[thread overview]
Message-ID: <20201201152505.19445-4-andraprs@amazon.com> (raw)
In-Reply-To: <20201201152505.19445-1-andraprs@amazon.com>

The vsock flag has been set in the connect and (listen) receive paths.

When the vsock transport is assigned, the remote CID is used to
distinguish between types of connection.

Use the vsock flag (in addition to the CID) from the remote address to
decide which vsock transport to assign. For the sibling VMs use case,
all the vsock packets need to be forwarded to the host, so always assign
the guest->host transport if the vsock flag is set. For the other use
cases, the vsock transport assignment logic is not changed.

Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
---
 net/vmw_vsock/af_vsock.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index d10916ab45267..bafc1cb20abd4 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -419,16 +419,21 @@ static void vsock_deassign_transport(struct vsock_sock *vsk)
  * (e.g. during the connect() or when a connection request on a listener
  * socket is received).
  * The vsk->remote_addr is used to decide which transport to use:
- *  - remote CID == VMADDR_CID_LOCAL or g2h->local_cid or VMADDR_CID_HOST if
- *    g2h is not loaded, will use local transport;
- *  - remote CID <= VMADDR_CID_HOST will use guest->host transport;
- *  - remote CID > VMADDR_CID_HOST will use host->guest transport;
+ *  - remote flag == VMADDR_FLAG_SIBLING_VMS_COMMUNICATION, will always
+ *    forward the vsock packets to the host and use guest->host transport;
+ *  - otherwise, going forward with the remote flag default value:
+ *    - remote CID == VMADDR_CID_LOCAL or g2h->local_cid or VMADDR_CID_HOST
+ *      if g2h is not loaded, will use local transport;
+ *    - remote CID <= VMADDR_CID_HOST or h2g is not loaded, will use
+ *      guest->host transport;
+ *    - remote CID > VMADDR_CID_HOST will use host->guest transport;
  */
 int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk)
 {
 	const struct vsock_transport *new_transport;
 	struct sock *sk = sk_vsock(vsk);
 	unsigned int remote_cid = vsk->remote_addr.svm_cid;
+	unsigned short remote_flag = vsk->remote_addr.svm_flag;
 	int ret;
 
 	switch (sk->sk_type) {
@@ -438,6 +443,8 @@ 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_flag == VMADDR_FLAG_SIBLING_VMS_COMMUNICATION)
+			new_transport = transport_g2h;
 		else if (remote_cid <= VMADDR_CID_HOST || !transport_h2g)
 			new_transport = transport_g2h;
 		else
-- 
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:27 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 ` [PATCH net-next v1 2/3] virtio_transport_common: Set sibling VMs flag on the receive path Andra Paraschiv
2020-12-01 16:22   ` Stefano Garzarella
2020-12-01 19:01     ` Paraschiv, Andra-Irina
2020-12-02  8:53       ` Stefano Garzarella
2020-12-01 15:25 ` Andra Paraschiv [this message]
2020-12-01 16:23   ` [PATCH net-next v1 3/3] af_vsock: Assign the vsock transport considering the vsock address flag 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-4-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).