You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Mladen Turk <mt...@apache.org> on 2006/12/11 14:58:04 UTC

[WIN32] IPV4/IPV6 differences

Hi,

On WIN32, APR by default comes with IPV6 disabled.
Enabling IPV6 brings in the completely different
behavior for NULL Listen address.
While on unixes regardless of the address being
NULL or 0.0.0.0 the socket will always accept
the connection to 127.0.0.1.
On Windows, if IPV6 is enabled the connection to
127.0.0.1 will be enabled *only* if address is 0.0.0.0
In case it is NULL, it'll default to ::0 and all IPV4
connections will be rejected.

Now, this is completely platform dependent, and makes
the same config behaving differently depending on the OS.

I'm not sure what is the exact reason, but if I
make "0.0.0.0" default when address is NULL for IPV6
enabled Win32/Win64, then it behaves like it behaves
on *nixes.

Any comments?

Regards,
Mladen.




Re: [WIN32] IPV4/IPV6 differences

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Mladen Turk wrote:
> Colm MacCarthaigh wrote:
>>>>
>>> Are you sure?
>>> Pass the NULL on unix enabled IPV6 APR, it will accept the
>>> 127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.
>>
>> apr_sockaddr_t is a linked list, and you have to listen() on every
>> address in the list.
> 
> Look, I'm I speaking Marsian?
> Same API and params: unix-OK, windows-NO
> How can I simplify that more so you will understand the problem?

In a nutshell, loopback is a distinct socket driver, and  one of the
most notoriously buggy pieces of microsoft code.  What are you asking
a portability project to do about broken drivers?

If this were so horridly broken on Darwin or Linux or Solaris (heh - where
in fact it actually is broken ;-)  we push back on the OS vendor to fix
the damned thing.  Same goes for all of the garbage drivers on the windows
socket stack, written by hacks that don't code to the API while developing
their VPN/AntiVirus/AntiSpyware drivers.

We may or may not be doing the right thing in the win32 apr_socket_listen
code, compare to the unix implementation.

Re: [WIN32] IPV4/IPV6 differences

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Mon, Dec 11, 2006 at 05:00:27PM +0100, Mladen Turk wrote:
> Makes no sense to continue the discussion because you either
> have not tried to build the APR with IPV6 enabled on Windows,
> or you just do not understand what the cross-platform is.

Given I *wrote* much of that code, and made it work and tested it on
windows, and then wrote the code which uses in httpd and tested that on
windows too, I'm going to go way out on a limb and claim that you're
wrong ;-)

> Let's finish this discussion, because it leads to nowhere.

Excellent, bizarre API breakage should always go nowhere!

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Re: [WIN32] IPV4/IPV6 differences

Posted by Mladen Turk <mt...@apache.org>.
Colm MacCarthaigh wrote:
> On Mon, Dec 11, 2006 at 04:48:23PM +0100, Mladen Turk wrote:
>> Colm MacCarthaigh wrote:
>>>> Are you sure?
>>>> Pass the NULL on unix enabled IPV6 APR, it will accept the
>>>> 127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.
>>> apr_sockaddr_t is a linked list, and you have to listen() on every
>>> address in the list.
>>>
>> Look, I'm I speaking Marsian?
> 
> Yes.

It was meant to be: 'Am I speak Martian' :)

> 
>> Same API and params: unix-OK, windows-NO
>> How can I simplify that more so you will understand the problem?
> 
> Can you give some code? httpd manages this fine for every instance
> of a "Listen" directive, there are no windows hacks in that code.
> 

Makes no sense to continue the discussion because you either
have not tried to build the APR with IPV6 enabled on Windows,
or you just do not understand what the cross-platform is.

Let's finish this discussion, because it leads to nowhere.

Regards,
Mladen.

Re: [WIN32] IPV4/IPV6 differences

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Mon, Dec 11, 2006 at 04:48:23PM +0100, Mladen Turk wrote:
> Colm MacCarthaigh wrote:
> >>>
> >>Are you sure?
> >>Pass the NULL on unix enabled IPV6 APR, it will accept the
> >>127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.
> >
> >apr_sockaddr_t is a linked list, and you have to listen() on every
> >address in the list.
> >
> 
> Look, I'm I speaking Marsian?

Yes.

> Same API and params: unix-OK, windows-NO
> How can I simplify that more so you will understand the problem?

Can you give some code? httpd manages this fine for every instance
of a "Listen" directive, there are no windows hacks in that code.

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Re: [WIN32] IPV4/IPV6 differences

Posted by Mladen Turk <mt...@apache.org>.
Colm MacCarthaigh wrote:
>>>
>> Are you sure?
>> Pass the NULL on unix enabled IPV6 APR, it will accept the
>> 127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.
> 
> apr_sockaddr_t is a linked list, and you have to listen() on every
> address in the list.
>

