From 214ae42cd3cfc9a844787e0cea8ff6fa483a8931 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 24 Mar 2014 13:22:22 +0100 Subject: [PATCH] The IP don't fragment bit is only set if try-mtu-discovery is true. --- src/main.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 97941e85..0e651fa1 100644 --- a/src/main.c +++ b/src/main.c @@ -95,20 +95,22 @@ static void add_listener(struct listen_list_st *list, list->total++; } -static void set_udp_socket_options(int fd) +static void set_udp_socket_options(struct cfg_st* config, int fd) { int y; + if (config->try_mtu) { #if defined(IP_DONTFRAG) - y = 1; - if (setsockopt(fd, SOL_IP, IP_DONTFRAG, - (const void *) &y, sizeof(y)) < 0) - perror("setsockopt(IP_DF) failed"); + y = 1; + if (setsockopt(fd, SOL_IP, IP_DONTFRAG, + (const void *) &y, sizeof(y)) < 0) + perror("setsockopt(IP_DF) failed"); #elif defined(IP_MTU_DISCOVER) - y = IP_PMTUDISC_DO; - if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, + y = IP_PMTUDISC_DO; + if (setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, (const void *) &y, sizeof(y)) < 0) - perror("setsockopt(IP_DF) failed"); + perror("setsockopt(IP_DF) failed"); #endif + } } static void set_common_socket_options(int fd) @@ -174,7 +176,7 @@ int _listen_ports(struct cfg_st* config, struct addrinfo *res, struct listen_lis } if (ptr->ai_socktype == SOCK_DGRAM) { - set_udp_socket_options(s); + set_udp_socket_options(config, s); } @@ -246,7 +248,7 @@ listen_ports(struct cfg_st* config, struct listen_list_st *list, const char *nod } if (type == SOCK_DGRAM) - set_udp_socket_options(fd); + set_udp_socket_options(config, fd); /* obtain socket params */ tmp_sock_len = sizeof(tmp_sock);