From 2b66a51a7d72e9cc07917fb583ad528b0539d2a3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 4 Jan 2006 04:15:55 +0000 Subject: [PATCH] 1950. [port] Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket. This prevents the source address being set for TCP connections. [RT #15628] --- CHANGES | 4 ++++ config.h.in | 5 ++++- configure | 19 ++++++++++++++++--- configure.in | 12 +++++++++++- doc/arm/Bv9ARM-book.xml | 20 +++++++++++++++++++- lib/dns/request.c | 4 +++- lib/dns/resolver.c | 4 +++- lib/dns/xfrin.c | 4 +++- 8 files changed, 63 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 7ea44525f7..b44ecce4ce 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1950. [port] Solaris 2.5.1 and earlier cannot bind() then connect() + a TCP socket. This prevents the source address being + set for TCP connections. [RT #15628] + 1949. [func] Addition memory leakage checks. [RT #15544] 1948. [bug] If was possible to trigger a REQUIRE failure in diff --git a/config.h.in b/config.h.in index a2b05ddf08..45444d9b1d 100644 --- a/config.h.in +++ b/config.h.in @@ -16,7 +16,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.h.in,v 1.75 2005/10/20 23:50:53 marka Exp $ */ +/* $Id: config.h.in,v 1.77 2006/01/05 00:30:34 marka Exp $ */ /*! \file */ @@ -150,6 +150,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define if threads need PTHREAD_SCOPE_SYSTEM */ #undef NEED_PTHREAD_SCOPE_SYSTEM +/* Define if you cannot bind() before connect() for TCP sockets. */ +#undef BROKEN_TCP_BIND_BEFORE_CONNECT + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H diff --git a/configure b/configure index 898af1d0f5..2d8224af9a 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") # Copyright (C) 1996-2003 Internet Software Consortium. # # Permission to use, copy, modify, and distribute this software for any @@ -14,7 +14,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # -# $Id: configure,v 1.385 2005/10/20 23:50:53 marka Exp $ +# $Id: configure,v 1.386 2006/01/04 04:15:55 marka Exp $ # # Portions Copyright (C) 1996-2001 Nominum, Inc. # @@ -29,7 +29,7 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# From configure.in Revision: 1.396 . +# From configure.in Revision: 1.397 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -27822,6 +27822,19 @@ _ACEOF ;; esac # +# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket. +# This prevents the source address being set. +# +case "$host" in +*-solaris2.[012345]|*-solaris2.5.1) + +cat >>confdefs.h <<\_ACEOF +#define BROKEN_TCP_BIND_BEFORE_CONNECT 1 +_ACEOF + + ;; +esac +# # The following sections deal with tools used for formatting # the documentation. They are all optional, unless you are # a developer editing the documentation source. diff --git a/configure.in b/configure.in index 0c66e29666..eef4800adf 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.396 $) +AC_REVISION($Revision: 1.397 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.59) @@ -2020,6 +2020,16 @@ case "$host" in ;; esac # +# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket. +# This prevents the source address being set. +# +case "$host" in +*-solaris2.[[012345]]|*-solaris2.5.1) + AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1, + [Define if you cannot bind() before connect() for TCP sockets.]) + ;; +esac +# # The following sections deal with tools used for formatting # the documentation. They are all optional, unless you are # a developer editing the documentation source. diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index 3d249e7822..423ae7bfed 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -18,7 +18,7 @@ - PERFORMANCE OF THIS SOFTWARE. --> - + BIND 9 Administrator Reference Manual @@ -5977,6 +5977,12 @@ query-source-v6 address * port *; unprivileged port. + + + Solaris 2.5.1 and earlier does not support setting the source + address for TCP sockets. + + See also transfer-source and @@ -6202,6 +6208,12 @@ query-source-v6 address * port *; zone block in the configuration file. + + + Solaris 2.5.1 and earlier does not support setting the + source address for TCP sockets. + + @@ -6277,6 +6289,12 @@ query-source-v6 address * port *; view block in the configuration file. + + + Solaris 2.5.1 and earlier does not support setting the + source address for TCP sockets. + + diff --git a/lib/dns/request.c b/lib/dns/request.c index a5493e9fc1..b3c645625e 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: request.c,v 1.74 2005/04/29 00:22:51 marka Exp $ */ +/* $Id: request.c,v 1.75 2006/01/04 04:14:39 marka Exp $ */ /*! \file */ @@ -514,6 +514,7 @@ create_tcp_dispatch(dns_requestmgr_t *requestmgr, isc_sockaddr_t *srcaddr, isc_sockettype_tcp, &socket); if (result != ISC_R_SUCCESS) return (result); +#ifndef BROKEN_TCP_BIND_BEFORE_CONNECT if (srcaddr == NULL) { isc_sockaddr_anyofpf(&bind_any, isc_sockaddr_pf(destaddr)); @@ -525,6 +526,7 @@ create_tcp_dispatch(dns_requestmgr_t *requestmgr, isc_sockaddr_t *srcaddr, } if (result != ISC_R_SUCCESS) goto cleanup; +#endif attrs = 0; attrs |= DNS_DISPATCHATTR_TCP; attrs |= DNS_DISPATCHATTR_PRIVATE; diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index a2769ce8be..dbba5abdbf 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.323 2006/01/04 00:37:24 marka Exp $ */ +/* $Id: resolver.c,v 1.324 2006/01/04 04:14:39 marka Exp $ */ /*! \file */ @@ -1070,9 +1070,11 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, if (result != ISC_R_SUCCESS) goto cleanup_query; +#ifndef BROKEN_TCP_BIND_BEFORE_CONNECT result = isc_socket_bind(query->tcpsocket, &addr); if (result != ISC_R_SUCCESS) goto cleanup_socket; +#endif /* * A dispatch will be created once the connect succeeds. diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 806d6d11c3..fb3eced043 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrin.c,v 1.143 2006/01/04 03:03:11 marka Exp $ */ +/* $Id: xfrin.c,v 1.144 2006/01/04 04:14:39 marka Exp $ */ /*! \file */ @@ -821,7 +821,9 @@ xfrin_start(dns_xfrin_ctx_t *xfr) { isc_sockaddr_pf(&xfr->sourceaddr), isc_sockettype_tcp, &xfr->socket)); +#ifndef BROKEN_TCP_BIND_BEFORE_CONNECT CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr)); +#endif CHECK(isc_socket_connect(xfr->socket, &xfr->masteraddr, xfr->task, xfrin_connect_done, xfr)); xfr->connects++;