Bug#611891: Half configured ipv6
On Thu, Mar 21, 2013 at 10:19:57AM +0000, Dick Middleton wrote:
> Hi,
Hi,
> I've been hit by this as well. For example RaspberryPi.org and their
> repositories at raspbian.org have AAAA records in DNS but these addresses are
> broken i.e. return nothing. This is going to happen more often as sites
> experiment with ipv6. Ideally programs should fall-back gracefully to ipv4 if
> ipv6 is not working.
The attached patch should make this work:
$ sudo apt-get install --force-ipv6 2vcard
or
$ sudo apt-get install 2vcard -o Acquire::ForceIPv4=true
I guess the open question is if we want a commandline switch or just a
config option and if "Acquire::ForceIPv{4,6}" is a good name.
Cheers,
Michael
=== modified file 'cmdline/apt-get.cc'
--- cmdline/apt-get.cc 2013-01-14 05:31:51 +0000
+++ cmdline/apt-get.cc 2013-03-21 16:24:42 +0000
@@ -3513,6 +3513,8 @@
{0,"install-recommends","APT::Install-Recommends",CommandLine::Boolean},
{0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean},
{0,"fix-policy","APT::Get::Fix-Policy-Broken",0},
+ {0,"force-ipv4","Acquire::ForceIPv4",CommandLine::Boolean},
+ {0,"force-ipv6","Acquire::ForceIPv6",CommandLine::Boolean},
{0,"solver","APT::Solver",CommandLine::HasArg},
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
=== modified file 'methods/connect.cc'
--- methods/connect.cc 2013-03-21 15:18:58 +0000
+++ methods/connect.cc 2013-03-21 16:21:15 +0000
@@ -17,6 +17,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/configuration.h>
#include <stdio.h>
#include <errno.h>
@@ -167,6 +168,13 @@
Hints.ai_flags = AI_ADDRCONFIG;
Hints.ai_protocol = 0;
+ if(_config->FindB("Acquire::ForceIPv4", false) == true)
+ Hints.ai_family = AF_INET;
+ else if(_config->FindB("Acquire::ForceIPv6", false) == true)
+ Hints.ai_family = AF_INET6;
+ else
+ Hints.ai_family = AF_UNSPEC;
+
// if we couldn't resolve the host before, we don't try now
if(bad_addr.find(Host) != bad_addr.end())
return _error->Error(_("Could not resolve '%s'"),Host.c_str());
Reply to: