qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu.
Date: Tue, 28 Oct 2008 14:31:19 +0000	[thread overview]
Message-ID: <20081028143119.GX18016@redhat.com> (raw)
In-Reply-To: <4907202B.9090703@redhat.com>

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	other threads:[~2008-10-28 14:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 12:55 [Qemu-devel] [PATCH 0/4] ipv6 and autoport patches Gerd Hoffmann
2008-10-28 12:55 ` [Qemu-devel] [PATCH 1/4] Implement "info chardev" command Gerd Hoffmann
2008-10-28 17:08   ` Blue Swirl
2008-10-28 19:58     ` Gerd Hoffmann
2008-10-29 11:02       ` Gerd Hoffmann
2008-10-29 18:30         ` Blue Swirl
2008-10-28 20:19   ` Daniel P. Berrange
2008-10-28 21:28     ` Gerd Hoffmann
2008-10-28 12:55 ` [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu Gerd Hoffmann
2008-10-28 13:15   ` Daniel P. Berrange
2008-10-28 14:22     ` Gerd Hoffmann
2008-10-28 14:31       ` Daniel P. Berrange [this message]
2008-10-28 15:10         ` Gerd Hoffmann
2008-10-28 12:55 ` [Qemu-devel] [PATCH 3/4] sockets: switch vnc to new code, support vnc port auto-allocation Gerd Hoffmann
2008-10-28 17:25   ` Blue Swirl
2008-10-28 19:57     ` Gerd Hoffmann
2008-10-29 10:46       ` Gerd Hoffmann
2008-10-28 12:55 ` [Qemu-devel] [PATCH 4/4] sockets: switch over tcp/telnet/unix serial line to new helper functions Gerd Hoffmann
2008-10-28 15:53 ` [Qemu-devel] [PATCH 0/4] ipv6 and autoport patches Anthony Liguori
  -- strict thread matches above, loose matches on Subject: below --
2008-10-31 12:47 [Qemu-devel] [PATCH v2 " Gerd Hoffmann
2008-10-31 12:47 ` [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu Gerd Hoffmann
2008-10-31 17:37   ` Anthony Liguori
2008-10-31 17:50     ` Daniel P. Berrange
2008-10-31 17:58       ` Anthony Liguori
2008-10-31 19:44         ` Jamie Lokier
2008-11-03 15:35     ` Gerd Hoffmann

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=20081028143119.GX18016@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).