Re: [Patch] Better IPv6 detection and configuration
On Tue, 2004-03-30 at 19:40 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: On Tue, 2004-03-30 at 15:25 -0500, Geoffrey Young wrote: Something like this will most likely work for everyone (ipv4/v6) with the only difference is that the test servers are not listening to localhost anymore and could be reached from oustide machines (do we care?) What happens in the following situation: One machine, two NICs, two IPs 10.0.0.1 and 10.0.0.2. If I say 'Listen *:8529' it'll try to listen on both IPs. What happens if 10.0.0.2:8529 is already taken and 10.0.0.1:8529 is available? Will it fail to start, saying that the port is busy? That's what it'll do, yes. The test framework will detect this early and report that : port 8529 is in use, cannot determine server pid to shutdown I actually find that a nice feature, as it means you can use t/TEST -start to start up your test config then, say, hit it from a browser on a different box. as it is now, you have to hand-edit the generated httpd.conf for that (or at least I did) Well, I agree with you, but other people might argue that it is somewhat of a security risk to start up a server and _not_ listen strictly on localhost. But, yes, I do think that Joe's suggestion is the best one and will keep tests passing until LWP becomes IPv6 aware. Untill we have a better solution (proper detection mechanism), by all means go with it, Philippe. You mean the one with Listen 0.0.0.0:port ? Thanks for the idea, Joe! __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com signature.asc Description: This is a digitally signed message part
Re: [Patch] Better IPv6 detection and configuration
Philippe M. Chiasson wrote: On Mon, 2004-03-29 at 15:43 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: After a bit of poking around different flavors of IPv6 systems, I've encountered a few situations where Apache::Test ends up configuring httpd in a way that can't be tested. This typically only happens on a system that has IPv4-mapped IPv6 addresses disabled, i.e. OpenBSD. If the hostname that is picked to form the Listen directives happens to have both an IPv4 and an IPv6 address, i.e localhot on OpenBSD, the server will start but will only be listening on an IPv6 address. And since LWP doesn't do requests over IPv6, all tests will fail. The following patch attempts to do handle all this by doing one of a few many things. gozer++ If the server has ipv4-mapped addresses, Listen to *:port, forcing the use of ipv4-mapped addresses and insuring that the server will be available over it's ipv4 address. Otherwise try to use Socket6 to see if the hostname is both v4 and v6 and Listen to *:port as well. Without Socket6 (not part of the Perl core), just warn the user about possible problems he/she will run into if the selected hostname happens to be ipv6. [...] +else { +if (eval { require Socket6 }) { +if (Socket6::gethostbyname2($name, Socket6::AF_INET6())) { +$self-{vars}{listen_addr} = '*'; +} +} +else { +warning Socket6 not installed; +warning Test might fail if your hostname: '$name' has an IPv6 address; I think we should die here: error EOI; Your system is configured to run both ipv6 and ipv4, but the right interface can't be selected. Please install the perl CPAN module Socket6 and re-run the last command. EOI die \n; That's something I considered, but I figured it was better to be gentle and just warn people that things might not work. I am perfectly fine with die instead. and if Socket6 builds everywhere, and including older perls, we should include it in Apache-Test's %PREREQ_PM. Well, I built it successfully with a combination of 5.8.x and 5.6.x on linux, freebsd and openbsd. I am not sure if it builds on systems without ipv4 support though. OK, so let's keep it warning/out of prereq for now while we polish it. but please replace s/warning/error/ so it'll more prominent. thanks. -- __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [Patch] Better IPv6 detection and configuration
On Mon, 2004-03-29 at 16:21 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: On Mon, 2004-03-29 at 15:43 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: After a bit of poking around different flavors of IPv6 systems, I've encountered a few situations where Apache::Test ends up configuring httpd in a way that can't be tested. This typically only happens on a system that has IPv4-mapped IPv6 addresses disabled, i.e. OpenBSD. If the hostname that is picked to form the Listen directives happens to have both an IPv4 and an IPv6 address, i.e localhot on OpenBSD, the server will start but will only be listening on an IPv6 address. And since LWP doesn't do requests over IPv6, all tests will fail. The following patch attempts to do handle all this by doing one of a few many things. gozer++ If the server has ipv4-mapped addresses, Listen to *:port, forcing the use of ipv4-mapped addresses and insuring that the server will be available over it's ipv4 address. Otherwise try to use Socket6 to see if the hostname is both v4 and v6 and Listen to *:port as well. Without Socket6 (not part of the Perl core), just warn the user about possible problems he/she will run into if the selected hostname happens to be ipv6. [...] +else { +if (eval { require Socket6 }) { +if (Socket6::gethostbyname2($name, Socket6::AF_INET6())) { +$self-{vars}{listen_addr} = '*'; +} +} +else { +warning Socket6 not installed; +warning Test might fail if your hostname: '$name' has an IPv6 address; I think we should die here: error EOI; Your system is configured to run both ipv6 and ipv4, but the right interface can't be selected. Please install the perl CPAN module Socket6 and re-run the last command. EOI die \n; That's something I considered, but I figured it was better to be gentle and just warn people that things might not work. I am perfectly fine with die instead. and if Socket6 builds everywhere, and including older perls, we should include it in Apache-Test's %PREREQ_PM. Well, I built it successfully with a combination of 5.8.x and 5.6.x on linux, freebsd and openbsd. I am not sure if it builds on systems without ipv4 support though. OK, so let's keep it warning/out of prereq for now while we polish it. Sure! but please replace s/warning/error/ so it'll more prominent. thanks. Patch following: 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.213 diff -u -I$Id -r1.213 TestConfig.pm --- Apache-Test/lib/Apache/TestConfig.pm4 Mar 2004 05:51:31 - 1.213 +++ Apache-Test/lib/Apache/TestConfig.pm30 Mar 2004 00:48:58 - @@ -63,6 +63,7 @@ documentroot= 'DocumentRoot (default is $ServerRoot/htdocs', port= 'Port [port_number|select] (default ' . DEFAULT_PORT . ')', servername = 'ServerName (default is localhost)', + listen_addr = 'The address to use in Listen directives', user= 'User to run test server as (default is $USER)', group = 'Group to run test server as (default is $GROUP)', bindir = 'Apache bin/ dir (default is apxs -q BINDIR)', @@ -272,7 +273,7 @@ $vars-{servername} ||= $self-default_servername; $vars-{port} = $self-select_first_port; $vars-{remote_addr} ||= $self-our_remote_addr; - +$vars-{listen_addr} ||= $self-default_localhost; $vars-{user} ||= $self-default_user; $vars-{group}||= $self-default_group; $vars-{serveradmin} ||= $self-default_serveradmin; @@ -286,6 +287,8 @@ $self-inherit_config; #see TestConfigParse.pm $self-configure_httpd_eapi; #must come after inherit_config +$self-check_ipv6; + $self-default_module(cgi= [qw(mod_cgi mod_cgid)]); $self-default_module(thread = [qw(worker threaded)]); $self-default_module(ssl= [qw(mod_ssl)]); @@ -637,6 +640,45 @@ $remote_addr ||= Socket::inet_ntoa($iaddr); } +my $apr_ipv6; +sub apr_has_ipv6 { +my $self = shift; +return $apr_ipv6 if defined $apr_ipv6; +foreach my $key (keys %{$self-{httpd_defines}}) { +return $apr_ipv6 = $key if $key =~ /^APR_HAVE_IPV6/; +} +} + +sub apr_has_ipv4_mapped { +my $self = shift; +return $self-apr_has_ipv6 =~ /IPv4-mapped addresses enabled/; +} + +sub check_ipv6 { +my $self = shift; + +return if $self-{vars}{listen_addr} ne $self-default_localhost; + +my $name = $self-{vars}{servername}; + +if ($self-apr_has_ipv6) { +if ($self-apr_has_ipv4_mapped) { +$self-{vars}{listen_addr} = '*'; +} +else { +if (eval { require Socket6
Re: [Patch] Better IPv6 detection and configuration
Philippe M. Chiasson wrote: On Mon, 2004-03-29 at 17:13 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: On Mon, 2004-03-29 at 17:03 -0800, Stas Bekman wrote: Philippe M. Chiasson wrote: +error Socket6 not installed; +error Test might fail if your hostname: '$name' has an IPv6 address; not too clear what to do in case of a problem, and what consitutes a problem. Yeah, guess the message is a bit too terse. something like this? error EOI; Your system is configured to run both ipv6 and ipv4, but can't figure out which interface to use, trying to use ipv6. If the test suite doesn't start, please install the perl CPAN module 'Socket6' and re-run the last command. EOI How about: Your system is configured to run both ipv6 and ipv4, but can't figure out if the hostname 'name' is ipv4 only. If the test suite doesn't start, try specifying a servername that you know is only ipv4, or what action user is supposed to undertake when you say that? it should be really clear, or we will end up with a question onto the list. Well, what I am trying to say is that if the user goes I understand what you are trying to say to me, but the user most likely won't. result: question to the list and we achieved nada. perl Makefile.PL -servername my.name.com or perl Makefile.PL -servername 127.0.0.1 His/Her problem will also go away. and that's exactly what the error message should say. but how the user will know which name to use? installing Socket6 will not solve the problem, but just allow me to detect if a problem is certain to happen. that's why I suggest to require Socket6, figure exactly what's going on and what user should do in case of ambiguety and based on the information that is accessible (.e.g resolve localhost and use the ip address, etc) the error message should explain what to do next. In any case, at that point, the user will need to specify an ipv4 hostname/address. most users don't know what is ipv4 hostname/address. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [Patch] Better IPv6 detection and configuration
Would it not be simpler to just change the Listen statements to be Listen 0.0.0.0:port by default and avoid the IPv6 issue entirely? joe
Re: [Patch] Better IPv6 detection and configuration
Philippe M. Chiasson wrote: After a bit of poking around different flavors of IPv6 systems, I've encountered a few situations where Apache::Test ends up configuring httpd in a way that can't be tested. This typically only happens on a system that has IPv4-mapped IPv6 addresses disabled, i.e. OpenBSD. If the hostname that is picked to form the Listen directives happens to have both an IPv4 and an IPv6 address, i.e localhot on OpenBSD, the server will start but will only be listening on an IPv6 address. And since LWP doesn't do requests over IPv6, all tests will fail. The following patch attempts to do handle all this by doing one of a few many things. gozer++ If the server has ipv4-mapped addresses, Listen to *:port, forcing the use of ipv4-mapped addresses and insuring that the server will be available over it's ipv4 address. Otherwise try to use Socket6 to see if the hostname is both v4 and v6 and Listen to *:port as well. Without Socket6 (not part of the Perl core), just warn the user about possible problems he/she will run into if the selected hostname happens to be ipv6. [...] +else { +if (eval { require Socket6 }) { +if (Socket6::gethostbyname2($name, Socket6::AF_INET6())) { +$self-{vars}{listen_addr} = '*'; +} +} +else { +warning Socket6 not installed; +warning Test might fail if your hostname: '$name' has an IPv6 address; I think we should die here: error EOI; Your system is configured to run both ipv6 and ipv4, but the right interface can't be selected. Please install the perl CPAN module Socket6 and re-run the last command. EOI die \n; and if Socket6 builds everywhere, and including older perls, we should include it in Apache-Test's %PREREQ_PM. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com