]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Support SO_REUSEPORT_LB in FreeBSD 12 with the so-reuseport: yes
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 19 Nov 2018 09:36:27 +0000 (09:36 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 19 Nov 2018 09:36:27 +0000 (09:36 +0000)
  option in unbound.conf.

git-svn-id: file:///svn/unbound/trunk@4960 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
services/listen_dnsport.c

index ffdeb93e7d8b9b8e7e807980cba2c68d3af602a4..38ca195cd5b768b93802f14e3a1114d13886db1e 100644 (file)
@@ -1,4 +1,8 @@
-6 November 2018:
+19 November 2018: Wouter
+       - Support SO_REUSEPORT_LB in FreeBSD 12 with the so-reuseport: yes
+         option in unbound.conf.
+
+6 November 2018: Ralph
        - Bugfix min-client-subnet-ipv6
 
 25 October 2018: Ralph
index a2fb8906702e3f64b2afc5e1b0e47d86b7c5387f..efc0c3e185b631e6fd67ab10ab723144dd95cd12 100644 (file)
@@ -247,6 +247,26 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
                }
 #endif /* SO_REUSEADDR */
 #ifdef SO_REUSEPORT
+#  ifdef SO_REUSEPORT_LB
+               /* on FreeBSD 12 we have SO_REUSEPORT_LB that does loadbalance
+                * like SO_REUSEPORT on Linux.  This is what the users want
+                * with the config option in unbound.conf; if we actually
+                * need local address and port reuse they'll also need to
+                * have SO_REUSEPORT set for them, assume it was _LB they want.
+                */
+               if (reuseport && *reuseport &&
+                   setsockopt(s, SOL_SOCKET, SO_REUSEPORT_LB, (void*)&on,
+                       (socklen_t)sizeof(on)) < 0) {
+#ifdef ENOPROTOOPT
+                       if(errno != ENOPROTOOPT || verbosity >= 3)
+                               log_warn("setsockopt(.. SO_REUSEPORT_LB ..) failed: %s",
+                                       strerror(errno));
+#endif
+                       /* this option is not essential, we can continue */
+                       *reuseport = 0;
+               }
+#  else /* no SO_REUSEPORT_LB */
+
                /* try to set SO_REUSEPORT so that incoming
                 * queries are distributed evenly among the receiving threads.
                 * Each thread must have its own socket bound to the same port,
@@ -263,6 +283,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
                        /* this option is not essential, we can continue */
                        *reuseport = 0;
                }
+#  endif /* SO_REUSEPORT_LB */
 #else
                (void)reuseport;
 #endif /* defined(SO_REUSEPORT) */