History

vm_sockets: Add VMADDR_FLAG_TO_HOST vsock flag

Add VMADDR_FLAG_TO_HOST vsock flag that is used to setup a vsock connection where all the packets are forwarded to the host. Then, using this type of vsock channel, vsock communication between sibling VMs can be built on top of it. Changelog v3 -> v4 * Update the "VMADDR_FLAG_TO_HOST" value, as the size of the field has been updated to 1 byte. v2 -> v3 * Update comments to mention when the flag is set in the connect and listen paths. v1 -> v2 * New patch in v2, it was split from the first patch in the series. * Remove the default value for the vsock flags field. * Update the naming for the vsock flag to "VMADDR_FLAG_TO_HOST".

Andra Paraschiv committed 5 years ago

Commit caaf95e1 parent dc8eeef1 file · +20 −0Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/vm_sockets.h+20−0
@@ -115,6 +115,26 @@ · 114 unmodified lines
115115
116116 #define VMADDR_CID_HOST 2
117117
118+/* The current default use case for the vsock channel is the following:
119+ * local vsock communication between guest and host and nested VMs setup.
120+ * In addition to this, implicitly, the vsock packets are forwarded to the host
121+ * if no host->guest vsock transport is set.
122+ *
123+ * Set this flag value in the sockaddr_vm corresponding field if the vsock
124+ * packets need to be always forwarded to the host. Using this behavior,
125+ * vsock communication between sibling VMs can be setup.
126+ *
127+ * This way can explicitly distinguish between vsock channels created for
128+ * different use cases, such as nested VMs (or local communication between
129+ * guest and host) and sibling VMs.
130+ *
131+ * The flag can be set in the connect logic in the user space application flow.
132+ * In the listen logic (from kernel space) the flag is set on the remote peer
133+ * address. This happens for an incoming connection when it is routed from the
134+ * host and comes from the guest (local CID and remote CID > VMADDR_CID_HOST).
135+ */
136+#define VMADDR_FLAG_TO_HOST 0x01
137+
118138 /* Invalid vSockets version. */
119139
120140 #define VM_SOCKETS_INVALID_VERSION -1U