qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Doug Evans via <qemu-devel@nongnu.org>
To: qemu-devel@nongnu.org,
	"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Cc: Doug Evans <dje@google.com>
Subject: [PATCH] inet_parse: Clarify IPv6 comment and error message
Date: Sun,  7 Mar 2021 16:29:28 -0800	[thread overview]
Message-ID: <20210308002928.3385275-1-dje@google.com> (raw)

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	other threads:[~2021-03-08  0:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  0:29 Doug Evans via [this message]
2021-03-08  0:33 ` [PATCH] inet_parse: Clarify IPv6 comment and error message 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é

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210308002928.3385275-1-dje@google.com \
    --to=qemu-devel@nongnu.org \
    --cc=berrange@redhat.com \
    --cc=dje@google.com \
    --cc=samuel.thibault@ens-lyon.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).