[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu.
From: |
Gerd Hoffmann |
Subject: |
Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu. |
Date: |
Tue, 28 Oct 2008 15:22:35 +0100 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080723) |
Daniel P. Berrange wrote:
>> + memset(&ai,0, sizeof(ai));
>> + ai.ai_flags = AI_PASSIVE;
>
> You should also set AI_ADDRCONFIG here. This ensure that it only
> returns IPv6 addresses if a network interface actally has IPv6
> enabled. So if someone's disabled IPv6 on a machine, and DNS still
> has IPv6 addrs, AI_ADDRCONFIG will stop QEMU pointlessly attempting
> to create IPv6 sockets that won't do anything
Done.
>> + if (e->ai_family == PF_INET6) {
>> + if (default_family == PF_INET6)
>> + setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,&on,sizeof(on));
>> + else
>> +
>> setsockopt(slisten,IPPROTO_IPV6,IPV6_V6ONLY,&off,sizeof(off));
>> + }
> One small problem here - for a server you need to expect more than one
> socket will be required. This is because some operating systems require
> you to bind to IPv4 and IPv6 sockets separately.
Sure? I've googled a bit on this issue, looked what apache does here.
I've figured this can be changed per socket, with a system-wide default
configurable via sysctl (and different OSes have different default
configs here).
The setsockopt code snippet quoted above should take care about that
issue and turn off the v6only option for the socket (unless the user
explicitly asked for IPv6 using the '-ipv6' command line option).
> So we really need an array of server sockets, and attempt to
> bind to all addresses returned by getaddrinfo().
I'm trying to get around that if possible ...
> There's more info on this here
>
> http://people.redhat.com/drepper/userapi-ipv6.html
Hmm, IPV6_V6ONLY not mentioned there ...
>> + memset(&ai,0, sizeof(ai));
>> + ai.ai_flags = AI_CANONNAME;
>
> This also needs AI_ADDRCONFIG set
Done.
cheers,
Gerd
[Qemu-devel] [PATCH 4/4] sockets: switch over tcp/telnet/unix serial line to new helper functions., Gerd Hoffmann, 2008/10/28
[Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu., Gerd Hoffmann, 2008/10/28
[Qemu-devel] [PATCH 3/4] sockets: switch vnc to new code, support vnc port auto-allocation., Gerd Hoffmann, 2008/10/28
Re: [Qemu-devel] [PATCH 0/4] ipv6 and autoport patches., Anthony Liguori, 2008/10/28