- Fix #741: systemd socket activation fails on IPv6.

This commit is contained in:
W.C.A. Wijngaards 2022-08-22 09:12:08 +02:00
parent dc6c04b243
commit e6f878ee71
2 changed files with 19 additions and 2 deletions

View 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.

View 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",