From: Nikos Mavrogiannopoulos Date: Wed, 28 Dec 2011 08:32:48 +0000 (+0200) Subject: Set don't fragment bit in Linux as well as in BSD variants. X-Git-Tag: gnutls_3_0_10~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=725cf45965e66b8d5a19fa39b679d0a2c505ce0f;p=thirdparty%2Fgnutls.git Set don't fragment bit in Linux as well as in BSD variants. --- diff --git a/NEWS b/NEWS index 499281b995..c04f2c80f7 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ See the end for copying conditions. * Version 3.0.10 (unreleased) +** gnutls-cli/serv: Set don't fragment bit in DTLS sessions +in Linux as well as in BSD. + ** libgnutls: Corrected ciphersuite GNUTLS_ECDHE_PSK_AES_256_CBC_SHA384 ** libgnutls: Added ciphersuites: GNUTLS_PSK_WITH_AES_256_GCM_SHA384 diff --git a/src/cli.c b/src/cli.c index 946dc85ea7..8676d1c71b 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1460,17 +1460,20 @@ socket_open (socket_st * hd, const char *hostname, const char *service) exit (1); } -#ifdef IP_DONTFRAG if (hints.ai_socktype == SOCK_DGRAM) { +#if defined(IP_DONTFRAG) int yes = 1; if (setsockopt (sd, IPPROTO_IP, IP_DONTFRAG, - (const void *) &yes, sizeof (yes)) < 0) - { - perror ("setsockopt(IP_DF) failed"); - } - } + (const void *) &yes, sizeof (yes)) < 0) + perror ("setsockopt(IP_DF) failed"); +#elif defined(IP_MTU_DISCOVER) + int yes = IP_PMTUDISC_DO; + if (setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, + (const void*) &yes, sizeof (yes)) < 0) + perror ("setsockopt(IP_DF) failed"); #endif + } hd->secure = 0; hd->fd = sd; diff --git a/src/serv.c b/src/serv.c index 381ab41fc4..370a669df7 100644 --- a/src/serv.c +++ b/src/serv.c @@ -733,18 +733,21 @@ listen_socket (const char *name, int listen_port, int socktype) continue; } } -#ifdef IP_DONTFRAG else { +#if defined(IP_DONTFRAG) yes = 1; if (setsockopt (s, IPPROTO_IP, IP_DONTFRAG, (const void *) &yes, sizeof (yes)) < 0) - { perror ("setsockopt(IP_DF) failed"); - } - } +#elif defined(IP_MTU_DISCOVER) + yes = IP_PMTUDISC_DO; + if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER, + (const void*) &yes, sizeof (yes)) < 0) + perror ("setsockopt(IP_DF) failed"); #endif - + } + if (bind (s, ptr->ai_addr, ptr->ai_addrlen) < 0) { perror ("bind() failed");