You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Justin Erenkrantz <ju...@erenkrantz.com> on 2005/02/23 07:52:57 UTC
Listen 0.0.0.0: is invalid
No idea why I'm suddenly hitting this, but in preparation for 2.1.3, I spent
another one of my patented hours searching for bugs in httpd that end up being
bugs in the perl-framework tests. =(
perl-framework generates Listen directives in the order of:
'Listen 0.0.0.0:8529'
For me, this causes errors like:
(48)Address already in use: make_sock: could not bind to address 0.0.0.0:8531
no listening sockets available, shutting down
Unable to open logs
On Mac OS X 10.3.8 (7.8.0 via uname -r), getaddrinfo() without AI_PASSIVE can
return duplicate IP addresses. This leads to the error condition that causes
the failure. And, based on my reading of the docs, I'm not sure that's
patently incorrect behavior on Darwin's part: that's 0.0.0.0 for both the
localhost and the network card.
The issue with this is that wildcard IP addresses aren't really supposed to be
explicit in Listen statements. httpd has a bunch of logic for inferring the
right IP wildcards - trying to out-guess can lead to real badness.
Specifically, this mucks with APR's ability to set AI_PASSIVE - which is
required for use with address that we will later call bind() on - i.e. our
listeners. So, Listen with an IP address should only be used for real
addresses.
Manually changing httpd-test's Listen statements to just 'Listen <port>' allow
me to run the tests correctly.
I don't have a clue how to change that in the Perl code though...
Thanks. -- justin
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 23, 2005 at 09:42:12AM +0000, Joe Orton wrote:
> On Tue, Feb 22, 2005 at 10:52:57PM -0800, Justin Erenkrantz wrote:
> > The issue with this is that wildcard IP addresses aren't really supposed to
> > be explicit in Listen statements. httpd has a bunch of logic for inferring
> > the right IP wildcards - trying to out-guess can lead to real badness.
> > Specifically, this mucks with APR's ability to set AI_PASSIVE - which is
> > required for use with address that we will later call bind() on - i.e. our
> > listeners. So, Listen with an IP address should only be used for real
> > addresses.
>
> The problem was that 2.0.x will only accept connections to IPv6
> addresses with a single "Listen <port>"
Missing the critical qualifier :) "on *BSD systems which disable
V4-mapped addresses by default"
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 23, 2005 at 09:42:12AM +0000, Joe Orton wrote:
> On Tue, Feb 22, 2005 at 10:52:57PM -0800, Justin Erenkrantz wrote:
> > The issue with this is that wildcard IP addresses aren't really supposed to
> > be explicit in Listen statements. httpd has a bunch of logic for inferring
> > the right IP wildcards - trying to out-guess can lead to real badness.
> > Specifically, this mucks with APR's ability to set AI_PASSIVE - which is
> > required for use with address that we will later call bind() on - i.e. our
> > listeners. So, Listen with an IP address should only be used for real
> > addresses.
>
> The problem was that 2.0.x will only accept connections to IPv6
> addresses with a single "Listen <port>"
Missing the critical qualifier :) "on *BSD systems which disable
V4-mapped addresses by default"
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 23, 2005 at 07:37:54AM -0800, Justin Erenkrantz wrote:
> --On Wednesday, February 23, 2005 9:42 AM +0000 Joe Orton
> <jo...@redhat.com> wrote:
>
> >But there is no way to differentiate between any different interfaces
> >for the address (without doing magic), so I would say that is a resolver
> >misfeature.
>
> But, the resolver was explicitly told that the socket addresses will be
> used to connect() - not for bind(). That's why I'm not convinced this
> behavior is 'wrong' per se.
A connect() to 0.0.0.0:80 is just the same; I don't see why it would
ever be useful to include two completely identical addresses in the
getaddrinfo results.
Simply passing AI_PASSIVE does make it omit the duplicates?
(http://cvs.apache.org/~jorton/gai.c is useful for testing getaddrinfo
behaviour)
> >to configure httpd to bind only to "all IPv4 addresses on the local host
> >with port X" (right?), which is certainly a valid and useful thing to
> >do.
> >
> >I think httpd should work around this: does something like the attached
> >work? (tested only to compile ;) Not necessarily the best place to put
> >this logic.
>
> It seems that we should have a better internal semantic than passing in a
> bogus address to connect to. Perhaps httpd in alloc_listener should
> intercept the '0.0.0.0' case and set the hostname to NULL and set the
> family to IPv4? This would preserve the correct internal semantics we're
> looking for such that AI_PASSIVE can be set so we get bind()able addresses.
>
> Would that be better? -- justin
INADDR_ANY is not really a bogus address, but yes I think that does make
more sense. It would also need to translate "::" into
hostname=NULL+family=AF_INET6 for consistency I suppose. But triggering
the AI_PASSIVE path is generally desirable.
Do you have time to try that out?
joe
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Wed, Feb 23, 2005 at 07:37:54AM -0800, Justin Erenkrantz wrote:
> --On Wednesday, February 23, 2005 9:42 AM +0000 Joe Orton
> <jo...@redhat.com> wrote:
>
> >But there is no way to differentiate between any different interfaces
> >for the address (without doing magic), so I would say that is a resolver
> >misfeature.
>
> But, the resolver was explicitly told that the socket addresses will be
> used to connect() - not for bind(). That's why I'm not convinced this
> behavior is 'wrong' per se.
A connect() to 0.0.0.0:80 is just the same; I don't see why it would
ever be useful to include two completely identical addresses in the
getaddrinfo results.
Simply passing AI_PASSIVE does make it omit the duplicates?
(http://cvs.apache.org/~jorton/gai.c is useful for testing getaddrinfo
behaviour)
> >to configure httpd to bind only to "all IPv4 addresses on the local host
> >with port X" (right?), which is certainly a valid and useful thing to
> >do.
> >
> >I think httpd should work around this: does something like the attached
> >work? (tested only to compile ;) Not necessarily the best place to put
> >this logic.
>
> It seems that we should have a better internal semantic than passing in a
> bogus address to connect to. Perhaps httpd in alloc_listener should
> intercept the '0.0.0.0' case and set the hostname to NULL and set the
> family to IPv4? This would preserve the correct internal semantics we're
> looking for such that AI_PASSIVE can be set so we get bind()able addresses.
>
> Would that be better? -- justin
INADDR_ANY is not really a bogus address, but yes I think that does make
more sense. It would also need to translate "::" into
hostname=NULL+family=AF_INET6 for consistency I suppose. But triggering
the AI_PASSIVE path is generally desirable.
Do you have time to try that out?
joe
Re: Listen 0.0.0.0: is invalid
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Wednesday, February 23, 2005 9:42 AM +0000 Joe Orton <jo...@redhat.com>
wrote:
> But there is no way to differentiate between any different interfaces
> for the address (without doing magic), so I would say that is a resolver
> misfeature.
But, the resolver was explicitly told that the socket addresses will be used
to connect() - not for bind(). That's why I'm not convinced this behavior is
'wrong' per se.
> "Listen 0.0.0.0:<port>" should always work because there's no other way
> to configure httpd to bind only to "all IPv4 addresses on the local host
> with port X" (right?), which is certainly a valid and useful thing to
> do.
>
> I think httpd should work around this: does something like the attached
> work? (tested only to compile ;) Not necessarily the best place to put
> this logic.
It seems that we should have a better internal semantic than passing in a
bogus address to connect to. Perhaps httpd in alloc_listener should intercept
the '0.0.0.0' case and set the hostname to NULL and set the family to IPv4?
This would preserve the correct internal semantics we're looking for such that
AI_PASSIVE can be set so we get bind()able addresses.
Would that be better? -- justin
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Tue, Feb 22, 2005 at 10:52:57PM -0800, Justin Erenkrantz wrote:
> No idea why I'm suddenly hitting this, but in preparation for 2.1.3, I
> spent another one of my patented hours searching for bugs in httpd that end
> up being bugs in the perl-framework tests. =(
>
> perl-framework generates Listen directives in the order of:
> 'Listen 0.0.0.0:8529'
>
> For me, this causes errors like:
> (48)Address already in use: make_sock: could not bind to address
> 0.0.0.0:8531
> no listening sockets available, shutting down
> Unable to open logs
>
> On Mac OS X 10.3.8 (7.8.0 via uname -r), getaddrinfo() without AI_PASSIVE
> can return duplicate IP addresses. This leads to the error condition that
> causes the failure. And, based on my reading of the docs, I'm not sure
> that's patently incorrect behavior on Darwin's part: that's 0.0.0.0 for
> both the localhost and the network card.
But there is no way to differentiate between any different interfaces
for the address (without doing magic), so I would say that is a resolver
misfeature.
"Listen 0.0.0.0:<port>" should always work because there's no other way
to configure httpd to bind only to "all IPv4 addresses on the local host
with port X" (right?), which is certainly a valid and useful thing to
do.
I think httpd should work around this: does something like the attached
work? (tested only to compile ;) Not necessarily the best place to put
this logic.
> The issue with this is that wildcard IP addresses aren't really supposed to
> be explicit in Listen statements. httpd has a bunch of logic for inferring
> the right IP wildcards - trying to out-guess can lead to real badness.
> Specifically, this mucks with APR's ability to set AI_PASSIVE - which is
> required for use with address that we will later call bind() on - i.e. our
> listeners. So, Listen with an IP address should only be used for real
> addresses.
The problem was that 2.0.x will only accept connections to IPv6
addresses with a single "Listen <port>"; but since LWP doesn't support
IPv6, that doesn't work for httpd-test. The alternative is to start
getting complicated but with the different logic in 2.0 and 2.1 I think
it would be better to avoid this.
joe
Re: Listen 0.0.0.0: is invalid
Posted by Joe Orton <jo...@redhat.com>.
On Tue, Feb 22, 2005 at 10:52:57PM -0800, Justin Erenkrantz wrote:
> No idea why I'm suddenly hitting this, but in preparation for 2.1.3, I
> spent another one of my patented hours searching for bugs in httpd that end
> up being bugs in the perl-framework tests. =(
>
> perl-framework generates Listen directives in the order of:
> 'Listen 0.0.0.0:8529'
>
> For me, this causes errors like:
> (48)Address already in use: make_sock: could not bind to address
> 0.0.0.0:8531
> no listening sockets available, shutting down
> Unable to open logs
>
> On Mac OS X 10.3.8 (7.8.0 via uname -r), getaddrinfo() without AI_PASSIVE
> can return duplicate IP addresses. This leads to the error condition that
> causes the failure. And, based on my reading of the docs, I'm not sure
> that's patently incorrect behavior on Darwin's part: that's 0.0.0.0 for
> both the localhost and the network card.
But there is no way to differentiate between any different interfaces
for the address (without doing magic), so I would say that is a resolver
misfeature.
"Listen 0.0.0.0:<port>" should always work because there's no other way
to configure httpd to bind only to "all IPv4 addresses on the local host
with port X" (right?), which is certainly a valid and useful thing to
do.
I think httpd should work around this: does something like the attached
work? (tested only to compile ;) Not necessarily the best place to put
this logic.
> The issue with this is that wildcard IP addresses aren't really supposed to
> be explicit in Listen statements. httpd has a bunch of logic for inferring
> the right IP wildcards - trying to out-guess can lead to real badness.
> Specifically, this mucks with APR's ability to set AI_PASSIVE - which is
> required for use with address that we will later call bind() on - i.e. our
> listeners. So, Listen with an IP address should only be used for real
> addresses.
The problem was that 2.0.x will only accept connections to IPv6
addresses with a single "Listen <port>"; but since LWP doesn't support
IPv6, that doesn't work for httpd-test. The alternative is to start
getting complicated but with the different logic in 2.0 and 2.1 I think
it would be better to avoid this.
joe