From fa6ba05097f144c8d943d2e7bea298f17236e690 Mon Sep 17 00:00:00 2001 From: chao an Date: Tue, 17 Jan 2023 19:52:02 +0800 Subject: [PATCH] net/tcp: move drop send source code to correct place Merge conflicts lead to code being placed in thre wrong place The debug code should placed in tcp_send() not tcp_synack() Signed-off-by: chao an --- net/tcp/tcp_send.c | 56 +++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c index 1cf14ec894f..db3d38835e1 100644 --- a/net/tcp/tcp_send.c +++ b/net/tcp/tcp_send.c @@ -279,6 +279,34 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, dev->d_len = len; tcp->tcpoffset = (TCP_HDRLEN / 4) << 4; tcp_sendcommon(dev, conn, tcp); + +#if defined(CONFIG_NET_STATISTICS) && \ + defined(CONFIG_NET_TCP_DEBUG_DROP_SEND) + +#pragma message \ + "CONFIG_NET_TCP_DEBUG_DROP_SEND is selected, this is debug " \ + "feature to drop the tcp send packet on the floor, " \ + "please confirm the configuration again if you do not want " \ + "debug the TCP stack." + + /* Debug feature to drop the tcp received packet on the floor */ + + if ((flags & TCP_PSH) != 0) + { + if ((g_netstats.tcp.sent % + CONFIG_NET_TCP_DEBUG_DROP_SEND_PROBABILITY) == 0) + { + uint32_t seq = tcp_getsequence(tcp->seqno); + + ninfo("TCP DROP SNDPKT: " + "[%d][%" PRIu32 " : %" PRIu32 " : %d]\n", + g_netstats.tcp.sent, seq, TCP_SEQ_ADD(seq, dev->d_sndlen), + dev->d_sndlen); + + dev->d_len = 0; + } + } +#endif } /**************************************************************************** @@ -575,34 +603,6 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, /* Complete the common portions of the TCP message */ tcp_sendcommon(dev, conn, tcp); - -#if defined(CONFIG_NET_STATISTICS) && \ - defined(CONFIG_NET_TCP_DEBUG_DROP_SEND) - -#pragma message \ - "CONFIG_NET_TCP_DEBUG_DROP_SEND is selected, this is debug " \ - "feature to drop the tcp send packet on the floor, " \ - "please confirm the configuration again if you do not want " \ - "debug the TCP stack." - - /* Debug feature to drop the tcp received packet on the floor */ - - if ((flags & TCP_PSH) != 0) - { - if ((g_netstats.tcp.sent % - CONFIG_NET_TCP_DEBUG_DROP_SEND_PROBABILITY) == 0) - { - uint32_t seq = tcp_getsequence(tcp->seqno); - - ninfo("TCP DROP SNDPKT: " - "[%d][%" PRIu32 " : %" PRIu32 " : %d]\n", - g_netstats.tcp.sent, seq, TCP_SEQ_ADD(seq, dev->d_sndlen), - dev->d_sndlen); - - dev->d_len = 0; - } - } -#endif } /****************************************************************************