From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KupT5-0003L7-Dn for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:22:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KupT3-0003J0-Pg for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:22:47 -0400 Received: from [199.232.76.173] (port=58045 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KupT3-0003Ix-Nb for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:22:45 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37296) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KupT2-0006I3-Nb for qemu-devel@nongnu.org; Tue, 28 Oct 2008 10:22:45 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id m9SEMdiZ020828 for ; Tue, 28 Oct 2008 10:22:39 -0400 Message-ID: <4907202B.9090703@redhat.com> Date: Tue, 28 Oct 2008 15:22:35 +0100 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/4] sockets: helper functions for qemu. References: <1225198518-16529-1-git-send-email-kraxel@redhat.com> <1225198518-16529-3-git-send-email-kraxel@redhat.com> <20081028131554.GV18016@redhat.com> In-Reply-To: <20081028131554.GV18016@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org 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