Skip to contentSkip to conversation

vsock.7: add VMADDR_CID_LOCAL description

PATCH Superseded Stefano Garzarella 2 participants 3 messages Feb 17, 2020 – Feb 18, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 vsock.7: add VMADDR_CID_LOCAL description

Linux 5.6 added the new well-known VMADDR_CID_LOCAL for local communication.

This patch explains how to use it and remove the legacy VMADDR_CID_RESERVED no longer available.

---
v3:
* rephrased "Previous versions" part [Jorgen]
v2:
* rephrased "Local communication" description [Stefan]
* added a mention of previous versions that supported loopback only in the guest [Stefan]

---
 man7/vsock.7 | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
man7/vsock.7 +17 -2
index c5ffcf07d..219e3505f 100644
@@ -127,8 +127,8 @@ There are several special addresses:
 means any address for binding;
 .B VMADDR_CID_HYPERVISOR
 (0) is reserved for services built into the hypervisor;
-.B VMADDR_CID_RESERVED
-(1) must not be used;
+.B VMADDR_CID_LOCAL
+(1) is the well-known address for local communication (loopback);
 .B VMADDR_CID_HOST
 (2)
 is the well-known address of the host.
@@ -164,6 +164,16 @@ Consider using
 .B VMADDR_CID_ANY
 when binding instead of getting the local CID with
 .BR IOCTL_VM_SOCKETS_GET_LOCAL_CID .
+.SS Local communication
+The
+.B VMADDR_CID_LOCAL
+(1) directs packets to the same host that generated them. This is useful
+for testing applications on a single host and for debugging.
+.PP
+The local CID obtained with
+.BR IOCTL_VM_SOCKETS_GET_LOCAL_CID
+can be used for the same purpose, but it is preferable to use
+.B VMADDR_CID_LOCAL .
 .SH ERRORS
 .TP
 .B EACCES
@@ -222,6 +232,11 @@ are valid.
 Support for VMware (VMCI) has been available since Linux 3.9.
 KVM (virtio) is supported since Linux 4.8.
 Hyper-V is supported since Linux 4.14.
+.PP
+VMADDR_CID_LOCAL is supported since Linux 5.6.
+Local communication in the guest and on the host is available since Linux 5.6.
+Previous versions only supported local communication within a guest
+(not on the host), and only with some transports (VMCI and virtio).
 .SH SEE ALSO
 .BR bind (2),
 .BR connect (2),
Signature · 1 line
2.24.1
#1 lore raw
Quoted 35 lines · Stefano Garzarella

Linux 5.6 added the new well-known VMADDR_CID_LOCAL for local communication.

This patch explains how to use it and remove the legacy VMADDR_CID_RESERVED no longer available.

---
v3:
* rephrased "Previous versions" part [Jorgen]
v2:
* rephrased "Local communication" description [Stefan]
* added a mention of previous versions that supported loopback only in the guest [Stefan]

---
 man7/vsock.7 | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
man7/vsock.7 +2 -2
index c5ffcf07d..219e3505f 100644
@@ -127,8 +127,8 @@ There are several special addresses:
 means any address for binding;
 .B VMADDR_CID_HYPERVISOR
 (0) is reserved for services built into the hypervisor;
-.B VMADDR_CID_RESERVED
-(1) must not be used;
+.B VMADDR_CID_LOCAL
+(1) is the well-known address for local communication (loopback);
 .B VMADDR_CID_HOST
 (2)
 is the well-known address of the host.

man7/vsock.7 Consider using · line 170

Quoted 7 lines
man7/vsock.7 +4 -0
@@ -164,6 +164,16 @@ Consider using
 .B VMADDR_CID_ANY
 when binding instead of getting the local CID with
 .BR IOCTL_VM_SOCKETS_GET_LOCAL_CID .
+.SS Local communication
+The
+.B VMADDR_CID_LOCAL
+(1) directs packets to the same host that generated them. This is useful

Please see my comment on v2. "The VMADDR_CID_LOCAL (1) directs packets ..." sounds unnatural. Please drop "The".

#2 lore raw
Quoted 38 lines · Stefan Hajnoczi
Quoted 37 lines · Stefano Garzarella

Linux 5.6 added the new well-known VMADDR_CID_LOCAL for local communication.

This patch explains how to use it and remove the legacy VMADDR_CID_RESERVED no longer available.

---
v3:
* rephrased "Previous versions" part [Jorgen]
v2:
* rephrased "Local communication" description [Stefan]
* added a mention of previous versions that supported loopback only in the guest [Stefan]

---
 man7/vsock.7 | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
man7/vsock.7 +2 -2
index c5ffcf07d..219e3505f 100644
@@ -127,8 +127,8 @@ There are several special addresses:
 means any address for binding;
 .B VMADDR_CID_HYPERVISOR
 (0) is reserved for services built into the hypervisor;
-.B VMADDR_CID_RESERVED
-(1) must not be used;
+.B VMADDR_CID_LOCAL
+(1) is the well-known address for local communication (loopback);
 .B VMADDR_CID_HOST
 (2)
 is the well-known address of the host.
@@ -164,6 +164,16 @@ Consider using
 .B VMADDR_CID_ANY
 when binding instead of getting the local CID with
Quoted 8 lines

man7/vsock.7 Consider using · line 170

Quoted 5 lines
man7/vsock.7 +4 -0
 .BR IOCTL_VM_SOCKETS_GET_LOCAL_CID .
+.SS Local communication
+The
+.B VMADDR_CID_LOCAL
+(1) directs packets to the same host that generated them. This is useful

Please see my comment on v2. "The VMADDR_CID_LOCAL (1) directs packets ..." sounds unnatural. Please drop "The".

I received it just now :O but you sent it 4 days ago! Sorry for that!

I'll send v4 dropping "The".

Thanks,
Stefano