Disable fragmentation for all the outgoing UDP packets

This commit is contained in:
Max Lv committed 2022-02-15 11:48:43 +08:00
1 parent 3654658111
commit 46382c23fa
1 file changed
+13
+13
View File
@@ -431,6 +431,13 @@ create_remote_socket(int ipv6)
}
#endif
}
#if defined(__linux__)
// Disable fragmentation
int val = IP_PMTUDISC_DO;
setsockopt(remote_sock, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
#endif
return remote_sock;
}
@@ -545,6 +552,12 @@ create_server_socket(const char *host, const char *port)
freeaddrinfo(result);
#if defined(__linux__)
// Disable fragmentation
int val = IP_PMTUDISC_DO;
setsockopt(server_sock, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
#endif
return server_sock;
}