apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sob <...@hisoftware.cz>
Subject Patch for IPv6 on Windows before Vista
Date Fri, 20 Jun 2008 01:56:44 GMT

while experimenting with httpd and IPv6 on WinXP, I found out that 
it's not working well.
In short, the code expects that IPv4 mapped addresses and IPV6_V6ONLY 
socket option are supported. This is not true for NTs < 6.0. They 
have IPv4 and IPv6 as two separate stacks and therefore all IPv6 
sockets always behave as V6ONLY and no IPv4 mapped addresses are 
possible. Unfortunately the IPV6_V6ONLY option is not understood, so 
if the code tries to set it, if fails with OS error. APR seems to be 
the best place where it can be fixed.

The attached patch modifies apr_socket_opt_set(). When the requested 
option is APR_IPV6_V6ONLY, it checks Windows version and if it's less 
than Vista, it does not call setsockopt(), but instead it calls 
directly apr_set_option() and pretends that the option was set. Then 
it returns APR_SUCCESS or APR_ENOTIMPL depending on if it was 
requested to set or unset the option.
I'm not exactly sure about returning APR_ENOTIMPL, but httpd would 
fail with anything else. At first I just set "on = 1;" and let the 
original apr_set_option() use it, but that wasn't right, because it 
always returned APR_SUCCESS and some application other than httpd can 
depend on the result and in case it requested to unset the option, 
returning APR_SUCCESS would be wrong. Httpd doesn't really care about 
the result and checks the state later using apr_socket_opt_get(). 
That's why always calling apr_set_option(sock, APR_IPV6_V6ONLY, 1) is 
important. If omited, it would be possible (if compiled with IPv4 
mapped addresses support) for apr_socket_opt_get() to return 0 (= 
socket can accept both IPv4 and 6), but that's not possible on these 
older Windows and if some code is depending on it, it may fail (like 
current httpd).

View raw message