From: W.C.A. Wijngaards Date: Mon, 22 Aug 2022 07:12:08 +0000 (+0200) Subject: - Fix #741: systemd socket activation fails on IPv6. X-Git-Tag: release-1.17.0rc1~37 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6f878ee7124d09610b3c110ba59fd2666f3ec92;p=thirdparty%2Funbound.git - Fix #741: systemd socket activation fails on IPv6. --- diff --git a/doc/Changelog b/doc/Changelog index 0e67bf0b1..352516525 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -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. diff --git a/services/listen_dnsport.c b/services/listen_dnsport.c index 467419b09..1263e0ead 100644 --- a/services/listen_dnsport.c +++ b/services/listen_dnsport.c @@ -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",