You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@cpan.org> on 2004/02/12 23:35:51 UTC

[patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

On Thu, 2004-02-12 at 10:24 -0800, Stas Bekman wrote:
> Andrew Wyllie wrote:
> > 
> > 
> > So, after rereading my previous post, I found one slight difference 
> > (funny how
> > it works that way sometimes).  When I used telnet to connect to the 
> > server, it
> > used '::1' as an address for localhost as opposed to 127.0.0.1 .  So I 
> > changed all the
> > refs to localhost in httpd.conf to ::1 and sure enough, all the tests 
> > passed.  I'm going to look
> > into this a bit more to see why this is the case as I have always 
> > thought that both of these
> > cases should work the same way.  
> 
> So how can we make it into a setup that will work on both, ipv6 and ipv4?

The problem is that on most BSDs, IPv6 is starting to become the default
setup, at least, it's the case on my OpenBSD box.

Configuring httpd with --enable-v4-mapped will make it all work, but
it's not the default, so most people on those BSDs are getting an httpd
that will default to IPv6. Even localhost in /etc/hosts is going to be
'::1' (ipv6 equiv of localhost).

The following patch (short of being to detect at configure time the
IPv4/6 status of the box) hard-codes all the listening IP addresses to
127.0.0.1, effectively ensuring all the test suite runs under vanilla-
IPv4.

Ideally, I'd like to figure out a way to detect things correctly, and
pick between 127.0.0.1 and ::1 accordingly.

Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.204
diff -u -r1.204 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	31 Jan 2004 01:53:09 -0000	1.204
+++ Apache-Test/lib/Apache/TestConfig.pm	2 Feb 2004 06:47:45 -0000
@@ -1002,7 +1002,7 @@
     my @out_config = ();
     if ($self->{vhosts}->{$module}->{namebased} < 2) {
         #extra config that should go *outside* the <VirtualHost ...>
-        @out_config = ([Listen => $port]);
+        @out_config = ([Listen => '127.0.0.1:' . $port]);
 
         if ($self->{vhosts}->{$module}->{namebased}) {
             push @out_config => [NameVirtualHost => "*:$port"];
@@ -1750,7 +1750,7 @@
 
 
 __DATA__
-Listen     @Port@
+Listen     127.0.0.1:@Port@
 
 ServerRoot   "@ServerRoot@"
 DocumentRoot "@DocumentRoot@"
Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.81
diff -u -r1.81 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm	24 Nov 2003 07:57:30 -0000	1.81
+++ Apache-Test/lib/Apache/TestConfigPerl.pm	2 Feb 2004 06:47:45 -0000
@@ -207,7 +207,7 @@
 sub set_connection_handler {
     my($self, $module, $args) = @_;
     my $port = $self->new_vhost($module);
-    $self->postamble(Listen => $port);
+    $self->postamble(Listen => '127.0.0.1:' . $port);
 }
 
 my %add_hook_config = (
Index: t/response/TestApache/conftree.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestApache/conftree.pm,v
retrieving revision 1.7
diff -u -r1.7 conftree.pm
--- t/response/TestApache/conftree.pm	8 Oct 2003 13:28:14 -0000	1.7
+++ t/response/TestApache/conftree.pm	2 Feb 2004 06:47:45 -0000
@@ -27,9 +27,9 @@
 
     ok $tree;
 
-    my $port = $tree->lookup('Listen');
+    my $listen = $tree->lookup('Listen');
 
-    ok t_cmp($vars->{port}, $port);
+    ok t_cmp('127.0.0.1:' . $vars->{port}, $listen);
 
     my $documentroot = $tree->lookup('DocumentRoot');
 

> > Anyway, for whatever it's worth, 
> > mod_perl 1.99_13
> > with perl 5.8.3 and apache 2.0.48 seems to build and test ok on FREEBSD 
> > current
> > (as of Feb 3, 2004).
> 
> That's good.
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
> 
> -- 
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html
> 

Re: forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
[...]
> One last review first please ;-)

+1
-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Tue, 2004-02-17 at 15:25 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> [...]
> >>I'll try to summarize what you said in a table. The following approaches work 
> >>for Listen:
> >>
> >>Apache  \   OS      | IPV4         |  IPV6
> >>--------------------------------------------
> >>--enable-v4-mapped  |      80      |  80
> >>--disable-v4-mapped | can't happen |  127.0.0.1:80
> >>
> >>Am I correct? So we need to use 'Listen 127.0.0.1:80' only when we see:
> >>
> >>-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled), .i.e. --disable-v4-mapped
> >>
> >>otherwise the old '80' is fine.
> > 
> > 
> > Yes, that's the way I've experienced/understood it on my trusty OpenBSD
> > box (and Linux with IPv6)
> 
> OK, so how about you go ahead and commit your original patch (hardcoding 
> 127.0.0.1). And log the above table in the Apache-Test/ToDo list, to may be 
> check have 127.0.0.1 hardcoded only if --disable-v4-mapped is detected, in 
> case someone will have problems with that change.
> 

One last review first please ;-)



> 
> -- 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.comIndex: Apache-Test/Changes
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
retrieving revision 1.87
diff -u -I$Id -r1.87 Changes
--- Apache-Test/Changes	9 Feb 2004 18:00:55 -0000	1.87
+++ Apache-Test/Changes	17 Feb 2004 23:46:30 -0000
@@ -8,6 +8,9 @@
 
 =item 1.08_dev
 
+Hard-code listen directive to 127.0.0.1, solving problems for people
+with IPv4 & IPv6 address until a better solution is found [Gozer]
+
 prefix Apache::TestTrace (non-colour mode) messages with the loglevel,
 similar to what Apache does. [Stas]
 
Index: Apache-Test/ToDo
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/ToDo,v
retrieving revision 1.7
diff -u -I$Id -r1.7 ToDo
--- Apache-Test/ToDo	26 Sep 2003 16:55:55 -0000	1.7
+++ Apache-Test/ToDo	17 Feb 2004 23:46:30 -0000
@@ -4,6 +4,16 @@
   Philippe posted patch here:
   http://marc.theaimsgroup.com/?l=apache-modperl-
dev&m=105514290024419&w=2
 
+  For now, 127.0.0.1 will be hardcoded in the Listen directive, but a
better
+  method would use this table:
+
+  Apache  \   OS      | IPV4         |  IPV6
+  --------------------------------------------
+  --enable-v4-mapped  |      80      |  80
+  --disable-v4-mapped | can't happen |  127.0.0.1:80
+
+  To more correctly pick the right Listen flavor.
+
 - Apache-Test assumes that any core file found under t/ was generated
   by httpd, (and suggests the gdb invoking command) which is incorrect
   in some cases. For example t/TEST -config, which is run by bin/perl,
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/
TestConfig.pm,v
retrieving revision 1.204
diff -u -I$Id -r1.204 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	31 Jan 2004 01:53:09 -
0000	1.204
+++ Apache-Test/lib/Apache/TestConfig.pm	17 Feb 2004 23:46:30 -0000
@@ -1002,7 +1002,7 @@
     my @out_config = ();
     if ($self->{vhosts}->{$module}->{namebased} < 2) {
         #extra config that should go *outside* the <VirtualHost ...>
-        @out_config = ([Listen => $port]);
+        @out_config = ([Listen => '127.0.0.1:' . $port]);
 
         if ($self->{vhosts}->{$module}->{namebased}) {
             push @out_config => [NameVirtualHost => "*:$port"];
@@ -1750,7 +1750,7 @@
 
 
 __DATA__
-Listen     @Port@
+Listen     127.0.0.1:@Port@
 
 ServerRoot   "@ServerRoot@"
 DocumentRoot "@DocumentRoot@"
Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/
TestConfigPerl.pm,v
retrieving revision 1.81
diff -u -I$Id -r1.81 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm	24 Nov 2003 07:57:30 -
0000	1.81
+++ Apache-Test/lib/Apache/TestConfigPerl.pm	17 Feb 2004 23:46:30 -0000
@@ -207,7 +207,7 @@
 sub set_connection_handler {
     my($self, $module, $args) = @_;
     my $port = $self->new_vhost($module);
-    $self->postamble(Listen => $port);
+    $self->postamble(Listen => '127.0.0.1:' . $port);
 }
 
 my %add_hook_config = (
Index: t/response/TestApache/conftree.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestApache/conftree.pm,v
retrieving revision 1.7
diff -u -I$Id -r1.7 conftree.pm
--- t/response/TestApache/conftree.pm	8 Oct 2003 13:28:14 -0000	1.7
+++ t/response/TestApache/conftree.pm	17 Feb 2004 23:46:30 -0000
@@ -27,9 +27,9 @@
 
     ok $tree;
 
-    my $port = $tree->lookup('Listen');
+    my $listen = $tree->lookup('Listen');
 
-    ok t_cmp($vars->{port}, $port);
+    ok t_cmp('127.0.0.1:' . $vars->{port}, $listen);
 
     my $documentroot = $tree->lookup('DocumentRoot');
 


Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
[...]
>>I'll try to summarize what you said in a table. The following approaches work 
>>for Listen:
>>
>>Apache  \   OS      | IPV4         |  IPV6
>>--------------------------------------------
>>--enable-v4-mapped  |      80      |  80
>>--disable-v4-mapped | can't happen |  127.0.0.1:80
>>
>>Am I correct? So we need to use 'Listen 127.0.0.1:80' only when we see:
>>
>>-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled), .i.e. --disable-v4-mapped
>>
>>otherwise the old '80' is fine.
> 
> 
> Yes, that's the way I've experienced/understood it on my trusty OpenBSD
> box (and Linux with IPv6)

OK, so how about you go ahead and commit your original patch (hardcoding 
127.0.0.1). And log the above table in the Apache-Test/ToDo list, to may be 
check have 127.0.0.1 hardcoded only if --disable-v4-mapped is detected, in 
case someone will have problems with that change.



-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Tue, 2004-02-17 at 14:52 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> [...]
> >>>Ideally, to fix this once and for all, we need to determine 2 things:
> >>>
> >>>1. The availability of IPv6 on that box
> >>>2. Wether httpd was compiled with --enable-v4-mapped or not (or what it
> >>>defaulted to)
> >>
> >>Well, if we can figure out (2), then 1 can be skipped. If someone built Apache 
> >>with v6, it certainly won't work on a system w/o ipv6 enabled. No?
> >>
> >>On my machine:
> >>% httpd -V | grep -i ipv
> >>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
> >>
> >>what's yours (with ipv6?)
> > 
> > 
> > OpenBSD 3.4, with no special ./configure options:
> > 
> >  -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
> > 
> > So what this actually means is that unless explicitily stated, a :
> > 
> > Listen 80
> > 
> > in your httpd.conf will _only_ bind on ::1, and not bind to an ipv4
> > address.
> > 
> > Specifying 
> > 
> > Listen 127.0.0.1:80 
> > 
> > will _only_ bind on the ipv4 localhost address...
> > 
> > And if you ./configure --enable-v4-mapped
> > 
> > Listen 80
> > 
> > Will get you an IPv6 listening socket on ::1 that's _also_ listening on
> > the ipv4 equivalent of 127.0.0.1
> 
> I'll try to summarize what you said in a table. The following approaches work 
> for Listen:
> 
> Apache  \   OS      | IPV4         |  IPV6
> --------------------------------------------
> --enable-v4-mapped  |      80      |  80
> --disable-v4-mapped | can't happen |  127.0.0.1:80
> 
> Am I correct? So we need to use 'Listen 127.0.0.1:80' only when we see:
> 
> -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled), .i.e. --disable-v4-mapped
> 
> otherwise the old '80' is fine.

Yes, that's the way I've experienced/understood it on my trusty OpenBSD
box (and Linux with IPv6)

> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
[...]
>>>Ideally, to fix this once and for all, we need to determine 2 things:
>>>
>>>1. The availability of IPv6 on that box
>>>2. Wether httpd was compiled with --enable-v4-mapped or not (or what it
>>>defaulted to)
>>
>>Well, if we can figure out (2), then 1 can be skipped. If someone built Apache 
>>with v6, it certainly won't work on a system w/o ipv6 enabled. No?
>>
>>On my machine:
>>% httpd -V | grep -i ipv
>>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
>>
>>what's yours (with ipv6?)
> 
> 
> OpenBSD 3.4, with no special ./configure options:
> 
>  -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)
> 
> So what this actually means is that unless explicitily stated, a :
> 
> Listen 80
> 
> in your httpd.conf will _only_ bind on ::1, and not bind to an ipv4
> address.
> 
> Specifying 
> 
> Listen 127.0.0.1:80 
> 
> will _only_ bind on the ipv4 localhost address...
> 
> And if you ./configure --enable-v4-mapped
> 
> Listen 80
> 
> Will get you an IPv6 listening socket on ::1 that's _also_ listening on
> the ipv4 equivalent of 127.0.0.1

I'll try to summarize what you said in a table. The following approaches work 
for Listen:

Apache  \   OS      | IPV4         |  IPV6
--------------------------------------------
--enable-v4-mapped  |      80      |  80
--disable-v4-mapped | can't happen |  127.0.0.1:80

Am I correct? So we need to use 'Listen 127.0.0.1:80' only when we see:

-D APR_HAVE_IPV6 (IPv4-mapped addresses disabled), .i.e. --disable-v4-mapped

otherwise the old '80' is fine.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Tue, 2004-02-17 at 12:27 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > On Fri, 2004-02-13 at 15:51 -0800, Stas Bekman wrote:
> > 
> >>Philippe M. Chiasson wrote:
> >>
> >>>On Thu, 2004-02-12 at 10:24 -0800, Stas Bekman wrote:
> >>>[...]
> > [...]
> > 
> > Ideally, to fix this once and for all, we need to determine 2 things:
> > 
> > 1. The availability of IPv6 on that box
> > 2. Wether httpd was compiled with --enable-v4-mapped or not (or what it
> > defaulted to)
> 
> Well, if we can figure out (2), then 1 can be skipped. If someone built Apache 
> with v6, it certainly won't work on a system w/o ipv6 enabled. No?
> 
> On my machine:
> % httpd -V | grep -i ipv
>   -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
> 
> what's yours (with ipv6?)

OpenBSD 3.4, with no special ./configure options:

 -D APR_HAVE_IPV6 (IPv4-mapped addresses disabled)

So what this actually means is that unless explicitily stated, a :

Listen 80

in your httpd.conf will _only_ bind on ::1, and not bind to an ipv4
address.

Specifying 

Listen 127.0.0.1:80 

will _only_ bind on the ipv4 localhost address...

And if you ./configure --enable-v4-mapped

Listen 80

Will get you an IPv6 listening socket on ::1 that's _also_ listening on
the ipv4 equivalent of 127.0.0.1


> > And once we can figure that out, then can we make a correct decision as
> > to what to bind to.
> > 
> > But, AFAIK, 127.0.0.1 (or ::1) _must_ be the a loopback address, isn't
> > it ?
> 
> It usually is. But I think you can change it. Otherwise you won't need to list 
> it in /etc/hosts if it was hardcoded to 127.0.0.1 in all software products. 
> But I could be wrong.
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> On Fri, 2004-02-13 at 15:51 -0800, Stas Bekman wrote:
> 
>>Philippe M. Chiasson wrote:
>>
>>>On Thu, 2004-02-12 at 10:24 -0800, Stas Bekman wrote:
>>>[...]
>>>Configuring httpd with --enable-v4-mapped will make it all work, but
>>>it's not the default, so most people on those BSDs are getting an httpd
>>>that will default to IPv6. Even localhost in /etc/hosts is going to be
>>>'::1' (ipv6 equiv of localhost).
>>
>>So will the name->ip resolving function return ::1 then? in which case you get 
>>the detection mechanism working, no?
>>
>>on ipv4 we get:
>>% perl -le 'use Socket; print inet_ntoa scalar gethostbyname shift;' localhost
>>
>>127.0.0.1
>>
>>what do you get on ipv6?
> 
> 
> 127.0.0.1 ;-)
> 
> The problem in this case is that for backwards-compatibility, the
> resolver library will return IPv4 address, unless (on OpenBSD) you use
> gethostbyname2(...,AF_INET6), and I don't think Perl exposes that stuff
> yet.

