From 035b66b1a997418293f82e663ed7b74ca0d2c143 Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Mon, 15 Jul 2019 20:14:14 +0200 Subject: [PATCH] Fix mtu with AES This avoids fragmentation when possible --- edge_utils.c | 10 +++++++--- n2n.h | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/edge_utils.c b/edge_utils.c index 6acaf0c..70f503d 100644 --- a/edge_utils.c +++ b/edge_utils.c @@ -1266,9 +1266,13 @@ static void send_packet2net(n2n_edge_t * eee, traceEvent(TRACE_DEBUG, "Encode %u B PACKET [%u B data, %u B overhead] transform %u", (u_int)idx, (u_int)len, (u_int)(idx-len), tx_transop_idx); -#if 0 - // MTU assertion to avoid fragmentation - assert(idx <= 1500); +#ifdef MTU_ASSERT_VALUE + { + const u_int eth_udp_overhead = 14 + 20 + 8; + + // MTU assertion which avoids fragmentation by N2N + assert(idx + eth_udp_overhead <= MTU_ASSERT_VALUE); + } #endif eee->transop.tx_cnt++; /* stats */ diff --git a/n2n.h b/n2n.h index 21473dd..cb9f4d6 100644 --- a/n2n.h +++ b/n2n.h @@ -164,7 +164,10 @@ typedef struct tuntap_dev { * same value if they are to understand each other. */ #define N2N_COMPRESSION_ENABLED 1 -#define DEFAULT_MTU 1400 +#define DEFAULT_MTU 1390 + +/** Uncomment this to enable the MTU check */ +//#define MTU_ASSERT_VALUE 1500 /** Common type used to hold stringified IP addresses. */ typedef char ipstr_t[32];