qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>
Subject: Re: [RFC PATCH 18/17] util/qemu-sockets: Display IPv6 addresses within square brackets
Date: Thu, 20 Oct 2022 14:50:18 +0100	[thread overview]
Message-ID: <Y1FSGsm4ThxkpK6N@redhat.com> (raw)
In-Reply-To: <20221020134051.88449-1-philmd@linaro.org>

On Thu, Oct 20, 2022 at 03:40:51PM +0200, Philippe Mathieu-Daudé wrote:
> See RFC3986 "Uniform Resource Identifier (URI): Generic Syntax"
> section 3.2.2. 'Host' [1]:
> 
>    A host identified by an Internet Protocol literal address, version
>    6 [RFC3513] or later, is distinguished by enclosing the IP literal
>    within square brackets ("[" and "]").  This is the only place where
>    square bracket characters are allowed in the URI syntax.
> 
> and RFC5952 "A Recommendation for IPv6 Address Text Representation"
> section 6. 'Notes on Combining IPv6 Addresses with Port Numbers' [2]:
> 
>    The [] style as expressed in [RFC3986] SHOULD be employed, and is
>    the default unless otherwise specified. [...] For URIs containing
>    IPv6 address literals, [RFC3986] MUST be followed [...].
> 
> [1] https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2
> [2] https://www.rfc-editor.org/rfc/rfc5952#section-6
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  tests/qtest/netdev-socket.c | 4 ++--
>  util/qemu-sockets.c         | 4 +++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/qtest/netdev-socket.c b/tests/qtest/netdev-socket.c
> index 4ea66b4c69..65f0e01db1 100644
> --- a/tests/qtest/netdev-socket.c
> +++ b/tests/qtest/netdev-socket.c
> @@ -134,13 +134,13 @@ static void test_stream_inet_ipv6(void)
>                         "addr.ipv4=off,addr.ipv6=on,"
>                         "addr.host=localhost,addr.port=%d", port);
>  
> -    expect = g_strdup_printf("st0: index=0,type=stream,tcp:::1:%d\r\n",
> +    expect = g_strdup_printf("st0: index=0,type=stream,tcp:[::1]:%d\r\n",
>                               port);
>      EXPECT_STATE(qts1, expect, 0);
>      g_free(expect);
>  
>      /* the port is unknown, check only the address */
> -    EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:::1", ':');
> +    EXPECT_STATE(qts0, "st0: index=0,type=stream,tcp:[::1]", ':');
>  
>      qtest_quit(qts1);
>      qtest_quit(qts0);
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index a9926af714..19af96fa2c 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -1081,8 +1081,10 @@ char *socket_uri(SocketAddress *addr)
>  {
>      switch (addr->type) {
>      case SOCKET_ADDRESS_TYPE_INET:
> -        return g_strdup_printf("tcp:%s:%s",
> +        return g_strdup_printf("tcp:%s%s%s:%s",
> +                               addr->u.inet.ipv6 ? "[" : "",
>                                 addr->u.inet.host,
> +                               addr->u.inet.ipv6 ? "]" : "",
>                                 addr->u.inet.port);

"host" is not required to be numeric and using [..] is  only
valid for numeric IPv6 addresses, not  hostnames. So you
need to actually check "host" is fully numeric.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2022-10-20 15:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  9:16 [PATCH v12 00/17] qapi: net: add unix socket type support to netdev backend Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 01/17] net: introduce convert_host_port() Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 02/17] net: remove the @errp argument of net_client_inits() Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 03/17] net: simplify net_client_parse() error management Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 04/17] qapi: net: introduce a way to bypass qemu_opts_parse_noisily() Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 05/17] net: introduce qemu_set_info_str() function Laurent Vivier
2022-10-20 11:22   ` Philippe Mathieu-Daudé
2022-10-20  9:16 ` [PATCH v12 06/17] qapi: net: add stream and dgram netdevs Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 07/17] net: socket: Don't ignore EINVAL on netdev socket connection Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 08/17] net: stream: " Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 09/17] net: stream: add unix socket Laurent Vivier
2022-10-20 11:29   ` Philippe Mathieu-Daudé
2022-10-20  9:16 ` [PATCH v12 10/17] net: dgram: make dgram_dst generic Laurent Vivier
2022-10-20 11:17   ` Philippe Mathieu-Daudé
2022-10-20 15:08     ` Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 11/17] net: dgram: move mcast specific code from net_socket_fd_init_dgram() Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 12/17] net: dgram: add unix socket Laurent Vivier
2022-10-20 11:04   ` Philippe Mathieu-Daudé
2022-10-20  9:16 ` [PATCH v12 13/17] qemu-sockets: move and rename SocketAddress_to_str() Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 14/17] qemu-sockets: update socket_uri() and socket_parse() to be consistent Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 15/17] net: stream: move to QIO to enable additional parameters Laurent Vivier
2022-10-20 11:05   ` Philippe Mathieu-Daudé
2022-10-20 13:09     ` Philippe Mathieu-Daudé
2022-10-20 13:09   ` Philippe Mathieu-Daudé
2022-10-20 15:23     ` Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 16/17] tests/qtest: netdev: test stream and dgram backends Laurent Vivier
2022-10-20 13:26   ` Philippe Mathieu-Daudé
2022-10-20 14:48     ` Laurent Vivier
2022-10-20  9:16 ` [PATCH v12 17/17] net: stream: add QAPI events to report connection state Laurent Vivier
2022-10-20 11:20   ` Philippe Mathieu-Daudé
2022-10-20 13:40 ` [RFC PATCH 18/17] util/qemu-sockets: Display IPv6 addresses within square brackets Philippe Mathieu-Daudé
2022-10-20 13:50   ` Daniel P. Berrangé [this message]

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=Y1FSGsm4ThxkpK6N@redhat.com \
    --to=berrange@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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).