Fix the wrong IPv6 TCP MSS calculation

1280(MTU) - 40(IPv6_HDRLEN) - 20(TCP_HDRLEN) = 1220
This commit is contained in:
Xiang Xiao 2020-02-01 02:59:54 +08:00 committed by Gregory Nutt
parent 3ae5f52757
commit 4a238f2e7b
2 changed files with 12 additions and 9 deletions

View File

@ -76,7 +76,7 @@
*/
#define __IPv4_HDRLEN 20 /* Must match IPv4_HDRLEN in include/nuttx/net/ip.h */
#define __IPv6_HDRLEN 40 /* Must match IPv4_HDRLEN in include/nuttx/net/ip.h */
#define __IPv6_HDRLEN 40 /* Must match IPv6_HDRLEN in include/nuttx/net/ip.h */
#define __UDP_HDRLEN 8 /* Must match UDP_HDRLEN in include/nuttx/net/udp.h */
#define __TCP_HDRLEN 20 /* Must match TCP_HDRLEN in include/nuttx/net/tcp.h */
/* REVISIT: Not really a constant */
@ -150,8 +150,8 @@
#endif
#ifdef CONFIG_NET_LOOPBACK
# define _MIN_LO_PKTSIZE MIN(_MIN_ETH_PKTSIZE, 1518)
# define _MAX_LO_PKTSIZE MAX(_MAX_ETH_PKTSIZE, 574)
# define _MIN_LO_PKTSIZE MIN(_MIN_ETH_PKTSIZE, 574)
# define _MAX_LO_PKTSIZE MAX(_MAX_ETH_PKTSIZE, 1518)
#else
# define _MIN_LO_PKTSIZE _MIN_ETH_PKTSIZE
# define _MAX_LO_PKTSIZE _MAX_ETH_PKTSIZE
@ -344,6 +344,9 @@
# undef MIN_UDP_MSS
# define MIN_IPv6_UDP_MSS __MIN_UDP_MSS(__IPv6_HDRLEN)
# define MIN_UDP_MSS __MIN_UDP_MSS(__IPv6_HDRLEN)
# ifndef MAX_UDP_MSS
# define MAX_UDP_MSS __MAX_UDP_MSS(__IPv6_HDRLEN)
# endif
#endif
/* TCP configuration options */

View File

@ -125,11 +125,11 @@
* These defaults correspond to the minimum MTU values:
*
* IPv4: MTU=576; MSS=536 (MTU - IPv4_HDRLEN - TCP_HDRLEN)
* IPv6: MTU=1280; MSS=1200 (MTU - IPv5_HDRLEN - TCP_HDRLEN)
* IPv6: MTU=1280; MSS=1220 (MTU - IPv6_HDRLEN - TCP_HDRLEN)
*/
#define TCP_DEFAULT_IPv4_MSS 536
#define TCP_DEFAULT_IPv6_MSS 1200
#define TCP_DEFAULT_IPv6_MSS 1220
/* However, we do need to make allowance for certain links such as SLIP that
* have unusually small MTUs.
@ -142,16 +142,16 @@
# define MIN_IPv4_TCP_INITIAL_MSS \
(__MIN_TCP_MSS(IPv4_HDRLEN) > 536 ? 536 : __MIN_TCP_MSS(IPv4_HDRLEN))
# define MAX_IPv4_TCP_INITIAL_MSS \
(__MAX_TCP_MSS(IPv4_HDRLEN) > 536 ? 536 : __MAX_TCP_MSS(h))
(__MAX_TCP_MSS(IPv4_HDRLEN) > 536 ? 536 : __MAX_TCP_MSS(IPv4_HDRLEN))
#endif
#ifdef CONFIG_NET_IPv6
# define TCP_IPv6_INITIAL_MSS(d) \
(TCP_MSS(d,IPv6_HDRLEN) > 1200 ? 1200 : TCP_MSS(d,IPv6_HDRLEN))
(TCP_MSS(d,IPv6_HDRLEN) > 1220 ? 1220 : TCP_MSS(d,IPv6_HDRLEN))
# define MIN_IPv6_TCP_INITIAL_MSS \
(__MIN_TCP_MSS(IPv6_HDRLEN) > 1200 ? 1200 : __MIN_TCP_MSS(IPv6_HDRLEN))
(__MIN_TCP_MSS(IPv6_HDRLEN) > 1220 ? 1220 : __MIN_TCP_MSS(IPv6_HDRLEN))
# define MAX_IPv6_TCP_INITIAL_MSS \
(__MAX_TCP_MSS(IPv6_HDRLEN) > 1200 ? 1200 : __MAX_TCP_MSS(IPv6_HDRLEN))
(__MAX_TCP_MSS(IPv6_HDRLEN) > 1220 ? 1220 : __MAX_TCP_MSS(IPv6_HDRLEN))
#endif
/****************************************************************************