]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
streams: Add ability to listen on any VSOCK CID
authorTobias Brunner <tobias@strongswan.org>
Wed, 1 May 2024 12:50:16 +0000 (14:50 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 17 May 2024 12:00:12 +0000 (14:00 +0200)
Can be useful if the CID inside the VM is not known.

The \htmlonly\endhtmlonly hack is used to avoid compiler warnings due
to /* inside a block comment.

src/libstrongswan/networking/streams/stream_vsock.c
src/libstrongswan/networking/streams/stream_vsock.h

index 4cfab426ecb945554ebd3fc3f9ceee70df0062bf..5a2eed5caaad9fb429cddf22dfba1d46d1f1e9bd 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Tobias Brunner
  * Copyright (C) 2024 Thomas Egerer
  *
  * Copyright (C) secunet Security Networks AG
@@ -40,7 +41,15 @@ static int stream_parse_uri_vsock(char *uri, struct sockaddr_vm *addr)
        }
 
        uri += strlen("vsock://");
-       cid = strtoul(uri, &uri, 10);
+       if (*uri == '*')
+       {
+               cid = VMADDR_CID_ANY;
+               uri++;
+       }
+       else
+       {
+               cid = strtoul(uri, &uri, 10);
+       }
 
        if (*uri != ':' || cid > UINT_MAX)
        {
index 14ef11a0f86318ba4ae4d6dd82863910d8a8e149..3950a9ae524b3bcb5294dc1fdd0d10e3e496e286 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2024 Tobias Brunner
  * Copyright (C) 2024 Thomas Egerer
  *
  * Copyright (C) secunet Security Networks AG
  * identifier, CID), followed by a colon separated port. CID as well as port
  * are 32-bit unsigned integers. A full VSOCK uri looks something like:
  *
- *   vsock://2:12345
+ * * vsock://1:12345 (loopback)
+ * * vsock://2:12345 (connect from the VM to the well-known CID of the host)
+ * * vsock://3:12345 (CID 3 as assigned to a VM)
+ * * vsock://\htmlonly\endhtmlonly*:12345 (listen on any CID)
  *
  * There is no default port, so a colon after vsock:// is mandatory.
  *