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/21 01:12:36 UTC

[Patch mp2] Better solution for Apache-Test on IPv6 boxes

This is a followup on my previous patch to attempt and solve the
problems people are having with Apache-Test on boxes with IPv6 and no
support for ipv4-mapped addresses in httpd.

Instead of hard-coding 127.0.0.1 in the listen directive, this patch
uses the servername instead.

The original problem was with statements such as:

Listen 80

That on IPv6 with no IPv4-mapped address would end up listening strictly
on the IPv6 loopback address (::1)

What seems to me like a superior solution is to use the servername
instead. That way, if a user has trouble because localhost defaults
to ::1 on his/her setup, passing -servername to ./t/TEST will fix the
problem.

For example

./t/TEST -servername some.name.for.an.ipv4.address.of.this.box

And then, of course, once LWP & Perl become IPv6 friendly, the tests
will be successfull even if localhost on the box points to ::1.

Only annoying side-effect is that this patch disables name-lookups on
the servername (I couldn't find a reason why it was doing it in the
first place anyhos). 

mod_perl 2.0 tests 100% fine with it, and so  does perl-framework (no
new errors).

Thoughts ?

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.209
diff -u -I$Id -r1.209 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	20 Feb 2004 23:51:54 -0000	1.209
+++ Apache-Test/lib/Apache/TestConfig.pm	21 Feb 2004 00:06:17 -0000
@@ -634,19 +634,8 @@
     my $module = shift || '';
 
     my $name = $vars->{servername};
-    my $resolve = \$self->{resolved}->{$name};
 
-    unless ($$resolve) {
-        if (gethostbyname $name) {
-            $$resolve = $name;
-        }
-        else {
-            $$resolve = $self->default_loopback;
-            warn "lookup $name failed, using $$resolve for client tests\n";
-        }
-    }
-
-    join ':', $$resolve || 'localhost', $self->port($module || '');
+    join ':', $name , $self->port($module || '');
 }
 
 #look for mod_foo.so
