Updates to s_client and s_server to remove the constant 28 (for IPv4 header
authorMatt Caswell <matt@openssl.org>
Mon, 1 Dec 2014 23:57:44 +0000 (23:57 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 3 Dec 2014 09:35:25 +0000 (09:35 +0000)
and UDP header) when setting an mtu. This constant is not always correct (e.g.
if using IPv6). Use the new DTLS_CTRL functions instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 464ce92026bd0c79186cbefa75470f39607110be)

apps/s_client.c
apps/s_server.c

index a156e2f9ff77cdfdd3b849b8ecb37eee19a0d2f5..8b96b407d089b6e57a57dba28f7bb2be37d6b916 100644 (file)
@@ -1321,10 +1321,22 @@ re_start:
                        BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
                        }
 
-               if (socket_mtu > 28)
+               if (socket_mtu)
                        {
+                       if(socket_mtu < DTLS_get_link_min_mtu(con))
+                               {
+                               BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
+                                       DTLS_get_link_min_mtu(con));
+                               BIO_free(sbio);
+                               goto shut;
+                               }
                        SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
-                       SSL_set_mtu(con, socket_mtu - 28);
+                       if(!DTLS_set_link_mtu(con, socket_mtu))
+                               {
+                               BIO_printf(bio_err, "Failed to set MTU\n");
+                               BIO_free(sbio);
+                               goto shut;
+                               }
                        }
                else
                        /* want to do MTU discovery */
index 4ff30d862e7e9a38fd2781474a48d7d54c8ce176..f47328ab352aec6769b4316eea0b65538524bc0d 100644 (file)
@@ -2051,10 +2051,24 @@ static int sv_body(char *hostname, int s, unsigned char *context)
                        BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
                        }
 
-               if (socket_mtu > 28)
+               if (socket_mtu)
                        {
+                       if(socket_mtu < DTLS_get_link_min_mtu(con))
+                               {
+                               BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
+                                       DTLS_get_link_min_mtu(con));
+                               ret = -1;
+                               BIO_free(sbio);
+                               goto err;
+                               }
                        SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
-                       SSL_set_mtu(con, socket_mtu - 28);
+                       if(!DTLS_set_link_mtu(con, socket_mtu))
+                               {
+                               BIO_printf(bio_err, "Failed to set MTU\n");
+                               ret = -1;
+                               BIO_free(sbio);
+                               goto err;
+                               }
                        }
                else
                        /* want to do MTU discovery */