qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] inet_parse: Clarify IPv6 comment and error message


From: Doug Evans
Subject: [PATCH] inet_parse: Clarify IPv6 comment and error message
Date: Sun, 7 Mar 2021 16:29:28 -0800

Wrapping an IP address in square brackets does not necessarily
mean the address is an IPv6 address. The wrapping is just an aid
to parsing since IPv6 addresses have colons, but does not provide
semantic information.
E.g., [127.0.0.1] is a valid way to write 127.0.0.1.

Signed-off-by: Doug Evans <dje@google.com>
---
 util/qemu-sockets.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 8af0278f15..0c41d372c0 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -635,9 +635,12 @@ int inet_parse(InetSocketAddress *addr, const char *str, 
Error **errp)
             return -1;
         }
     } else if (str[0] == '[') {
-        /* IPv6 addr */
+        /*
+         * Probably, but not necessarily, an IPv6 addr.
+         * Note that [127.0.0.1] is also valid.
+         */
         if (sscanf(str, "[%64[^]]]:%32[^,]%n", host, port, &pos) != 2) {
-            error_setg(errp, "error parsing IPv6 address '%s'", str);
+            error_setg(errp, "error parsing address '%s'", str);
             return -1;
         }
     } else {
-- 
2.30.1.766.gb4fecdf3b7-goog




reply via email to

[Prev in Thread] Current Thread [Next in Thread]