diff options
| author | Doug Barton <dougb@FreeBSD.org> | 2011-08-02 07:40:29 +0000 |
|---|---|---|
| committer | Doug Barton <dougb@FreeBSD.org> | 2011-08-02 07:40:29 +0000 |
| commit | 92ca6d96a96522bb1e8e222f02352a8b98d9203b (patch) | |
| tree | bcab1b6e0db4d240584439eef7fd10b076cded30 /lib/isc | |
| parent | d2b93373b258059aa9768088e51b34573accbb40 (diff) | |
Diffstat (limited to 'lib/isc')
| -rw-r--r-- | lib/isc/api | 4 | ||||
| -rw-r--r-- | lib/isc/include/isc/file.h | 25 | ||||
| -rw-r--r-- | lib/isc/powerpc/include/isc/atomic.h | 36 | ||||
| -rw-r--r-- | lib/isc/unix/file.c | 21 | ||||
| -rw-r--r-- | lib/isc/unix/socket.c | 59 | ||||
| -rw-r--r-- | lib/isc/unix/stdio.c | 7 |
6 files changed, 119 insertions, 33 deletions
diff --git a/lib/isc/api b/lib/isc/api index 2caba4267223..83a084dba820 100644 --- a/lib/isc/api +++ b/lib/isc/api @@ -1,3 +1,3 @@ -LIBINTERFACE = 37 +LIBINTERFACE = 38 LIBREVISION = 1 -LIBAGE = 1 +LIBAGE = 2 diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index 2bb59027dc73..1ad98b3aec7a 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: file.h,v 1.27.18.4 2009-01-19 23:46:16 tbox Exp $ */ +/* $Id: file.h,v 1.27.18.6 2011-03-05 23:47:52 tbox Exp $ */ #ifndef ISC_FILE_H #define ISC_FILE_H 1 @@ -181,6 +181,27 @@ isc_file_isabsolute(const char *filename); * \brief Return #ISC_TRUE if the given file name is absolute. */ +isc_result_t +isc_file_isplainfile(const char *name); +/*!< + * \brief Check that the file is a plain file + * + * Returns: + *\li #ISC_R_SUCCESS + * Success. The file is a plain file. + *\li #ISC_R_INVALIDFILE + * The path specified was not usable by the operating system. + *\li #ISC_R_FILENOTFOUND + * The file does not exist. This return code comes from + * errno=ENOENT when stat returns -1. This code is mentioned + * here, because in logconf.c, it is the one rcode that is + * permitted in addition to ISC_R_SUCCESS. This is done since + * the next call in logconf.c is to isc_stdio_open(), which + * will create the file if it can. + *\li #other ISC_R_* errors translated from errno + * These occur when stat returns -1 and an errno. + */ + isc_boolean_t isc_file_iscurrentdir(const char *filename); /*!< diff --git a/lib/isc/powerpc/include/isc/atomic.h b/lib/isc/powerpc/include/isc/atomic.h index 067e81c2b134..158b46e25475 100644 --- a/lib/isc/powerpc/include/isc/atomic.h +++ b/lib/isc/powerpc/include/isc/atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2005, 2007, 2011 Internet Systems Consortium, Inc. ("ISC") * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: atomic.h,v 1.1.6.6 2007-08-28 07:20:06 tbox Exp $ */ +/* $Id: atomic.h,v 1.1.6.9 2011-03-08 00:49:33 marka Exp $ */ #ifndef ISC_ATOMIC_H #define ISC_ATOMIC_H 1 @@ -55,16 +55,16 @@ static inline int static int #endif isc_atomic_cmpxchg(atomic_p p, int old, int new) { - int orig = old; + int orig = old; #ifdef __GNUC__ - asm("ics"); + asm("ics"); #else - __isync(); + __isync(); #endif - if (compare_and_swap(p, &orig, new)) + if (compare_and_swap(p, &orig, new)) return (old); - return (orig); + return (orig); } #elif defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM) @@ -76,17 +76,19 @@ isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { #ifdef ISC_PLATFORM_USEMACASM "1:" "lwarx r6, 0, %1\n" - "mr %0, r6\n" + "mr %0, r6\n" "add r6, r6, %2\n" "stwcx. r6, 0, %1\n" - "bne- 1b" + "bne- 1b\n" + "sync" #else "1:" "lwarx 6, 0, %1\n" - "mr %0, 6\n" + "mr %0, 6\n" "add 6, 6, %2\n" "stwcx. 6, 0, %1\n" - "bne- 1b" + "bne- 1b\n" + "sync" #endif : "=&r"(orig) : "r"(p), "r"(val) @@ -104,13 +106,15 @@ isc_atomic_store(void *p, isc_int32_t val) { "lwarx r6, 0, %0\n" "lwz r6, %1\n" "stwcx. r6, 0, %0\n" - "bne- 1b" + "bne- 1b\n" + "sync" #else "1:" "lwarx 6, 0, %0\n" "lwz 6, %1\n" "stwcx. 6, 0, %0\n" - "bne- 1b" + "bne- 1b\n" + "sync" #endif : : "r"(p), "m"(val) @@ -132,7 +136,8 @@ isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { "mr r6, %3\n" "stwcx. r6, 0, %1\n" "bne- 1b\n" - "2:" + "2:\n" + "sync" #else "1:" "lwarx 6, 0, %1\n" @@ -142,7 +147,8 @@ isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { "mr 6, %3\n" "stwcx. 6, 0, %1\n" "bne- 1b\n" - "2:" + "2:\n" + "sync" #endif : "=&r" (orig) : "r"(p), "r"(cmpval), "r"(val) diff --git a/lib/isc/unix/file.c b/lib/isc/unix/file.c index eac60361851f..8f55c6095805 100644 --- a/lib/isc/unix/file.c +++ b/lib/isc/unix/file.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2009, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -48,7 +48,7 @@ * SUCH DAMAGE. */ -/* $Id: file.c,v 1.47.18.4 2009-02-16 23:46:03 tbox Exp $ */ +/* $Id: file.c,v 1.47.18.6 2011-03-05 23:47:52 tbox Exp $ */ /*! \file */ @@ -338,6 +338,23 @@ isc_file_exists(const char *pathname) { return (ISC_TF(file_stats(pathname, &stats) == ISC_R_SUCCESS)); } +isc_result_t +isc_file_isplainfile(const char *filename) { + /* + * This function returns success if filename is a plain file. + */ + struct stat filestat; + memset(&filestat,0,sizeof(struct stat)); + + if ((stat(filename, &filestat)) == -1) + return(isc__errno2result(errno)); + + if(! S_ISREG(filestat.st_mode)) + return(ISC_R_INVALIDFILE); + + return(ISC_R_SUCCESS); +} + isc_boolean_t isc_file_isabsolute(const char *filename) { REQUIRE(filename != NULL); diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 6d1027920859..3e1c1c18e90c 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.237.18.68 2009-09-07 02:17:09 marka Exp $ */ +/* $Id: socket.c,v 1.237.18.72 2011-07-21 23:45:14 tbox Exp $ */ /*! \file */ @@ -1088,6 +1088,9 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) if ((sock->type == isc_sockettype_udp) && ((dev->attributes & ISC_SOCKEVENTATTR_PKTINFO) != 0)) { +#if defined(IPV6_USE_MIN_MTU) + int use_min_mtu = 1; /* -1, 0, 1 */ +#endif struct cmsghdr *cmsgp; struct in6_pktinfo *pktinfop; @@ -1106,6 +1109,22 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, cmsgp->cmsg_len = cmsg_len(sizeof(struct in6_pktinfo)); pktinfop = (struct in6_pktinfo *)CMSG_DATA(cmsgp); memcpy(pktinfop, &dev->pktinfo, sizeof(struct in6_pktinfo)); +#if defined(IPV6_USE_MIN_MTU) + /* + * Set IPV6_USE_MIN_MTU as a per packet option as FreeBSD + * ignores setsockopt(IPV6_USE_MIN_MTU) when IPV6_PKTINFO + * is used. + */ + cmsgp = (struct cmsghdr *)(sock->sendcmsgbuf + + msg->msg_controllen); + msg->msg_controllen += cmsg_space(sizeof(use_min_mtu)); + INSIST(msg->msg_controllen <= sock->sendcmsgbuflen); + + cmsgp->cmsg_level = IPPROTO_IPV6; + cmsgp->cmsg_type = IPV6_USE_MIN_MTU; + cmsgp->cmsg_len = cmsg_len(sizeof(use_min_mtu)); + memcpy(CMSG_DATA(cmsgp), &use_min_mtu, sizeof(use_min_mtu)); +#endif } #endif /* USE_CMSG && ISC_PLATFORM_HAVEIPV6 */ #else /* ISC_NET_BSD44MSGHDR */ @@ -1724,7 +1743,14 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, cmsgbuflen = 0; #if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO) - cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo)); + cmsgbuflen += cmsg_space(sizeof(struct in6_pktinfo)); +#if defined(IPV6_USE_MIN_MTU) + /* + * Provide space for working around FreeBSD's broken IPV6_USE_MIN_MTU + * support. + */ + cmsgbuflen += cmsg_space(sizeof(int)); +#endif #endif sock->sendcmsgbuflen = cmsgbuflen; if (sock->sendcmsgbuflen != 0U) { @@ -2055,10 +2081,18 @@ opensocket(isc_socketmgr_t *manager, isc_socket_t *sock) { #endif /* ISC_PLATFORM_HAVEIN6PKTINFO */ #ifdef IPV6_USE_MIN_MTU /* RFC 3542, not too common yet*/ /* use minimum MTU */ - if (sock->pf == AF_INET6) { - (void)setsockopt(sock->fd, IPPROTO_IPV6, - IPV6_USE_MIN_MTU, - (void *)&on, sizeof(on)); + if (sock->pf == AF_INET6 && + setsockopt(sock->fd, IPPROTO_IPV6, IPV6_USE_MIN_MTU, + (void *)&on, sizeof(on)) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, + "setsockopt(%d, IPV6_USE_MIN_MTU) " + "%s: %s", sock->fd, + isc_msgcat_get(isc_msgcat, + ISC_MSGSET_GENERAL, + ISC_MSG_FAILED, + "failed"), + strbuf); } #endif #endif /* ISC_PLATFORM_HAVEIPV6 */ @@ -4334,9 +4368,16 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr, return (ISC_R_SUCCESS); } +/* + * Enable this only for specific OS versions, and only when they have repaired + * their problems with it. Until then, this is is broken and needs to be + * diabled by default. See RT22589 for details. + */ +#undef ENABLE_ACCEPTFILTER + isc_result_t isc_socket_filter(isc_socket_t *sock, const char *filter) { -#ifdef SO_ACCEPTFILTER +#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER) char strbuf[ISC_STRERRORSIZE]; struct accept_filter_arg afa; #else @@ -4346,7 +4387,7 @@ isc_socket_filter(isc_socket_t *sock, const char *filter) { REQUIRE(VALID_SOCKET(sock)); -#ifdef SO_ACCEPTFILTER +#if defined(SO_ACCEPTFILTER) && defined(ENABLE_ACCEPTFILTER) bzero(&afa, sizeof(afa)); strncpy(afa.af_name, filter, sizeof(afa.af_name)); if (setsockopt(sock->fd, SOL_SOCKET, SO_ACCEPTFILTER, diff --git a/lib/isc/unix/stdio.c b/lib/isc/unix/stdio.c index a18c5ab15686..c06bd4fbb269 100644 --- a/lib/isc/unix/stdio.c +++ b/lib/isc/unix/stdio.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2011 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: stdio.c,v 1.6 2004-03-05 05:11:47 marka Exp $ */ +/* $Id: stdio.c,v 1.6.18.2 2011-03-05 23:47:52 tbox Exp $ */ #include <config.h> @@ -23,6 +23,7 @@ #include <unistd.h> #include <isc/stdio.h> +#include <isc/stat.h> #include "errno2result.h" |