Thanks.

>>>The following patch (short of being to detect at configure time the
>>>IPv4/6 status of the box) hard-codes all the listening IP addresses to
>>>127.0.0.1, effectively ensuring all the test suite runs under vanilla-
>>>IPv4.
>>>
>>>Ideally, I'd like to figure out a way to detect things correctly, and
>>>pick between 127.0.0.1 and ::1 accordingly.
>>
>>What happens if localhost != 127.0.0.1? Shouldn't we use 'localhost' instead? 
>>(though we know cases when users didn't have localhost defined in /etc/hosts)
> 
> 
> Yeah, well, problems arises when localhost in /etc/hosts is ::1 (ipv6
> loopback)
> 
> Ideally, to fix this once and for all, we need to determine 2 things:
> 
> 1. The availability of IPv6 on that box
> 2. Wether httpd was compiled with --enable-v4-mapped or not (or what it
> defaulted to)

Well, if we can figure out (2), then 1 can be skipped. If someone built Apache 
with v6, it certainly won't work on a system w/o ipv6 enabled. No?

On my machine:
% httpd -V | grep -i ipv
  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)

what's yours (with ipv6?)

> And once we can figure that out, then can we make a correct decision as
> to what to bind to.
> 
> But, AFAIK, 127.0.0.1 (or ::1) _must_ be the a loopback address, isn't
> it ?

