qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] inet_parse: Clarify IPv6 comment and error message
@ 2021-03-08  0:29 Doug Evans via
  2021-03-08  0:33 ` no-reply
  2021-03-08 11:31 ` Daniel P. Berrangé
  0 siblings, 2 replies; 6+ messages in thread
From: Doug Evans via @ 2021-03-08  0:29 UTC (permalink / raw)
  To: qemu-devel, Samuel Thibault, Daniel P. Berrangé; +Cc: Doug Evans

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-08 16:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-08  0:29 [PATCH] inet_parse: Clarify IPv6 comment and error message Doug Evans via
2021-03-08  0:33 ` no-reply
2021-03-08  1:31   ` Doug Evans
2021-03-08 11:30     ` Daniel P. Berrangé
2021-03-08 16:05       ` Eric Blake
2021-03-08 11:31 ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).