[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] sockets: ensure we can bind to both ipv4 & ipv6

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] sockets: ensure we can bind to both ipv4 & ipv6 separately
Date: Fri, 28 Apr 2017 09:57:24 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 04/28/2017 07:15 AM, Daniel P. Berrange wrote:
> When binding to an IPv6 socket we currently force the
> IPV6_V6ONLY flag to off. This means that the IPv6 socket
> will accept both IPv4 & IPv6 sockets when QEMU is launched
> with something like
>   -vnc :::1

At first glance, I thought that was too many :.  But I guess it is
parsed as host:screen, with host of '::', and port offset of '1'...

> While this is good for that case, it is bad for other
> cases. For example if an empty hostname is given,
> getaddrinfo resolves it to 2 addresses and ::,
> in that order. We will thus bind to first, and
> then fail to bind to :: on the same port. The same
> problem can happen if any other hostname lookup causes
> the IPv4 address to be reported before the IPv6 address.
> When we get an IPv6 bind failure, we should re-try the
> same port, but with IPV6_V6ONLY turned on again, to
> avoid clash with any IPv4 listener.
> This ensures that
>   -vnc :1

...and matches this being parsed as host of '' and port offset of '1'

> will bind successfully to both and ::, and also
> avoid
>   -vnc :1,to=2
> from mistakenly using a 2nd port for the :: listener.
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>  util/qemu-sockets.c | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)

Reviewed-by: Eric Blake <address@hidden>

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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