]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't check the result of setting SO_INCOMING_CPU
authorOndřej Surý <ondrej@isc.org>
Wed, 3 Jun 2020 09:01:19 +0000 (11:01 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 3 Jun 2020 10:44:44 +0000 (12:44 +0200)
The SO_INCOMING_CPU is available since Linux 3.19 for getting the value,
but only since Linux 4.4 for setting the value (see below for a full
description).  BIND 9 should not fail when setting the option on the
socket fails, as this is only an optimization and not hard requirement
to run BIND 9.

    SO_INCOMING_CPU (gettable since Linux 3.19, settable since Linux 4.4)
        Sets or gets the CPU affinity of a socket.  Expects an integer flag.

            int cpu = 1;
            setsockopt(fd, SOL_SOCKET, SO_INCOMING_CPU, &cpu, sizeof(cpu));

        Because all of the packets for a single stream (i.e., all
packets for the same 4-tuple) arrive on the single RX queue that
is associated with a particular CPU, the typical use case is to
employ one listening process per RX queue, with the incoming
flow being handled by a listener on the same CPU that is
handling the RX queue.  This provides optimal NUMA behavior and
keeps CPU caches hot.

lib/isc/netmgr/udp.c

index 1b642b8928e2f4d12f0008ff1fa2429366052ae9..066e5edcb57126b72e01b7e56a1be560118464cc 100644 (file)
@@ -115,9 +115,12 @@ isc_nm_listenudp(isc_nm_t *mgr, isc_nmiface_t *iface, isc_nm_recv_cb_t cb,
 #endif
 
 #ifdef SO_INCOMING_CPU
-               res = setsockopt(csock->fd, SOL_SOCKET, SO_INCOMING_CPU,
+               /* We don't check for the result, because SO_INCOMING_CPU can be
+                * available without the setter on Linux kernel version 4.4, and
+                * setting SO_INCOMING_CPU is just an optimization.
+                */
+               (void)setsockopt(csock->fd, SOL_SOCKET, SO_INCOMING_CPU,
                                 &(int){ 1 }, sizeof(int));
-               RUNTIME_CHECK(res == 0);
 #endif
                ievent = isc__nm_get_ievent(mgr, netievent_udplisten);
                ievent->sock = csock;