You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/14 02:20:34 UTC
[incubator-nuttx] 01/03: tcp: Extract MSS calculation from
tcp_synack
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 1f6fdf04b7dca14dd3afc77b3f35ebc0ad6828ff
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Tue Jun 1 18:43:24 2021 +0900
tcp: Extract MSS calculation from tcp_synack
I plan to use it for recv window update decision logic.
---
net/tcp/tcp.h | 16 ++++++++++++++++
net/tcp/tcp_send.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index c83f832..b71c012 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -963,6 +963,22 @@ ssize_t tcp_sendfile(FAR struct socket *psock, FAR struct file *infile,
void tcp_reset(FAR struct net_driver_s *dev);
/****************************************************************************
+ * Name: tcp_rx_mss
+ *
+ * Description:
+ * Return the MSS to advertize to the peer.
+ *
+ * Input Parameters:
+ * dev - The device driver structure
+ *
+ * Returned Value:
+ * The MSS value.
+ *
+ ****************************************************************************/
+
+uint16_t tcp_rx_mss(FAR struct net_driver_s *dev);
+
+/****************************************************************************
* Name: tcp_synack
*
* Description:
diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c
index 050fd80..1079b13 100644
--- a/net/tcp/tcp_send.c
+++ b/net/tcp/tcp_send.c
@@ -553,6 +553,45 @@ void tcp_reset(FAR struct net_driver_s *dev)
}
/****************************************************************************
+ * Name: tcp_rx_mss
+ *
+ * Description:
+ * Return the MSS to advertize to the peer.
+ *
+ * Input Parameters:
+ * dev - The device driver structure
+ *
+ * Returned Value:
+ * The MSS value.
+ *
+ ****************************************************************************/
+
+uint16_t tcp_rx_mss(FAR struct net_driver_s *dev)
+{
+ uint16_t tcp_mss;
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ if (IFF_IS_IPv6(dev->d_flags))
+#endif
+ {
+ tcp_mss = TCP_IPv6_MSS(dev);
+ }
+#endif /* CONFIG_NET_IPv6 */
+
+#ifdef CONFIG_NET_IPv4
+#ifdef CONFIG_NET_IPv6
+ else
+#endif
+ {
+ tcp_mss = TCP_IPv4_MSS(dev);
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+ return tcp_mss;
+}
+
+/****************************************************************************
* Name: tcp_synack
*
* Description:
@@ -588,10 +627,9 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
if (IFF_IS_IPv6(dev->d_flags))
#endif
{
- /* Get the MSS value and offset TCP header address for this packet */
+ /* Get the offset TCP header address for this packet */
tcp = TCPIPv6BUF;
- tcp_mss = TCP_IPv6_MSS(dev);
/* Set the packet length for the TCP Maximum Segment Size */
@@ -604,10 +642,9 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
else
#endif
{
- /* Get the MSS value and offset TCP header address for this packet */
+ /* Get the offset TCP header address for this packet */
tcp = TCPIPv4BUF;
- tcp_mss = TCP_IPv4_MSS(dev);
/* Set the packet length for the TCP Maximum Segment Size */
@@ -615,6 +652,8 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
}
#endif /* CONFIG_NET_IPv4 */
+ tcp_mss = tcp_rx_mss(dev);
+
/* Save the ACK bits */
tcp->flags = ack;