From c34cf1122f107769bc6b18aa78be87b8ec4e20f5 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 12 Jan 2015 21:23:34 +0100 Subject: Make MTU mismatches fatal As fastd calculates its receive buffer sizes based on the MTU, not matching MTUs is bound to cause issues anyways, so let's fail completely. --- src/handshake.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/handshake.c') diff --git a/src/handshake.c b/src/handshake.c index f66282c..2c22655 100644 --- a/src/handshake.c +++ b/src/handshake.c @@ -243,6 +243,10 @@ static void print_error(const char *prefix, const fastd_peer_address_t *remote_a pr_warn("Handshake with %I failed: %s error: TUN/TAP mode mismatch", remote_addr, prefix); break; + case RECORD_MTU: + pr_warn("Handshake with %I failed: %s error: MTU configuration differs with peer (local MTU is %u)", remote_addr, prefix, conf.mtu); + break; + case RECORD_METHOD_NAME: case RECORD_METHOD_LIST: pr_warn("Handshake with %I failed: %s error: no common methods are configured", remote_addr, prefix); @@ -364,8 +368,8 @@ static inline bool check_records(fastd_socket_t *sock, const fastd_peer_address_ if (!conf.secure_handshakes || handshake->type > 1) { if (handshake->records[RECORD_MTU].length == 2) { if (as_uint16_endian(&handshake->records[RECORD_MTU], handshake->little_endian) != conf.mtu) { - pr_warn("MTU configuration differs with peer %I: local MTU is %u, remote MTU is %u", - remote_addr, conf.mtu, as_uint16_endian(&handshake->records[RECORD_MTU], handshake->little_endian)); + send_error(sock, local_addr, remote_addr, peer, handshake, REPLY_UNACCEPTABLE_VALUE, RECORD_MTU); + return false; } } } -- cgit v1.2.3