1From d0edabb1ebfe0cc1f32e91834589b16b209dcfc9 Mon Sep 17 00:00:00 2001 2From: hantwofish <hankangkang5@huawei.com> 3Date: Tue, 28 Nov 2023 04:34:02 +0800 4Subject: [PATCH] add tcpslowtmr log and tcpfasttmr cnt 5 6--- 7 src/core/tcp.c | 18 +++++++++++------- 8 src/include/lwip/stats.h | 3 +++ 9 src/include/lwipopts.h | 3 +++ 10 3 files changed, 17 insertions(+), 7 deletions(-) 11 12diff --git a/src/core/tcp.c b/src/core/tcp.c 13index 9f1e636..c1b64a3 100644 14--- a/src/core/tcp.c 15+++ b/src/core/tcp.c 16@@ -1393,16 +1393,17 @@ tcp_slowtmr_start: 17 18 if (pcb->state == SYN_SENT && pcb->nrtx >= TCP_SYNMAXRTX) { 19 ++pcb_remove; 20- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); 21+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max SYN retries reached loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 22 } else if (pcb->nrtx >= TCP_MAXRTX) { 23 ++pcb_remove; 24- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); 25+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: max DATA retries reached loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 26 } else { 27 if (pcb->persist_backoff > 0) { 28 LWIP_ASSERT("tcp_slowtimr: persist ticking with in-flight data", pcb->unacked == NULL); 29 LWIP_ASSERT("tcp_slowtimr: persist ticking with empty send buffer", pcb->unsent != NULL); 30 if (pcb->persist_probe >= TCP_MAXRTX) { 31 ++pcb_remove; /* max probes reached */ 32+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: persist_probe is greater TCP_MAXRTX loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 33 } else { 34 u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff - 1]; 35 if (pcb->persist_cnt < backoff_cnt) { 36@@ -1486,7 +1487,7 @@ tcp_slowtmr_start: 37 if ((u32_t)(tcp_ticks - pcb->tmr) > 38 TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { 39 ++pcb_remove; 40- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); 41+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2 loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 42 } 43 } 44 } 45@@ -1497,7 +1498,7 @@ tcp_slowtmr_start: 46 (pcb->state == CLOSE_WAIT))) { 47 if ((u32_t)(tcp_ticks - pcb->tmr) > 48 (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) { 49- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to ")); 50+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 51 ip_addr_debug_print_val(TCP_DEBUG, pcb->remote_ip); 52 LWIP_DEBUGF(TCP_DEBUG, ("\n")); 53 54@@ -1519,7 +1520,7 @@ tcp_slowtmr_start: 55 #if TCP_QUEUE_OOSEQ 56 if (pcb->ooseq != NULL && 57 (tcp_ticks - pcb->tmr >= (u32_t)pcb->rto * TCP_OOSEQ_TIMEOUT)) { 58- LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); 59+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: dropping OOSEQ queued data loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 60 tcp_free_ooseq(pcb); 61 } 62 #endif /* TCP_QUEUE_OOSEQ */ 63@@ -1529,7 +1530,7 @@ tcp_slowtmr_start: 64 if ((u32_t)(tcp_ticks - pcb->tmr) > 65 TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { 66 ++pcb_remove; 67- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); 68+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 69 } 70 } 71 72@@ -1537,7 +1538,7 @@ tcp_slowtmr_start: 73 if (pcb->state == LAST_ACK) { 74 if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { 75 ++pcb_remove; 76- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n")); 77+ LWIP_DEBUGF(TCP_DEBUG | GAZELLE_DEBUG_SERIOUS, ("tcp_slowtmr: removing pcb stuck in LAST-ACK loac_port=%u, remote_port=%u\n", pcb->local_port, pcb->remote_port)); 78 } 79 } 80 81@@ -1691,6 +1692,7 @@ tcp_fasttmr_start: 82 /* send delayed ACKs */ 83 if (pcb->flags & TF_ACK_DELAY) { 84 LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); 85+ MIB2_STATS_INC(mib2.tcpdelayackcnt); 86 tcp_ack_now(pcb); 87 tcp_output(pcb); 88 tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); 89@@ -1698,6 +1700,7 @@ tcp_fasttmr_start: 90 /* send pending FIN */ 91 if (pcb->flags & TF_CLOSEPEND) { 92 LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: pending FIN\n")); 93+ MIB2_STATS_INC(mib2.tcpfinackcnt); 94 tcp_clear_flags(pcb, TF_CLOSEPEND); 95 tcp_close_shutdown_fin(pcb); 96 } 97@@ -1707,6 +1710,7 @@ tcp_fasttmr_start: 98 /* If there is data which was previously "refused" by upper layer */ 99 if (pcb->refused_data != NULL) { 100 tcp_active_pcbs_changed = 0; 101+ MIB2_STATS_INC(mib2.tcpredusedcnt); 102 tcp_process_refused_data(pcb); 103 if (tcp_active_pcbs_changed) { 104 /* application callback has changed the pcb list: restart the loop */ 105diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h 106index 4470531..5953a74 100644 107--- a/src/include/lwip/stats.h 108+++ b/src/include/lwip/stats.h 109@@ -150,6 +150,9 @@ struct stats_mib2 { 110 u32_t tcpinsegs; 111 u32_t tcpinerrs; 112 u32_t tcpoutrsts; 113+ u32_t tcpfinackcnt; 114+ u32_t tcpdelayackcnt; 115+ u32_t tcpredusedcnt; 116 117 /* UDP */ 118 u32_t udpindatagrams; 119diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h 120index 06b3ae5..5fe647f 100644 121--- a/src/include/lwipopts.h 122+++ b/src/include/lwipopts.h 123@@ -269,6 +269,9 @@ 124 #define LWIP_DEBUG 1 125 126 #define GAZELLE_DEBUG LWIP_DBG_ON 127+#define GAZELLE_DEBUG_WARNING (LWIP_DBG_ON | LWIP_DBG_LEVEL_WARNING) 128+#define GAZELLE_DEBUG_SERIOUS (LWIP_DBG_ON | LWIP_DBG_LEVEL_SERIOUS) 129+#define GAZELLE_DEBUG_SEVERE (LWIP_DBG_ON | LWIP_DBG_LEVEL_SEVERE) 130 131 /* 132 ------------------------------------ 133-- 1342.33.0 135 136