Look, I'm I speaking Marsian?
Same API and params: unix-OK, windows-NO
How can I simplify that more so you will understand the problem?

Regards,
Mladen.


Re: [WIN32] IPV4/IPV6 differences

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Mon, Dec 11, 2006 at 04:30:43PM +0100, Mladen Turk wrote:
> Colm MacCarthaigh wrote:
> >
> >> So you are saying that the same API behaves differently
> >> depending on the OS beneath. Then what's the purpose of the APR?
> >
> > No, the API behaves no differently at all. The API deals with you
> > wanting to listen on the ANY just fine, on windows and so on it will
> > return :: and 0.0.0.0 and if you listen on both it will work.
> >
> 
> Are you sure?
> Pass the NULL on unix enabled IPV6 APR, it will accept the
> 127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.

apr_sockaddr_t is a linked list, and you have to listen() on every
address in the list.

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Re: [WIN32] IPV4/IPV6 differences

Posted by Mladen Turk <mt...@apache.org>.
Colm MacCarthaigh wrote:
 >
 >> So you are saying that the same API behaves differently
 >> depending on the OS beneath. Then what's the purpose of the APR?
 >
 > No, the API behaves no differently at all. The API deals with you
 > wanting to listen on the ANY just fine, on windows and so on it will
 > return :: and 0.0.0.0 and if you listen on both it will work.
 >

Are you sure?
Pass the NULL on unix enabled IPV6 APR, it will accept the
127.0.0.1. The IPV6 enabled Win32/Win64 will always reject this.

So, if you think this is something legitimate, IMHO
it should at least be documented, on better called platform
specific.

Regards,
Mladen.

Re: [WIN32] IPV4/IPV6 differences

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Mon, Dec 11, 2006 at 03:41:55PM +0100, Mladen Turk wrote:
> Colm MacCarthaigh wrote:
> >On Mon, Dec 11, 2006 at 02:58:04PM +0100, Mladen Turk wrote:
> >>On WIN32, APR by default comes with IPV6 disabled.
> >
> >I'm not sure what you mean by that. Do you mean the binary builds
> >particular developers make?
> 
> Yes and no. IPV6 on WIN32/WIN64 can be enabled only by
> manually editing the apr.hw. On nixes it's configure.in-ed.

I always thought those were comparable proccess :-)

> So you are saying that the same API behaves differently
> depending on the OS beneath. Then what's the purpose of the APR?

No, the API behaves no differently at all. The API deals with you
wanting to listen on the ANY just fine, on windows and so on it will
return :: and 0.0.0.0 and if you listen on both it will work. 

It returns a list of addresses to listen on, not just one :-)

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Re: [WIN32] IPV4/IPV6 differences

Posted by Mladen Turk <mt...@apache.org>.
Colm MacCarthaigh wrote:
> On Mon, Dec 11, 2006 at 02:58:04PM +0100, Mladen Turk wrote:
>> On WIN32, APR by default comes with IPV6 disabled.
> 
> I'm not sure what you mean by that. Do you mean the binary builds
> particular developers make?
>

Yes and no. IPV6 on WIN32/WIN64 can be enabled only by
manually editing the apr.hw. On nixes it's configure.in-ed.

>> Now, this is completely platform dependent, and makes
>> the same config behaving differently depending on the OS.
> 
> Many stacks exhibit this behaviour and do not support IPv4 mapped IPv6
> addresses.  OpenBSD does this by default, FreeBSD and Linux have it as
> system-configurable. Tru64 and MacOSX do slightly weirder things still.
> 
> In general, the application needs to be aware of this and decide to
> listen() on whatever it feels the need to listen() on. Not doing this is
> a bug.
>

So you are saying that the same API behaves differently
depending on the OS beneath. Then what's the purpose of the APR?

If one platform behaves completely different from the
other platform for the same API and params passed in, then
it cannot be called cross-platform at the first place.

Regards,
Mladen.

Re: [WIN32] IPV4/IPV6 differences

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Mon, Dec 11, 2006 at 02:58:04PM +0100, Mladen Turk wrote:
> On WIN32, APR by default comes with IPV6 disabled.

I'm not sure what you mean by that. Do you mean the binary builds
particular developers make?

> Now, this is completely platform dependent, and makes
> the same config behaving differently depending on the OS.

Many stacks exhibit this behaviour and do not support IPv4 mapped IPv6
addresses.  OpenBSD does this by default, FreeBSD and Linux have it as
system-configurable. Tru64 and MacOSX do slightly weirder things still.

In general, the application needs to be aware of this and decide to
listen() on whatever it feels the need to listen() on. Not doing this is
a bug.

> I'm not sure what is the exact reason, but if I
> make "0.0.0.0" default when address is NULL for IPV6
> enabled Win32/Win64, then it behaves like it behaves
> on *nixes.

That's over-simplifying things, and would break a lot of other
code.

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net