diff --git a/CHANGES b/CHANGES index 461fbed6a1..530f574a72 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +1203. [func] Use "dataready" accept filter if available. + 1302. [port] libbind: hpux 11.11 interface scaning. 1301. [func] Log zone when unable to get private keys to update diff --git a/bin/named/interfacemgr.c b/bin/named/interfacemgr.c index de78eb03da..16702e4254 100644 --- a/bin/named/interfacemgr.c +++ b/bin/named/interfacemgr.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfacemgr.c,v 1.66 2001/11/29 13:14:32 marka Exp $ */ +/* $Id: interfacemgr.c,v 1.67 2002/05/27 00:40:16 marka Exp $ */ #include @@ -312,6 +312,12 @@ ns_interface_accepttcp(ns_interface_t *ifp) { goto tcp_listen_failure; } + /* + * If/when there a multiple filters listen to the + * result. + */ + (void)isc_socket_filter(ifp->tcpsocket, "dataready"); + result = ns_clientmgr_createclients(ifp->clientmgr, ifp->ntcptarget, ifp, ISC_TRUE); diff --git a/lib/isc/include/isc/msgs.h b/lib/isc/include/isc/msgs.h index 0714e47cfa..b166199e8f 100644 --- a/lib/isc/include/isc/msgs.h +++ b/lib/isc/include/isc/msgs.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: msgs.h,v 1.6 2002/04/02 04:36:48 marka Exp $ */ +/* $Id: msgs.h,v 1.7 2002/05/27 00:40:18 marka Exp $ */ #ifndef ISC_MSGS_H #define ISC_MSGS_H 1 @@ -145,6 +145,7 @@ #define ISC_MSG_ACCEPTRETURNED 1418 /* accept() returned %d/%s */ #define ISC_MSG_TOOMANYFDS 1419 /* %s: too many open file descriptors */ #define ISC_MSG_ZEROPORT 1420 /* dropping source port zero packet */ +#define ISC_MSG_FILTER 1420 /* setsockopt(SO_ACCEPTFILTER): %s */ #define ISC_MSG_AWAKE 1502 /* "awake" */ #define ISC_MSG_WORKING 1503 /* "working" */ diff --git a/lib/isc/include/isc/socket.h b/lib/isc/include/isc/socket.h index a2dd8ffb07..e29af04d17 100644 --- a/lib/isc/include/isc/socket.h +++ b/lib/isc/include/isc/socket.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.h,v 1.55 2001/11/29 07:31:25 marka Exp $ */ +/* $Id: socket.h,v 1.56 2002/05/27 00:40:19 marka Exp $ */ #ifndef ISC_SOCKET_H #define ISC_SOCKET_H 1 @@ -326,6 +326,13 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *addressp); * ISC_R_UNEXPECTED */ +isc_result_t +isc_socket_filter(isc_socket_t *sock, const char *filter); +/* + * Inform the kernel that it should perform accept filtering. + * If filter is NULL the current filter will be removed.:w + */ + isc_result_t isc_socket_listen(isc_socket_t *sock, unsigned int backlog); /* diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 86a299d1ac..042688f34a 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.225 2002/04/03 06:44:11 marka Exp $ */ +/* $Id: socket.c,v 1.226 2002/05/27 00:40:22 marka Exp $ */ #include @@ -2803,6 +2803,35 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { return (ISC_R_SUCCESS); } +isc_result_t +isc_socket_filter(isc_socket_t *sock, const char *filter) { +#ifdef SO_ACCEPTFILTER + char strbuf[ISC_STRERRORSIZE]; + struct accept_filter_arg afa; +#else + UNUSED(sock); + UNUSED(filter); +#endif + + REQUIRE(VALID_SOCKET(sock)); + +#ifdef SO_ACCEPTFILTER + bzero(&afa, sizeof(afa)); + strncpy(afa.af_name, filter, sizeof(afa.af_name)); + if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER, + &afa, sizeof(afa)) == -1) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + socket_log(sock, NULL, CREATION, isc_msgcat, ISC_MSGSET_SOCKET, + ISC_MSG_FILTER, "setsockopt(SO_ACCEPTFILTER): %s", + strbuf); + return (ISC_R_FAILURE); + } + return (ISC_R_SUCCESS); +#else + return (ISC_R_NOTIMPLEMENTED); +#endif +} + /* * Set up to listen on a given socket. We do this by creating an internal * event that will be dispatched when the socket has read activity. The diff --git a/lib/isc/win32/socket.c b/lib/isc/win32/socket.c index 1cf9bc8660..c68c7bb9b0 100644 --- a/lib/isc/win32/socket.c +++ b/lib/isc/win32/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.17 2002/04/02 04:36:52 marka Exp $ */ +/* $Id: socket.c,v 1.18 2002/05/27 00:40:23 marka Exp $ */ #define MAKE_EXTERNAL 1 #include @@ -2899,6 +2899,15 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { return (ISC_R_SUCCESS); } +isc_result_t +isc_socket_filter(isc_socket_t *sock, const char *filter) { + UNUSED(sock); + UNUSED(filter); + + REQUIRE(VALID_SOCKET(sock)); + return (ISC_R_NOTIMPLEMENTED); +} + /* * Set up to listen on a given socket. We do this by creating an internal * event that will be dispatched when the socket has read activity. The