]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- For windows crosscompile, fix setting the IPV6_MTU socket option
authorGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 12 Jul 2022 15:17:59 +0000 (17:17 +0200)
committerGeorge Thessalonikefs <george@nlnetlabs.nl>
Tue, 12 Jul 2022 15:17:59 +0000 (17:17 +0200)
  equivalent (IPV6_USER_MTU); allows cross compiling with latest
  cross-compiler versions.

doc/Changelog
services/listen_dnsport.c

index d6511e4a27593931f586f9552bd173b32838e711..ddefbde296cb9e4344267b18bccafd6f81049c4f 100644 (file)
@@ -1,3 +1,8 @@
+12 July 2022: George
+       - For windows crosscompile, fix setting the IPV6_MTU socket option
+         equivalent (IPV6_USER_MTU); allows cross compiling with latest
+         cross-compiler versions.
+
 12 July 2022: Wouter
        - Fix dname count in sldns parse type descriptor for SVCB and HTTPS.
 
index 03153bd64778ce145482a149f041a2b0c83cd459..1c7c177a007e986d11f4f7ce6dd435aa52007cd5 100644 (file)
@@ -490,6 +490,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
                        return -1;
                }
 # elif defined(IPV6_MTU)
+#   ifndef USE_WINSOCK
                /*
                 * On Linux, to send no larger than 1280, the PMTUD is
                 * disabled by default for datagrams anyway, so we set
@@ -497,13 +498,27 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
                 */
                if (setsockopt(s, IPPROTO_IPV6, IPV6_MTU,
                        (void*)&mtu, (socklen_t)sizeof(mtu)) < 0) {
-                       log_err("setsockopt(..., IPV6_MTU, ...) failed: %s", 
+                       log_err("setsockopt(..., IPV6_MTU, ...) failed: %s",
                                sock_strerror(errno));
                        sock_close(s);
                        *noproto = 0;
                        *inuse = 0;
                        return -1;
                }
+#   elif defined(IPV6_USER_MTU)
+               /* As later versions of the mingw crosscompiler define
+                * IPV6_MTU, do the same for windows but use IPV6_USER_MTU
+                * instead which is writable; IPV6_MTU is readonly there. */
+               if (setsockopt(s, IPPROTO_IPV6, IPV6_USER_MTU,
+                       (void*)&mtu, (socklen_t)sizeof(mtu)) < 0) {
+                       log_err("setsockopt(..., IPV6_USER_MTU, ...) failed: %s",
+                               wsa_strerror(WSAGetLastError()));
+                       sock_close(s);
+                       *noproto = 0;
+                       *inuse = 0;
+                       return -1;
+               }
+#   endif /* USE_WINSOCK */
 # endif /* IPv6 MTU */
 # if defined(IPV6_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
 #  if defined(IP_PMTUDISC_OMIT)