From 46382c23fac8fbabb62130ef49d3f0bf4c807b43 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Tue, 15 Feb 2022 11:48:43 +0800 Subject: [PATCH] Disable fragmentation for all the outgoing UDP packets --- src/udprelay.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/udprelay.c b/src/udprelay.c index 9c46f142b..23a042497 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -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; }