You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/31 19:30:54 UTC

[incubator-nuttx] 10/10: Fix the wrong IPv6 TCP MSS calculation

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch pr192
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit c8fb4863f2cf993c7fa3ebd42842189bca5b559d
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Feb 1 02:59:54 2020 +0800

    Fix the wrong IPv6 TCP MSS calculation
    
    1280(MTU) - 40(IPv6_HDRLEN) - 20(TCP_HDRLEN0 = 1220
    
    Change-Id: If3e8352b07992b54f5d2c9c4170f0426feb4682b
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 include/nuttx/net/netconfig.h |  9 ++++++---
 include/nuttx/net/tcp.h       | 12 ++++++------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/nuttx/net/netconfig.h b/include/nuttx/net/netconfig.h
index 780290f..1fdb71f 100644
--- a/include/nuttx/net/netconfig.h
+++ b/include/nuttx/net/netconfig.h
@@ -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 */
diff --git a/include/nuttx/net/tcp.h b/include/nuttx/net/tcp.h
index 3e9f6dc..a3f3750 100644
--- a/include/nuttx/net/tcp.h
+++ b/include/nuttx/net/tcp.h
@@ -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
 
 /****************************************************************************