Joe Orton wrote:
> On Mon, Nov 27, 2006 at 12:13:06AM -0600, William Rowe wrote:
>> Joe Orton wrote:
>>> (The test_get_addr test was to check for a ->remote_addr_unknown
>>> handling bug alone, FWIW: PR 32737)
>> Right - and it erroneously invokes connect against 0.0.0.0 no matter which
>> way I patch this. We need to determine that connect-to 0.0.0.0 is portable
>> behavior and emulate, correct the patch to connect to a non-ephemeral addr,
>> or revert the test.
>
> I've changed it to use 127.0.0.1 on the trunk; does that help?
Yes - although it does complete synchronously - and I'd expect it to far more
often than before.
>> And we need to roll a tarball - this is getting silly. But I'm not rolling
>> with a borked test.
>
> The test has been in 1.2.x since September 2005 - did something change
> since then?
Good question. Perhaps it's the fact that MS has tossed in an update "fix"
rejecting connect-to 0.0.0.0 as a "security patch"? Nothing would surprise
me given MS's "understanding" of both transport or protocol layers anymore.
If our understanding is correct, isn't the following patch needed to address
the missing win32 and unix unknown_local_address for bind, and os2 missing
both this and unknown_local_port, and for win32/os2 set up the unknown_remote
initial value?
We would still need to decide how to let the resolver handle get_local_addr
when it remains unknown, of course. Right now, it round-trips back to the
0.0.0.0 ephemeral address.
Bill
Index: network_io/win32/sockets.c
===================================================================
--- network_io/win32/sockets.c (revision 479715)
+++ network_io/win32/sockets.c (working copy)
@@ -59,9 +59,11 @@
(*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool,
sizeof(apr_sockaddr_t));
(*new)->local_addr->pool = p;
+
(*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool,
sizeof(apr_sockaddr_t));
(*new)->remote_addr->pool = p;
+ (*new)->remote_addr_unknown = 1;
/* Create a pollset with room for one descriptor. */
/* ### check return codes */
@@ -202,6 +204,13 @@
if (sock->local_addr->sa.sin.sin_port == 0) {
sock->local_port_unknown = 1; /* ephemeral port */
}
+ if (!memcmp(sa->ipaddr_ptr, generic_inaddr_any, sa->ipaddr_len)) {
+ /*
+ * If the listening socket is not bound to a specific interface,
+ * we don't know the specific local_addr(s).
+ */
+ sock->local_interface_unknown = 1;
+ }
return APR_SUCCESS;
}
}
Index: network_io/os2/sockets.c
===================================================================
--- network_io/os2/sockets.c (revision 479715)
+++ network_io/os2/sockets.c (working copy)
@@ -62,9 +62,11 @@
(*new)->local_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool,
sizeof(apr_sockaddr_t));
(*new)->local_addr->pool = p;
+
(*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->pool,
sizeof(apr_sockaddr_t));
(*new)->remote_addr->pool = p;
+ (*new)->remote_addr_unknown = 1;
/* Create a pollset with room for one descriptor. */
/* ### check return codes */
@@ -140,6 +142,17 @@
return APR_OS2_STATUS(sock_errno());
else {
sock->local_addr = sa;
+ /* XXX IPv6 - this assumes sin_port and sin6_port at same offset */
+ if (sock->local_addr->sa.sin.sin_port == 0) { /* no need for ntohs() when comparing w/ 0 */
+ sock->local_port_unknown = 1; /* kernel got us an ephemeral port */
+ }
+ if (!memcmp(sa->ipaddr_ptr, generic_inaddr_any, sa->ipaddr_len)) {
+ /*
+ * If the listening socket is not bound to a specific interface,
+ * we don't know the specific local_addr(s).
+ */
+ sock->local_interface_unknown = 1;
+ }
return APR_SUCCESS;
}
}
Index: network_io/unix/sockets.c
===================================================================
--- network_io/unix/sockets.c (revision 479715)
+++ network_io/unix/sockets.c (working copy)
@@ -161,6 +161,13 @@
if (sock->local_addr->sa.sin.sin_port == 0) { /* no need for ntohs() when comparing w/ 0 */
sock->local_port_unknown = 1; /* kernel got us an ephemeral port */
}
+ if (!memcmp(sa->ipaddr_ptr, generic_inaddr_any, sa->ipaddr_len)) {
+ /*
+ * If the listening socket is not bound to a specific interface,
+ * we don't know the specific local_addr(s).
+ */
+ sock->local_interface_unknown = 1;
+ }
return APR_SUCCESS;
}
}