diff options
Diffstat (limited to 'lib/isc/unix')
-rw-r--r-- | lib/isc/unix/app.c | 22 | ||||
-rw-r--r-- | lib/isc/unix/file.c | 16 | ||||
-rw-r--r-- | lib/isc/unix/ifiter_ioctl.c | 4 | ||||
-rw-r--r-- | lib/isc/unix/ifiter_sysctl.c | 4 | ||||
-rw-r--r-- | lib/isc/unix/net.c | 33 | ||||
-rw-r--r-- | lib/isc/unix/socket.c | 30 |
6 files changed, 75 insertions, 34 deletions
diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c index aeebc31f9a43..141e9c21a94c 100644 --- a/lib/isc/unix/app.c +++ b/lib/isc/unix/app.c @@ -90,6 +90,7 @@ ISC_APPFUNC_SCOPE isc_result_t isc__app_onrun(isc_mem_t *mctx, void *arg); ISC_APPFUNC_SCOPE isc_result_t isc__app_ctxrun(isc_appctx_t *ctx); ISC_APPFUNC_SCOPE isc_result_t isc__app_run(void); +ISC_APPFUNC_SCOPE isc_boolean_t isc__app_isrunning(void); ISC_APPFUNC_SCOPE isc_result_t isc__app_ctxshutdown(isc_appctx_t *ctx); ISC_APPFUNC_SCOPE isc_result_t isc__app_shutdown(void); ISC_APPFUNC_SCOPE isc_result_t isc__app_reload(void); @@ -145,6 +146,7 @@ typedef struct isc__appctx { } isc__appctx_t; static isc__appctx_t isc_g_appctx; +static isc_boolean_t is_running = ISC_FALSE; static struct { isc_appmethods_t methods; @@ -154,7 +156,8 @@ static struct { */ #ifndef BIND9 void *run, *shutdown, *start, *onrun, - *reload, *finish, *block, *unblock; + *reload, *finish, *block, *unblock, + *isrunning; #endif } appmethods = { { @@ -174,7 +177,7 @@ static struct { (void *)isc__app_run, (void *)isc__app_shutdown, (void *)isc__app_start, (void *)isc__app_onrun, (void *)isc__app_reload, (void *)isc__app_finish, (void *)isc__app_block, - (void *)isc__app_unblock + (void *)isc__app_unblock, (void *)isc__app_isrunning #endif }; @@ -701,7 +704,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) { return (ISC_R_UNEXPECTED); } #endif - result = sigsuspend(&sset); + (void)sigsuspend(&sset); #endif /* HAVE_SIGWAIT */ if (ctx->want_reload) { @@ -728,7 +731,18 @@ isc__app_ctxrun(isc_appctx_t *ctx0) { ISC_APPFUNC_SCOPE isc_result_t isc__app_run(void) { - return (isc__app_ctxrun((isc_appctx_t *)&isc_g_appctx)); + isc_result_t result; + + is_running = ISC_TRUE; + result = isc__app_ctxrun((isc_appctx_t *)&isc_g_appctx); + is_running = ISC_FALSE; + + return (result); +} + +ISC_APPFUNC_SCOPE isc_boolean_t +isc__app_isrunning(void) { + return (is_running); } ISC_APPFUNC_SCOPE isc_result_t diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index 1b7d563d875a..c2abd440e18c 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2009, 2011-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2009, 2011-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -135,12 +135,12 @@ isc_file_mode(const char *file, mode_t *modep) { } isc_result_t -isc_file_getmodtime(const char *file, isc_time_t *time) { +isc_file_getmodtime(const char *file, isc_time_t *modtime) { isc_result_t result; struct stat stats; REQUIRE(file != NULL); - REQUIRE(time != NULL); + REQUIRE(modtime != NULL); result = file_stats(file, &stats); @@ -149,16 +149,16 @@ isc_file_getmodtime(const char *file, isc_time_t *time) { * XXXDCL some operating systems provide nanoseconds, too, * such as BSD/OS via st_mtimespec. */ - isc_time_set(time, stats.st_mtime, 0); + isc_time_set(modtime, stats.st_mtime, 0); return (result); } isc_result_t -isc_file_settime(const char *file, isc_time_t *time) { +isc_file_settime(const char *file, isc_time_t *when) { struct timeval times[2]; - REQUIRE(file != NULL && time != NULL); + REQUIRE(file != NULL && when != NULL); /* * tv_sec is at least a 32 bit quantity on all platforms we're @@ -170,7 +170,7 @@ isc_file_settime(const char *file, isc_time_t *time) { * * isc_time_seconds is changed to be > 32 bits but long is 32 bits * and isc_time_seconds has at least 33 significant bits. */ - times[0].tv_sec = times[1].tv_sec = (long)isc_time_seconds(time); + times[0].tv_sec = times[1].tv_sec = (long)isc_time_seconds(when); /* * Here is the real check for the high bit being set. @@ -186,7 +186,7 @@ isc_file_settime(const char *file, isc_time_t *time) { * we can at least cast to signed so the IRIX compiler shuts up. */ times[0].tv_usec = times[1].tv_usec = - (isc_int32_t)(isc_time_nanoseconds(time) / 1000); + (isc_int32_t)(isc_time_nanoseconds(when) / 1000); if (utimes(file, times) < 0) return (isc__errno2result(errno)); diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index f0026c285b80..6b1ceda09e0a 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2009, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -17,6 +17,8 @@ /* $Id: ifiter_ioctl.c,v 1.62 2009/01/18 23:48:14 tbox Exp $ */ +#include <isc/print.h> + /*! \file * \brief * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl. diff --git a/lib/isc/unix/ifiter_sysctl.c b/lib/isc/unix/ifiter_sysctl.c index 102ecc1fee28..e4ca48a9aa4e 100644 --- a/lib/isc/unix/ifiter_sysctl.c +++ b/lib/isc/unix/ifiter_sysctl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -30,6 +30,8 @@ #include <net/route.h> #include <net/if_dl.h> +#include <isc/print.h> + /* XXX what about Alpha? */ #ifdef sgi #define ROUNDUP(a) ((a) > 0 ? \ diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index e4de0489ec11..c811d1ba4194 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008, 2012, 2014, 2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -414,12 +414,12 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high) { sysctlname_lowport = SYSCTL_V6PORTRANGE_LOW; sysctlname_hiport = SYSCTL_V6PORTRANGE_HIGH; } - portlen = sizeof(portlen); + portlen = sizeof(port_low); if (sysctlbyname(sysctlname_lowport, &port_low, &portlen, NULL, 0) < 0) { return (ISC_R_FAILURE); } - portlen = sizeof(portlen); + portlen = sizeof(port_high); if (sysctlbyname(sysctlname_hiport, &port_high, &portlen, NULL, 0) < 0) { return (ISC_R_FAILURE); @@ -453,12 +453,12 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high) { miblen = sizeof(mib_lo6) / sizeof(mib_lo6[0]); } - portlen = sizeof(portlen); + portlen = sizeof(port_low); if (sysctl(mib_lo, miblen, &port_low, &portlen, NULL, 0) < 0) { return (ISC_R_FAILURE); } - portlen = sizeof(portlen); + portlen = sizeof(port_high); if (sysctl(mib_hi, miblen, &port_high, &portlen, NULL, 0) < 0) { return (ISC_R_FAILURE); } @@ -477,11 +477,34 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high) { isc_result_t isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high) { int result = ISC_R_FAILURE; +#if !defined(USE_SYSCTL_PORTRANGE) && defined(__linux) + FILE *fp; +#endif REQUIRE(low != NULL && high != NULL); #if defined(USE_SYSCTL_PORTRANGE) result = getudpportrange_sysctl(af, low, high); +#elif defined(__linux) + + UNUSED(af); + + /* + * Linux local ports are address family agnostic. + */ + fp = fopen("/proc/sys/net/ipv4/ip_local_port_range", "r"); + if (fp != NULL) { + int n; + unsigned int l, h; + + n = fscanf(fp, "%u %u", &l, &h); + if (n == 2 && (l & ~0xffff) == 0 && (h & ~0xffff) == 0) { + *low = l; + *high = h; + result = ISC_R_SUCCESS; + } + fclose(fp); + } #else UNUSED(af); #endif diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 110eafe50fd1..5e6320d821c6 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2014 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2015 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -5957,33 +5957,33 @@ isc__socketmgr_dispatch(isc_socketmgr_t *manager0, isc_socketwait_t *swait) { #ifdef BIND9 void isc__socket_setname(isc_socket_t *socket0, const char *name, void *tag) { - isc__socket_t *socket = (isc__socket_t *)socket0; + isc__socket_t *sock = (isc__socket_t *)socket0; /* - * Name 'socket'. + * Name 'sock'. */ - REQUIRE(VALID_SOCKET(socket)); + REQUIRE(VALID_SOCKET(sock)); - LOCK(&socket->lock); - memset(socket->name, 0, sizeof(socket->name)); - strncpy(socket->name, name, sizeof(socket->name) - 1); - socket->tag = tag; - UNLOCK(&socket->lock); + LOCK(&sock->lock); + memset(sock->name, 0, sizeof(sock->name)); + strncpy(sock->name, name, sizeof(sock->name) - 1); + sock->tag = tag; + UNLOCK(&sock->lock); } ISC_SOCKETFUNC_SCOPE const char * isc__socket_getname(isc_socket_t *socket0) { - isc__socket_t *socket = (isc__socket_t *)socket0; + isc__socket_t *sock = (isc__socket_t *)socket0; - return (socket->name); + return (sock->name); } void * isc__socket_gettag(isc_socket_t *socket0) { - isc__socket_t *socket = (isc__socket_t *)socket0; + isc__socket_t *sock = (isc__socket_t *)socket0; - return (socket->tag); + return (sock->tag); } #endif /* BIND9 */ @@ -5996,9 +5996,9 @@ isc__socket_register(void) { ISC_SOCKETFUNC_SCOPE int isc__socket_getfd(isc_socket_t *socket0) { - isc__socket_t *socket = (isc__socket_t *)socket0; + isc__socket_t *sock = (isc__socket_t *)socket0; - return ((short) socket->fd); + return ((short) sock->fd); } #if defined(HAVE_LIBXML2) && defined(BIND9) |