]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove SO_BSDCOMPAT usage, it's ignore since Linux 2.4
authorOndřej Surý <ondrej@sury.org>
Mon, 1 Jul 2019 14:16:40 +0000 (16:16 +0200)
committerOndřej Surý <ondrej@sury.org>
Mon, 1 Jul 2019 14:16:40 +0000 (16:16 +0200)
The SO_BSDCOMPAT socket option is no-op since Linux 2.4, see the manpage:

SO_BSDCOMPAT
Enable BSD bug-to-bug compatibility.  This is used by the UDP protocol
module in Linux 2.0 and 2.2.  If enabled, ICMP errors received for a UDP
socket will not be passed to the user program.  In later kernel
versions, support for this option has been phased out: Linux 2.4
silently ignores it, and Linux 2.6 generates a kernel warning (printk())
if a program uses this option.  Linux 2.0 also enabled BSD bug-to-bug
compatibility options (random header changing, skipping of the broadcast
flag) for raw sockets with this option, but that was removed in Linux
2.2.

lib/isc/unix/socket.c

index 6eda418b9f3b371197fc811c9e7a32c02409fab1..d2b8b77156f833cba11880d121d19943556e1591 100644 (file)
 
 #include "errno2result.h"
 
-#if defined(SO_BSDCOMPAT) && defined(__linux__)
-#include <sys/utsname.h>
-#endif
-
 #ifdef ENABLE_TCP_FASTOPEN
 #include <netinet/tcp.h>
 #endif
@@ -2054,44 +2050,6 @@ set_sndbuf(void) {
 }
 #endif
 
-#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;
-bool bsdcompat = 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 = false;
-               }
-        }
-#endif /* __linux __ */
-}
-#endif
-
 static void
 use_min_mtu(isc__socket_t *sock) {
 #if !defined(IPV6_USE_MIN_MTU) && !defined(IPV6_MTU)
@@ -2134,7 +2092,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
        char strbuf[ISC_STRERRORSIZE];
        const char *err = "socket";
        int tries = 0;
-#if defined(USE_CMSG) || defined(SO_BSDCOMPAT) || defined(SO_NOSIGPIPE)
+#if defined(USE_CMSG) || defined(SO_NOSIGPIPE)
        int on = 1;
 #endif
 #if defined(SO_RCVBUF) || defined(SO_SNDBUF)
@@ -2282,21 +2240,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock,
                return (result);
        }
 
-#ifdef SO_BSDCOMPAT
-       RUNTIME_CHECK(isc_once_do(&bsdcompat_once,
-                                 clear_bsdcompat) == ISC_R_SUCCESS);
-       if (sock->type != isc_sockettype_unix && bsdcompat &&
-           setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT,
-                      (void *)&on, sizeof(on)) < 0) {
-               strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "setsockopt(%d, SO_BSDCOMPAT) failed: %s",
-                                sock->fd,
-                                strbuf);
-               /* Press on... */
-       }
-#endif
-
 #ifdef SO_NOSIGPIPE
        if (setsockopt(sock->fd, SOL_SOCKET, SO_NOSIGPIPE,
                       (void *)&on, sizeof(on)) < 0) {