Browse Source

Revised handling of path MTU discovery to exclude Mac OS

Paul-Louis Ageneau 5 years ago
parent
commit
7af3da7872
2 changed files with 23 additions and 5 deletions
  1. 1 1
      deps/libjuice
  2. 22 4
      src/sctptransport.cpp

+ 1 - 1
deps/libjuice

@@ -1 +1 @@
-Subproject commit 3a0e15876c5633312a54a44b55ac8f27ea0a0e33
+Subproject commit a7ca5e9e8fd139ed9a2a137ec6fad6e35da623df

+ 22 - 4
src/sctptransport.cpp

@@ -27,6 +27,25 @@
 #include <arpa/inet.h>
 #endif
 
+#ifdef USE_JUICE
+#ifndef __APPLE__
+// libjuice enables Linux path MTU discovery or sets the DF flag
+#define USE_PMTUD 1
+#else
+// Setting the DF flag is not available on Mac OS
+#define USE_PMTUD 0
+#endif
+#else
+#ifdef __linux__
+// Linux UDP does path MTU discovery by default (setting DF and returning EMSGSIZE)
+// It should be safe to enable discovery for SCTP.
+#define USE_PMTUD 1
+#else
+// Otherwise assume fragmentation
+#define USE_PMTUD 0
+#endif
+#endif
+
 using namespace std::chrono_literals;
 using namespace std::chrono;
 
@@ -119,12 +138,11 @@ SctpTransport::SctpTransport(std::shared_ptr<Transport> lower, uint16_t port,
 		                         std::to_string(errno));
 
 	struct sctp_paddrparams spp = {};
-#ifdef __linux__
-	// Linux UDP does path MTU discovery by default (setting DF and returning EMSGSIZE).
-	// It should be safe to enable discovery for SCTP.
+#if USE_PMTUD
+	// Enabled SCTP path MTU discovery
 	spp.spp_flags = SPP_PMTUD_ENABLE;
 #else
-	// Otherwise, fall back to a safe MTU value.
+	// Fall back to a safe MTU value.
 	spp.spp_flags = SPP_PMTUD_DISABLE;
 	spp.spp_pathmtu = 1200; // Max safe value recommended by RFC 8261
 	                        // See https://tools.ietf.org/html/rfc8261#section-5