It usually is. But I think you can change it. Otherwise you won't need to list 
it in /etc/hosts if it was hardcoded to 127.0.0.1 in all software products. 
But I could be wrong.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Fri, 2004-02-13 at 15:51 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > On Thu, 2004-02-12 at 10:24 -0800, Stas Bekman wrote:
> > [...]
> > Configuring httpd with --enable-v4-mapped will make it all work, but
> > it's not the default, so most people on those BSDs are getting an httpd
> > that will default to IPv6. Even localhost in /etc/hosts is going to be
> > '::1' (ipv6 equiv of localhost).
> 
> So will the name->ip resolving function return ::1 then? in which case you get 
> the detection mechanism working, no?
> 
> on ipv4 we get:
> % perl -le 'use Socket; print inet_ntoa scalar gethostbyname shift;' localhost
> 
> 127.0.0.1
> 
> what do you get on ipv6?

127.0.0.1 ;-)

The problem in this case is that for backwards-compatibility, the
resolver library will return IPv4 address, unless (on OpenBSD) you use
gethostbyname2(...,AF_INET6), and I don't think Perl exposes that stuff
yet.

> > The following patch (short of being to detect at configure time the
> > IPv4/6 status of the box) hard-codes all the listening IP addresses to
> > 127.0.0.1, effectively ensuring all the test suite runs under vanilla-
> > IPv4.
> > 
> > Ideally, I'd like to figure out a way to detect things correctly, and
> > pick between 127.0.0.1 and ::1 accordingly.
> 
> What happens if localhost != 127.0.0.1? Shouldn't we use 'localhost' instead? 
> (though we know cases when users didn't have localhost defined in /etc/hosts)

Yeah, well, problems arises when localhost in /etc/hosts is ::1 (ipv6
loopback)

Ideally, to fix this once and for all, we need to determine 2 things:

1. The availability of IPv6 on that box
2. Wether httpd was compiled with --enable-v4-mapped or not (or what it
defaulted to)

And once we can figure that out, then can we make a correct decision as
to what to bind to.

But, AFAIK, 127.0.0.1 (or ::1) _must_ be the a loopback address, isn't
it ?
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: [patch mp2] forcing IPv4 configuration [was:Apache::Test on FreeBSD]

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> On Thu, 2004-02-12 at 10:24 -0800, Stas Bekman wrote:
> 
>>Andrew Wyllie wrote:
>>
>>>
>>>So, after rereading my previous post, I found one slight difference 
>>>(funny how
>>>it works that way sometimes).  When I used telnet to connect to the 
>>>server, it
>>>used '::1' as an address for localhost as opposed to 127.0.0.1 .  So I 
>>>changed all the
>>>refs to localhost in httpd.conf to ::1 and sure enough, all the tests 
>>>passed.  I'm going to look
>>>into this a bit more to see why this is the case as I have always 
>>>thought that both of these
>>>cases should work the same way.  
>>
>>So how can we make it into a setup that will work on both, ipv6 and ipv4?
> 
> 
> The problem is that on most BSDs, IPv6 is starting to become the default
> setup, at least, it's the case on my OpenBSD box.
> 
> Configuring httpd with --enable-v4-mapped will make it all work, but
> it's not the default, so most people on those BSDs are getting an httpd
> that will default to IPv6. Even localhost in /etc/hosts is going to be
> '::1' (ipv6 equiv of localhost).

So will the name->ip resolving function return ::1 then? in which case you get 
the detection mechanism working, no?

on ipv4 we get:
% perl -le 'use Socket; print inet_ntoa scalar gethostbyname shift;' localhost

127.0.0.1

what do you get on ipv6?

> The following patch (short of being to detect at configure time the
> IPv4/6 status of the box) hard-codes all the listening IP addresses to
> 127.0.0.1, effectively ensuring all the test suite runs under vanilla-
> IPv4.
> 
> Ideally, I'd like to figure out a way to detect things correctly, and
> pick between 127.0.0.1 and ::1 accordingly.

What happens if localhost != 127.0.0.1? Shouldn't we use 'localhost' instead? 
(though we know cases when users didn't have localhost defined in /etc/hosts)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html