2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

3225. [bug] Silence spurious "setsockopt(517, IPV6_V6ONLY) failed"

messages. [RT #26507]
This commit is contained in:
Mark Andrews
2011-11-29 01:03:47 +00:00
parent 9bd876a683
commit 23daf8948b
5 changed files with 58 additions and 49 deletions

View File

@@ -1,3 +1,6 @@
3225. [bug] Silence spurious "setsockopt(517, IPV6_V6ONLY) failed"
messages. [RT #26507]
3224. [bug] 'rndc signing' argument parsing was broken. [RT #26684]
3223. [bug] 'task_test privilege_drop' generated false positives.

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dispatch.c,v 1.174 2011/07/28 23:47:58 tbox Exp $ */
/* $Id: dispatch.c,v 1.175 2011/11/29 01:03:47 marka Exp $ */
/*! \file */
@@ -1810,6 +1810,10 @@ open_socket(isc_socketmgr_t *mgr, isc_sockaddr_t *local,
result = isc_socket_dup(dup_socket, &sock);
if (result != ISC_R_SUCCESS)
return (result);
isc_socket_setname(sock, "dispatcher", NULL);
*sockp = sock;
return (ISC_R_SUCCESS);
} else {
result = isc_socket_create(mgr, isc_sockaddr_pf(local),
isc_sockettype_udp, &sock);

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket_test.c,v 1.4 2011/09/02 21:15:38 each Exp $ */
/* $Id: socket_test.c,v 1.5 2011/11/29 01:03:47 marka Exp $ */
/*! \file */
@@ -181,12 +181,10 @@ ATF_TC_BODY(udp_dup, tc) {
result = isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, &s2);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_socket_dup(s2, &s3);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_socket_bind(s2, &addr2, ISC_SOCKET_REUSEADDRESS);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_socket_bind(s3, &addr2, ISC_SOCKET_REUSEADDRESS);
result = isc_socket_dup(s2, &s3);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
result = isc_task_create(taskmgr, 0, &task);
@@ -245,7 +243,6 @@ ATF_TC_BODY(udp_dup, tc) {
isc_test_end();
}
/*
* Main
*/

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.348 2011/08/25 11:37:13 marka Exp $ */
/* $Id: socket.c,v 1.349 2011/11/29 01:03:47 marka Exp $ */
/*! \file */
@@ -2270,6 +2270,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
} else {
sock->fd = dup(dup_socket->fd);
sock->dupped = 1;
sock->bound = dup_socket->bound;
}
if (sock->fd == -1 && errno == EINTR && tries++ < 42)
goto again;
@@ -5028,54 +5029,55 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr,
LOCK(&sock->lock);
INSIST(!sock->bound);
INSIST(!sock->dupped);
if (sock->pf != sockaddr->type.sa.sa_family) {
UNLOCK(&sock->lock);
return (ISC_R_FAMILYMISMATCH);
}
if (!sock->dupped) {
/*
* Only set SO_REUSEADDR when we want a specific port.
*/
#ifdef AF_UNIX
if (sock->pf == AF_UNIX)
goto bind_socket;
#endif
if ((options & ISC_SOCKET_REUSEADDRESS) != 0 &&
isc_sockaddr_getport(sockaddr) != (in_port_t)0 &&
setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
sizeof(on)) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d) %s", sock->fd,
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"));
/* Press on... */
}
#ifdef AF_UNIX
bind_socket:
#endif
if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) {
inc_stats(sock->manager->stats,
sock->statsindex[STATID_BINDFAIL]);
UNLOCK(&sock->lock);
switch (errno) {
case EACCES:
return (ISC_R_NOPERM);
case EADDRNOTAVAIL:
return (ISC_R_ADDRNOTAVAIL);
case EADDRINUSE:
return (ISC_R_ADDRINUSE);
case EINVAL:
return (ISC_R_BOUND);
default:
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
strbuf);
return (ISC_R_UNEXPECTED);
}
/*
* Only set SO_REUSEADDR when we want a specific port.
*/
#ifdef AF_UNIX
if (sock->pf == AF_UNIX)
goto bind_socket;
#endif
if ((options & ISC_SOCKET_REUSEADDRESS) != 0 &&
isc_sockaddr_getport(sockaddr) != (in_port_t)0 &&
setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
sizeof(on)) < 0) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"setsockopt(%d) %s", sock->fd,
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
ISC_MSG_FAILED, "failed"));
/* Press on... */
}
#ifdef AF_UNIX
bind_socket:
#endif
if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) {
inc_stats(sock->manager->stats,
sock->statsindex[STATID_BINDFAIL]);
UNLOCK(&sock->lock);
switch (errno) {
case EACCES:
return (ISC_R_NOPERM);
case EADDRNOTAVAIL:
return (ISC_R_ADDRNOTAVAIL);
case EADDRINUSE:
return (ISC_R_ADDRINUSE);
case EINVAL:
return (ISC_R_BOUND);
default:
isc__strerror(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s",
strbuf);
return (ISC_R_UNEXPECTED);
}
}
socket_log(sock, sockaddr, TRACE,
isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_BOUND, "bound");
sock->bound = 1;
@@ -5718,6 +5720,7 @@ isc__socket_ipv6only(isc_socket_t *sock0, isc_boolean_t yes) {
#endif
REQUIRE(VALID_SOCKET(sock));
INSIST(!sock->dupped);
#ifdef IPV6_V6ONLY
if (sock->pf == AF_INET6) {

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.92 2011/08/23 18:24:33 each Exp $ */
/* $Id: socket.c,v 1.93 2011/11/29 01:03:47 marka Exp $ */
/* This code uses functions which are only available on Server 2003 and
* higher, and Windows XP and higher.
@@ -1688,6 +1688,7 @@ socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
*/
sock->fd = _dup(dup_socket->fd);
sock->dupped = 1;
sock->bound = dup_socket->bound;
}
if (sock->fd == INVALID_SOCKET) {
@@ -3175,6 +3176,7 @@ isc__socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr,
}
INSIST(!sock->bound);
INSIST(!sock->dupped);
if (sock->pf != sockaddr->type.sa.sa_family) {
UNLOCK(&sock->lock);