[PATCH V3 1/7] NaCl: Add autoconf check for IPV6_PATHMTU getsockopt() call

Kevin Cernekee cernekee at gmail.com
Wed May 4 21:40:03 PDT 2016


Unfortunately this feature is not yet supported under NaCl, and it
results in a compile error.

Signed-off-by: Kevin Cernekee <cernekee at gmail.com>
---
 configure.ac | 10 ++++++++++
 dtls.c       | 16 ++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0851f9f..ff381a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,6 +183,16 @@ if test "$have_inet_aton" = "yes"; then
    AC_DEFINE(HAVE_INET_ATON, 1, [Have inet_aton()])
 fi
 
+AC_MSG_CHECKING([for IPV6_PATHMTU socket option])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+		  #include <netinet/in.h>
+		  #include <sys/socket.h>
+		  #include <sys/types.h>],[
+		  int foo = IPV6_PATHMTU; (void)foo;])],
+		  [AC_DEFINE(HAVE_IPV6_PATHMTU, 1, [Have IPV6_PATHMTU socket option])
+		   AC_MSG_RESULT([yes])],
+		  [AC_MSG_RESULT([no])])
+
 AC_CHECK_FUNC(__android_log_vprint, [], AC_CHECK_LIB(log, __android_log_vprint, [], []))
 
 AC_ENABLE_SHARED
diff --git a/dtls.c b/dtls.c
index 3b9cbbe..cc56067 100644
--- a/dtls.c
+++ b/dtls.c
@@ -18,6 +18,8 @@
 #include <config.h>
 
 #include <errno.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -1069,11 +1071,6 @@ int dtls_mainloop(struct openconnect_info *vpninfo, int *timeout)
 
 #if defined(DTLS_GNUTLS)
 
-/* Old glibc doesn't define that */
-#if defined(__linux__) && !defined(IPV6_PATHMTU)
-# define IPV6_PATHMTU 61
-#endif
-
 static int is_cancelled(struct openconnect_info *vpninfo)
 {
 	fd_set rd_set;
@@ -1195,6 +1192,13 @@ static int detect_mtu_ipv4(struct openconnect_info *vpninfo, unsigned char *buf)
 }
 
 #if defined(IPPROTO_IPV6)
+
+/* This symbol is missing in glibc < 2.22 (bug 18643). */
+#if defined(__linux__) && !defined(HAVE_IPV6_PATHMTU)
+# define HAVE_IPV6_PATHMTU 1
+# define IPV6_PATHMTU 61
+#endif
+
 /* Verifies whether current MTU is ok, or detects new MTU using IPv6's ICMP6 messages
  * @buf: is preallocated with MTU size
  * @id: a unique ID for our DPD exchange
@@ -1265,7 +1269,7 @@ static int detect_mtu_ipv6(struct openconnect_info *vpninfo, unsigned char *buf)
 		break;
 	} while(max_resends-- > 0);
 
-#ifndef _WIN32
+#ifdef HAVE_IPV6_PATHMTU
 	/* If we received back our DPD packet, do nothing; otherwise,
 	 * attempt to get MTU from the ICMP6 packet we received */
 	if (ret <= 0) {
-- 
1.9.1




More information about the openconnect-devel mailing list