Commit 340a0596 authored by Mark Andrews's avatar Mark Andrews
Browse files

2146. [cleanup] Silence Linux's spurious "obsolete setsockopt

                        SO_BSDCOMPAT" message. [RT #16641]
parent 394f4aec
2146. [cleanup] Silence Linux's spurious "obsolete setsockopt
SO_BSDCOMPAT" message. [RT #16641]
2145. [bug] Check DS/DLV digest lengths for known digests.
[RT #16622]
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: socket.c,v 1.269 2007/02/13 02:49:08 marka Exp $ */
/* $Id: socket.c,v 1.270 2007/02/26 01:37:37 marka Exp $ */
/*! \file */
......@@ -48,6 +48,7 @@
#include <isc/msgs.h>
#include <isc/mutex.h>
#include <isc/net.h>
#include <isc/once.h>
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/region.h>
......@@ -69,6 +70,11 @@
*/
#define ISC_SOCKET_NAMES 1
#if defined(SO_BSDCOMPAT) && defined(__linux__)
#include <sys/utsname.h>
#endif
/*%
* Some systems define the socket length argument as an int, some as size_t,
* some as socklen_t. This is here so it can be easily changed if needed.
......@@ -1410,7 +1416,45 @@ free_socket(isc_socket_t **socketp) {
*socketp = NULL;
}
#ifdef SO_BSDCOMPAT
/*
* This really should not be necessary to do. Having to workout
* which kernel version we are on at run time so that we don't cause
* the kernel to issue a warning about us using a deprecated socket option.
* Such warnings should *never* be on by default in production kernels.
*
* We can't do this a build time because executables are moved between
* machines and hence kernels.
*
* We can't just not set SO_BSDCOMAT because some kernels require it.
*/
static isc_once_t bsdcompat_once = ISC_ONCE_INIT;
isc_boolean_t bsdcompat = ISC_TRUE;
static void
clear_bsdcompat(void) {
#ifdef __linux__
struct utsname buf;
char *endp;
long int major;
long int minor;
uname(&buf); /* Can only fail if buf is bad in Linux. */
/* Paranoia in parsing can be increased, but we trust uname(). */
major = strtol(buf.release, &endp, 10);
if (*endp == '.') {
minor = strtol(endp+1, &endp, 10);
if ((major > 2) || ((major == 2) && (minor >= 4))) {
bsdcompat = ISC_FALSE;
}
}
#endif /* __linux __ */
}
#endif
/*%
* Create a new 'type' socket managed by 'manager'. Events
* will be posted to 'task' and when dispatched 'action' will be
* called with 'arg' as the arg value. The new socket is returned
......@@ -1520,7 +1564,9 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
}
#ifdef SO_BSDCOMPAT
if (type != isc_sockettype_unix &&
RUNTIME_CHECK(isc_once_do(&bsdcompat_once,
clear_bsdcompat) == ISC_R_SUCCESS);
if (type != isc_sockettype_unix && bsdcompat &&
setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
(void *)&on, sizeof(on)) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment