linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Paraschiv, Andra-Irina" <andraprs@amazon.com>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: netdev <netdev@vger.kernel.org>,
	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>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH net-next v2 4/4] af_vsock: Assign the vsock transport considering the vsock address flags
Date: Mon, 7 Dec 2020 21:51:55 +0200	[thread overview]
Message-ID: <0ce190c0-53c1-fa45-0e7d-45ed7913b076@amazon.com> (raw)
In-Reply-To: <20201207100016.6n5x7bd2fqvf2mmi@steredhat>



On 07/12/2020 12:00, Stefano Garzarella wrote:
>
> On Fri, Dec 04, 2020 at 07:02:35PM +0200, Andra Paraschiv wrote:
>> The vsock flags field can be 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 flags value (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 VMADDR_FLAG_TO_HOST flag
>> is set. For the other use cases, the vsock transport assignment logic is
>> not changed.
>>
>> Changelog
>>
>> v1 -> v2
>>
>> * Use bitwise operator to check the vsock flag.
>> * Use the updated "VMADDR_FLAG_TO_HOST" flag naming.
>> * Merge the checks for the g2h transport assignment in one "if" block.
>>
>> Signed-off-by: Andra Paraschiv <andraprs@amazon.com>
>> ---
>> net/vmw_vsock/af_vsock.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>> index 83d035eab0b05..66e643c3b5f85 100644
>> --- a/net/vmw_vsock/af_vsock.c
>> +++ b/net/vmw_vsock/af_vsock.c
>> @@ -421,7 +421,8 @@ static void vsock_deassign_transport(struct 
>> vsock_sock *vsk)
>>  * 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 or h2g is not loaded or remote 
>> flags field
>> + *    includes VMADDR_FLAG_TO_HOST flag value, 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)
>> @@ -429,6 +430,7 @@ 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_flags;
>>       int ret;
>>
>>       /* If the packet is coming with the source and destination CIDs 
>> higher
>> @@ -443,6 +445,8 @@ int vsock_assign_transport(struct vsock_sock 
>> *vsk, struct vsock_sock *psk)
>>           vsk->remote_addr.svm_cid > VMADDR_CID_HOST)
>>               vsk->remote_addr.svm_flags |= VMADDR_FLAG_TO_HOST;
>>
>> +      remote_flags = vsk->remote_addr.svm_flags;
>> +
>>       switch (sk->sk_type) {
>>       case SOCK_DGRAM:
>>               new_transport = transport_dgram;
>> @@ -450,7 +454,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_cid <= VMADDR_CID_HOST || !transport_h2g)
>> +              else if (remote_cid <= VMADDR_CID_HOST || 
>> !transport_h2g ||
>> +                       (remote_flags & VMADDR_FLAG_TO_HOST) == 
>> VMADDR_FLAG_TO_HOST)
>
> Maybe "remote_flags & VMADDR_FLAG_TO_HOST" should be enough, but the
> patch is okay:
>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

Done, updated to have only the bitwise logic, without the comparison.

Thanks,
Andra

>
>>                       new_transport = transport_g2h;
>>               else
>>                       new_transport = transport_h2g;
>> -- 
>> 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.
>>
>




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.

  reply	other threads:[~2020-12-07 19:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 17:02 [PATCH net-next v2 0/4] vsock: Add flags field in the vsock address Andra Paraschiv
2020-12-04 17:02 ` [PATCH net-next v2 1/4] vm_sockets: Include flags field in the vsock address data structure Andra Paraschiv
2020-12-07  9:59   ` Stefano Garzarella
2020-12-07 19:25     ` Paraschiv, Andra-Irina
2020-12-07 21:29   ` Jakub Kicinski
2020-12-08 18:23     ` Paraschiv, Andra-Irina
2020-12-08 18:42       ` Jakub Kicinski
2020-12-09 10:48         ` Stefano Garzarella
2020-12-09 15:17           ` Paraschiv, Andra-Irina
2020-12-09 17:30             ` Jakub Kicinski
2020-12-10 15:29               ` Paraschiv, Andra-Irina
2020-12-04 17:02 ` [PATCH net-next v2 2/4] vm_sockets: Add VMADDR_FLAG_TO_HOST vsock flag Andra Paraschiv
2020-12-07  9:59   ` Stefano Garzarella
2020-12-07 19:45     ` Paraschiv, Andra-Irina
2020-12-04 17:02 ` [PATCH net-next v2 3/4] af_vsock: Set VMADDR_FLAG_TO_HOST flag on the receive path Andra Paraschiv
2020-12-07  9:59   ` Stefano Garzarella
2020-12-04 17:02 ` [PATCH net-next v2 4/4] af_vsock: Assign the vsock transport considering the vsock address flags Andra Paraschiv
2020-12-07 10:00   ` Stefano Garzarella
2020-12-07 19:51     ` Paraschiv, Andra-Irina [this message]
2020-12-07 10:05 ` [PATCH net-next v2 0/4] vsock: Add flags field in the vsock address Stefano Garzarella
2020-12-07 19:18   ` Paraschiv, Andra-Irina

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=0ce190c0-53c1-fa45-0e7d-45ed7913b076@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 \
    --subject='Re: [PATCH net-next v2 4/4] af_vsock: Assign the vsock transport considering the vsock address flags' \
    /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

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).