]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #741: systemd socket activation fails on IPv6.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 Aug 2022 07:12:08 +0000 (09:12 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Mon, 22 Aug 2022 07:12:08 +0000 (09:12 +0200)
doc/Changelog
services/listen_dnsport.c

index 0e67bf0b19f7317f8b3470c2348429380980b05f..3525165250c7f25710909c3dbdf93fee6e9c5d70 100644 (file)
@@ -1,3 +1,6 @@
+22 August 2022: Wouter
+       - Fix #741: systemd socket activation fails on IPv6.
+
 12 August 2022: Wouter
        - Fix to log accept error ENFILE and EMFILE errno, but slowly, once
          per 10 seconds. Also log accept failures when no slow down is used.
index 467419b093980a7160e5261b0a63222afbdce623..1263e0ead055cac2f7fd5f55a18adb77cf397bd2 100644 (file)
@@ -458,7 +458,14 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
                int action;
 # endif
 # if defined(IPV6_V6ONLY)
-               if(v6only) {
+               if(v6only
+#   ifdef HAVE_SYSTEMD
+                       /* Systemd wants to control if the socket is v6 only
+                        * or both, with BindIPv6Only=default, ipv6-only or
+                        * both in systemd.socket, so it is not set here. */
+                       && !got_fd_from_systemd
+#   endif
+                       ) {
                        int val=(v6only==2)?0:1;
                        if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, 
                                (void*)&val, (socklen_t)sizeof(val)) < 0) {
@@ -776,7 +783,14 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
        (void)reuseport;
 #endif /* defined(SO_REUSEPORT) */
 #if defined(IPV6_V6ONLY)
-       if(addr->ai_family == AF_INET6 && v6only) {
+       if(addr->ai_family == AF_INET6 && v6only
+#  ifdef HAVE_SYSTEMD
+               /* Systemd wants to control if the socket is v6 only
+                * or both, with BindIPv6Only=default, ipv6-only or
+                * both in systemd.socket, so it is not set here. */
+               && !got_fd_from_systemd
+#  endif
+               ) {
                if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, 
                        (void*)&on, (socklen_t)sizeof(on)) < 0) {
                        log_err("setsockopt(..., IPV6_V6ONLY, ...) failed: %s",