af_vsock: Assign the vsock transport considering the vsock address flags
authorAndra Paraschiv <andraprs@amazon.com>
Mon, 14 Dec 2020 16:11:22 +0000 (18:11 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 15 Dec 2020 03:33:39 +0000 (19:33 -0800)
commit7f816984f439dfe24da25032254cb10512900346
tree6d3e957b647ce7f82ddb4674477176f41887c66b
parent1b5f2ab98e7f99f1a83960b17c5596012a7c5e88
af_vsock: Assign the vsock transport considering the vsock address flags

The vsock flags field can be set in the connect path (user space app)
and the (listen) receive path (kernel space logic).

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

v3 -> v4

* Update the "remote_flags" local variable type to reflect the change of
  the "svm_flags" field to be 1 byte in size.

v2 -> v3

* Update bitwise check logic to not compare result to the flag value.

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>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/vmw_vsock/af_vsock.c