All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PULL v2 4/5] io: preserve ipv4/ipv6 flags when resolving InetSocketAddress
Date: Wed, 12 Jul 2017 17:18:29 +0100	[thread overview]
Message-ID: <20170712161830.3621-5-berrange@redhat.com> (raw)
In-Reply-To: <20170712161830.3621-1-berrange@redhat.com>

The original InetSocketAddress struct may have has_ipv4 and
has_ipv6 fields set, which will control both the ai_family
used during DNS resolution, and later use of the V6ONLY
flag.

Currently the standalone DNS resolver code drops the
has_ipv4 & has_ipv6 flags after resolving, which means
the later bind() code won't correctly set V6ONLY.

This fixes the following scenarios

  -vnc :0,ipv4=off
  -vnc :0,ipv6=on
  -vnc :::0,ipv4=off
  -vnc :::0,ipv6=on

which all mistakenly accepted IPv4 clients

Acked-by: Gerd Hoffmann <kraxel@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 io/dns-resolver.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/io/dns-resolver.c b/io/dns-resolver.c
index 57a8896..c072d12 100644
--- a/io/dns-resolver.c
+++ b/io/dns-resolver.c
@@ -116,8 +116,10 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
             .numeric = true,
             .has_to = iaddr->has_to,
             .to = iaddr->to,
-            .has_ipv4 = false,
-            .has_ipv6 = false,
+            .has_ipv4 = iaddr->has_ipv4,
+            .ipv4 = iaddr->ipv4,
+            .has_ipv6 = iaddr->has_ipv6,
+            .ipv6 = iaddr->ipv6,
         };
 
         (*addrs)[i] = newaddr;
-- 
2.9.4

  parent reply	other threads:[~2017-07-12 16:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12 16:18 [Qemu-devel] [PULL v2 0/5] Merge sockets 2017/07/11 Daniel P. Berrange
2017-07-12 16:18 ` [Qemu-devel] [PULL v2 1/5] sockets: ensure we can bind to both ipv4 & ipv6 separately Daniel P. Berrange
2017-07-12 16:18 ` [Qemu-devel] [PULL v2 2/5] sockets: don't block IPv4 clients when listening on "::" Daniel P. Berrange
2017-07-12 16:18 ` [Qemu-devel] [PULL v2 3/5] sockets: ensure we don't accept IPv4 clients when IPv4 is disabled Daniel P. Berrange
2017-07-12 16:18 ` Daniel P. Berrange [this message]
2017-07-12 16:18 ` [Qemu-devel] [PULL v2 5/5] tests: add functional test validating ipv4/ipv6 address flag handling Daniel P. Berrange
2017-07-12 21:28 ` [Qemu-devel] [PULL v2 0/5] Merge sockets 2017/07/11 Philippe Mathieu-Daudé
2017-07-14  8:36 ` Peter Maydell
2017-07-14  9:18   ` Christian Borntraeger
2017-07-14  9:28     ` Daniel P. Berrange
2017-07-14 15:13   ` Daniel P. Berrange

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=20170712161830.3621-5-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.