From e7ad7fc73e46112756272423e5e0694673849193 Mon Sep 17 00:00:00 2001 From: Max Witten Date: Mon, 5 Mar 2018 21:37:12 +0800 Subject: [PATCH] udprelay: display mtu at least size --- src/udprelay.c | 14 +++++++------- src/udprelay.h | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/udprelay.c b/src/udprelay.c index aa0b2c36..2b774d27 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -724,7 +724,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) goto CLEAN_UP; } else if (r > packet_size) { if (verbose) { - LOGI("[udp] remote_recv_recvfrom fragmentation"); + LOGI("[udp] remote_recv_recvfrom fragmentation, MTU at least be: %zd", r + PACKET_HEADER_SIZE); } } @@ -798,7 +798,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) if (buf->len > packet_size) { if (verbose) { - LOGI("[udp] remote_recv_sendto fragmentation"); + LOGI("[udp] remote_recv_sendto fragmentation, MTU at least be: %zd", buf->len + PACKET_HEADER_SIZE); } } @@ -902,7 +902,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) goto CLEAN_UP; } else if (buf->len > packet_size) { if (verbose) { - LOGI("[udp] UDP server_recv_recvmsg fragmentation"); + LOGI("[udp] UDP server_recv_recvmsg fragmentation, MTU at least be: %zd", buf->len + PACKET_HEADER_SIZE); } } @@ -924,7 +924,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) goto CLEAN_UP; } else if (r > packet_size) { if (verbose) { - LOGI("[udp] server_recv_recvfrom fragmentation"); + LOGI("[udp] server_recv_recvfrom fragmentation, MTU at least be: %zd", r + PACKET_HEADER_SIZE); } } @@ -1208,7 +1208,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) if (buf->len > packet_size) { if (verbose) { - LOGI("[udp] server_recv_sendto fragmentation"); + LOGI("[udp] server_recv_sendto fragmentation, MTU at least be: %zd", buf->len + PACKET_HEADER_SIZE); } } @@ -1225,7 +1225,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) if (buf->len - addr_header_len > packet_size) { if (verbose) { - LOGI("[udp] server_recv_sendto fragmentation"); + LOGI("[udp] server_recv_sendto fragmentation, MTU at least be: %zd", buf->len - addr_header_len + PACKET_HEADER_SIZE); } } @@ -1345,7 +1345,7 @@ init_udprelay(const char *server_host, const char *server_port, // Initialize MTU if (mtu > 0) { - packet_size = mtu - 1 - 28 - 2 - 64; + packet_size = mtu - PACKET_HEADER_SIZE; buf_size = packet_size * 2; } diff --git a/src/udprelay.h b/src/udprelay.h index 0068adff..4b801a30 100644 --- a/src/udprelay.h +++ b/src/udprelay.h @@ -44,7 +44,8 @@ #define MAX_UDP_PACKET_SIZE (65507) -#define DEFAULT_PACKET_SIZE 1397 // 1492 - 1 - 28 - 2 - 64 = 1397, the default MTU for UDP relay +#define PACKET_HEADER_SIZE (1 + 28 + 2 + 64) +#define DEFAULT_PACKET_SIZE 1397 // 1492 - PACKET_HEADER_SIZE = 1397, the default MTU for UDP relay typedef struct server_ctx { ev_io io;