qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu.


From: Daniel P. Berrange
Subject: Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu.
Date: Tue, 28 Oct 2008 14:31:19 +0000
User-agent: Mutt/1.4.1i

On Tue, Oct 28, 2008 at 03:22:35PM +0100, Gerd Hoffmann wrote:
> 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).

Ah, I was mis-understanding  what  IPV6_V6ONLY was doing here. If that's
portable to BSD like OS too, then I reckon that's sufficient and would
avoid need for separate sockets.

> 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 ...

Uli was demonstrating how to achieve total protocol independance
in your code. So if someone invents something better even than
IPv6 your code would still work. If you're happy to limit yourself
to just IPv4 & IPv6, then the IPV6_V6ONLY trick would work.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




reply via email to

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