[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
Re: [Qemu-devel] [PATCH] sockets: ensure we can bind to both ipv4 & ipv6 separately
Fri, 28 Apr 2017 09:57:24 -0500
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 0.0.0.0 and ::,
> in that order. We will thus bind to 0.0.0.0 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 0.0.0.0 and ::, and also
> -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
Description: OpenPGP digital signature