@@ -1004,7 +993,7 @@
     my @out_config = ();
     if ($self->{vhosts}->{$module}->{namebased} < 2) {
         #extra config that should go *outside* the <VirtualHost ...>
-        @out_config = ([Listen => '127.0.0.1:' . $port]);
+        @out_config = ([Listen => $vars->{servername} . ':' . $port]);
 
         if ($self->{vhosts}->{$module}->{namebased}) {
             push @out_config => [NameVirtualHost => "*:$port"];
@@ -1772,7 +1761,7 @@
 
 
 __DATA__
-Listen     127.0.0.1:@Port@
+Listen     @ServerName@:@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.82
diff -u -I$Id -r1.82 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm	18 Feb 2004 00:30:57 -0000	1.82
+++ Apache-Test/lib/Apache/TestConfigPerl.pm	21 Feb 2004 00:06:17 -0000
@@ -207,7 +207,8 @@
 sub set_connection_handler {
     my($self, $module, $args) = @_;
     my $port = $self->new_vhost($module);
-    $self->postamble(Listen => '127.0.0.1:' . $port);
+    my $vars = $self->{vars};
+    $self->postamble(Listen => $vars->{servername} . ':' . $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.8
diff -u -I$Id -r1.8 conftree.pm
--- t/response/TestApache/conftree.pm	18 Feb 2004 00:30:57 -0000	1.8
+++ t/response/TestApache/conftree.pm	21 Feb 2004 00:06:17 -0000
@@ -29,7 +29,7 @@
 
     my $listen = $tree->lookup('Listen');
 
-    ok t_cmp('127.0.0.1:' . $vars->{port}, $listen);
+    ok t_cmp(join(':', $vars->{servername}, $vars->{port}), $listen);
 
     my $documentroot = $tree->lookup('DocumentRoot');
 
-- 
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5


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


Re: [Patch mp2] Better solution for Apache-Test on IPv6 boxes

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
[...]
>>+1 to commit.
> 
> 
> Done.

Thanks, Philippe!

But in the future please commit A-T changes from within the Apache-Test/ dir, 
so that they will be emailed to the right cvs commit list and therefore end up 
in the right archive for the future reference.

__________________________________________________________________
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


Re: [Patch mp2] Better solution for Apache-Test on IPv6 boxes

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Fri, 2004-02-20 at 16:54 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > This is a followup on my previous patch to attempt and solve the
> > problems people are having with Apache-Test on boxes with IPv6 and no
> > support for ipv4-mapped addresses in httpd.
> > 
> > Instead of hard-coding 127.0.0.1 in the listen directive, this patch
> > uses the servername instead.
> > 
> > The original problem was with statements such as:
> > 
> > Listen 80
> > 
> > That on IPv6 with no IPv4-mapped address would end up listening strictly
> > on the IPv6 loopback address (::1)
> > 
> > What seems to me like a superior solution is to use the servername
> > instead. That way, if a user has trouble because localhost defaults
> > to ::1 on his/her setup, passing -servername to ./t/TEST will fix the
> > problem.
> > 
> > For example
> > 
> > ./t/TEST -servername some.name.for.an.ipv4.address.of.this.box
> > 
> > And then, of course, once LWP & Perl become IPv6 friendly, the tests
> > will be successfull even if localhost on the box points to ::1.
> 
> Sounds very good to me. I hope we don't miss some special cases we haven't 
> thought of.

We'll have to see about that. I am indeed a tiny bit curious about the
resolving logic I ended up removing. I searched all over perl-framework
and I couldn't find a single place it was being used.

> > Only annoying side-effect is that this patch disables name-lookups on
> > the servername (I couldn't find a reason why it was doing it in the
> > first place anyhos). 
> 
> I wonder too. I guess there was a reason for doing that. Unfortunately it 
> wasn't documented.

Well, I imagine that if this change does cause trouble, and we have to
re-add that logic, at least we'll know why it was there in the first
place.

> > mod_perl 2.0 tests 100% fine with it, and so  does perl-framework (no
> > new errors).
> > 
> > Thoughts ?
> 
> +1 to commit.

Done.

>  We can always revert things back if we find that there is a 
> problem with that approach. put it in and I'll post an A-T release candidate 
> shortly afterwards.

Release away!

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

Re: [Patch mp2] Better solution for Apache-Test on IPv6 boxes

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:
> This is a followup on my previous patch to attempt and solve the
> problems people are having with Apache-Test on boxes with IPv6 and no
> support for ipv4-mapped addresses in httpd.
> 
> Instead of hard-coding 127.0.0.1 in the listen directive, this patch
> uses the servername instead.
> 
> The original problem was with statements such as:
> 
> Listen 80
> 
> That on IPv6 with no IPv4-mapped address would end up listening strictly
> on the IPv6 loopback address (::1)
> 
> What seems to me like a superior solution is to use the servername
> instead. That way, if a user has trouble because localhost defaults
> to ::1 on his/her setup, passing -servername to ./t/TEST will fix the
> problem.
> 
> For example
> 
> ./t/TEST -servername some.name.for.an.ipv4.address.of.this.box
> 
> And then, of course, once LWP & Perl become IPv6 friendly, the tests
> will be successfull even if localhost on the box points to ::1.

Sounds very good to me. I hope we don't miss some special cases we haven't 
thought of.

> Only annoying side-effect is that this patch disables name-lookups on
> the servername (I couldn't find a reason why it was doing it in the
> first place anyhos). 

I wonder too. I guess there was a reason for doing that. Unfortunately it 
wasn't documented.

> mod_perl 2.0 tests 100% fine with it, and so  does perl-framework (no
> new errors).
> 
> Thoughts ?

+1 to commit. We can always revert things back if we find that there is a 
problem with that approach. put it in and I'll post an A-T release candidate 
shortly afterwards.


__________________________________________________________________
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