1195972f6Sopenharmony_ciFrom d0edabb1ebfe0cc1f32e91834589b16b209dcfc9 Mon Sep 17 00:00:00 2001 2195972f6Sopenharmony_ciFrom: hantwofish <hankangkang5@huawei.com> 3195972f6Sopenharmony_ciDate: Tue, 28 Nov 2023 04:34:02 +0800 4195972f6Sopenharmony_ciSubject: [PATCH] add tcpslowtmr log and tcpfasttmr cnt 5195972f6Sopenharmony_ci 6195972f6Sopenharmony_ci--- 7195972f6Sopenharmony_ci src/core/tcp.c | 18 +++++++++++------- 8195972f6Sopenharmony_ci src/include/lwip/stats.h | 3 +++ 9195972f6Sopenharmony_ci src/include/lwipopts.h | 3 +++ 10195972f6Sopenharmony_ci 3 files changed, 17 insertions(+), 7 deletions(-) 11195972f6Sopenharmony_ci 12195972f6Sopenharmony_cidiff --git a/src/core/tcp.c b/src/core/tcp.c 13195972f6Sopenharmony_ciindex 9f1e636..c1b64a3 100644 14195972f6Sopenharmony_ci--- a/src/core/tcp.c 15195972f6Sopenharmony_ci+++ b/src/core/tcp.c 16195972f6Sopenharmony_ci@@ -1393,16 +1393,17 @@ tcp_slowtmr_start: 17195972f6Sopenharmony_ci 18195972f6Sopenharmony_ci if (pcb->state == SYN_SENT && pcb->nrtx >= TCP_SYNMAXRTX) { 19195972f6Sopenharmony_ci ++pcb_remove; 20195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); 21195972f6Sopenharmony_ci+ 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)); 22195972f6Sopenharmony_ci } else if (pcb->nrtx >= TCP_MAXRTX) { 23195972f6Sopenharmony_ci ++pcb_remove; 24195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); 25195972f6Sopenharmony_ci+ 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)); 26195972f6Sopenharmony_ci } else { 27195972f6Sopenharmony_ci if (pcb->persist_backoff > 0) { 28195972f6Sopenharmony_ci LWIP_ASSERT("tcp_slowtimr: persist ticking with in-flight data", pcb->unacked == NULL); 29195972f6Sopenharmony_ci LWIP_ASSERT("tcp_slowtimr: persist ticking with empty send buffer", pcb->unsent != NULL); 30195972f6Sopenharmony_ci if (pcb->persist_probe >= TCP_MAXRTX) { 31195972f6Sopenharmony_ci ++pcb_remove; /* max probes reached */ 32195972f6Sopenharmony_ci+ 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)); 33195972f6Sopenharmony_ci } else { 34195972f6Sopenharmony_ci u8_t backoff_cnt = tcp_persist_backoff[pcb->persist_backoff - 1]; 35195972f6Sopenharmony_ci if (pcb->persist_cnt < backoff_cnt) { 36195972f6Sopenharmony_ci@@ -1486,7 +1487,7 @@ tcp_slowtmr_start: 37195972f6Sopenharmony_ci if ((u32_t)(tcp_ticks - pcb->tmr) > 38195972f6Sopenharmony_ci TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { 39195972f6Sopenharmony_ci ++pcb_remove; 40195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); 41195972f6Sopenharmony_ci+ 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)); 42195972f6Sopenharmony_ci } 43195972f6Sopenharmony_ci } 44195972f6Sopenharmony_ci } 45195972f6Sopenharmony_ci@@ -1497,7 +1498,7 @@ tcp_slowtmr_start: 46195972f6Sopenharmony_ci (pcb->state == CLOSE_WAIT))) { 47195972f6Sopenharmony_ci if ((u32_t)(tcp_ticks - pcb->tmr) > 48195972f6Sopenharmony_ci (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) { 49195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to ")); 50195972f6Sopenharmony_ci+ 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)); 51195972f6Sopenharmony_ci ip_addr_debug_print_val(TCP_DEBUG, pcb->remote_ip); 52195972f6Sopenharmony_ci LWIP_DEBUGF(TCP_DEBUG, ("\n")); 53195972f6Sopenharmony_ci 54195972f6Sopenharmony_ci@@ -1519,7 +1520,7 @@ tcp_slowtmr_start: 55195972f6Sopenharmony_ci #if TCP_QUEUE_OOSEQ 56195972f6Sopenharmony_ci if (pcb->ooseq != NULL && 57195972f6Sopenharmony_ci (tcp_ticks - pcb->tmr >= (u32_t)pcb->rto * TCP_OOSEQ_TIMEOUT)) { 58195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); 59195972f6Sopenharmony_ci+ 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)); 60195972f6Sopenharmony_ci tcp_free_ooseq(pcb); 61195972f6Sopenharmony_ci } 62195972f6Sopenharmony_ci #endif /* TCP_QUEUE_OOSEQ */ 63195972f6Sopenharmony_ci@@ -1529,7 +1530,7 @@ tcp_slowtmr_start: 64195972f6Sopenharmony_ci if ((u32_t)(tcp_ticks - pcb->tmr) > 65195972f6Sopenharmony_ci TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { 66195972f6Sopenharmony_ci ++pcb_remove; 67195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); 68195972f6Sopenharmony_ci+ 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)); 69195972f6Sopenharmony_ci } 70195972f6Sopenharmony_ci } 71195972f6Sopenharmony_ci 72195972f6Sopenharmony_ci@@ -1537,7 +1538,7 @@ tcp_slowtmr_start: 73195972f6Sopenharmony_ci if (pcb->state == LAST_ACK) { 74195972f6Sopenharmony_ci if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { 75195972f6Sopenharmony_ci ++pcb_remove; 76195972f6Sopenharmony_ci- LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n")); 77195972f6Sopenharmony_ci+ 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)); 78195972f6Sopenharmony_ci } 79195972f6Sopenharmony_ci } 80195972f6Sopenharmony_ci 81195972f6Sopenharmony_ci@@ -1691,6 +1692,7 @@ tcp_fasttmr_start: 82195972f6Sopenharmony_ci /* send delayed ACKs */ 83195972f6Sopenharmony_ci if (pcb->flags & TF_ACK_DELAY) { 84195972f6Sopenharmony_ci LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); 85195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcpdelayackcnt); 86195972f6Sopenharmony_ci tcp_ack_now(pcb); 87195972f6Sopenharmony_ci tcp_output(pcb); 88195972f6Sopenharmony_ci tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW); 89195972f6Sopenharmony_ci@@ -1698,6 +1700,7 @@ tcp_fasttmr_start: 90195972f6Sopenharmony_ci /* send pending FIN */ 91195972f6Sopenharmony_ci if (pcb->flags & TF_CLOSEPEND) { 92195972f6Sopenharmony_ci LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: pending FIN\n")); 93195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcpfinackcnt); 94195972f6Sopenharmony_ci tcp_clear_flags(pcb, TF_CLOSEPEND); 95195972f6Sopenharmony_ci tcp_close_shutdown_fin(pcb); 96195972f6Sopenharmony_ci } 97195972f6Sopenharmony_ci@@ -1707,6 +1710,7 @@ tcp_fasttmr_start: 98195972f6Sopenharmony_ci /* If there is data which was previously "refused" by upper layer */ 99195972f6Sopenharmony_ci if (pcb->refused_data != NULL) { 100195972f6Sopenharmony_ci tcp_active_pcbs_changed = 0; 101195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcpredusedcnt); 102195972f6Sopenharmony_ci tcp_process_refused_data(pcb); 103195972f6Sopenharmony_ci if (tcp_active_pcbs_changed) { 104195972f6Sopenharmony_ci /* application callback has changed the pcb list: restart the loop */ 105195972f6Sopenharmony_cidiff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h 106195972f6Sopenharmony_ciindex 4470531..5953a74 100644 107195972f6Sopenharmony_ci--- a/src/include/lwip/stats.h 108195972f6Sopenharmony_ci+++ b/src/include/lwip/stats.h 109195972f6Sopenharmony_ci@@ -150,6 +150,9 @@ struct stats_mib2 { 110195972f6Sopenharmony_ci u32_t tcpinsegs; 111195972f6Sopenharmony_ci u32_t tcpinerrs; 112195972f6Sopenharmony_ci u32_t tcpoutrsts; 113195972f6Sopenharmony_ci+ u32_t tcpfinackcnt; 114195972f6Sopenharmony_ci+ u32_t tcpdelayackcnt; 115195972f6Sopenharmony_ci+ u32_t tcpredusedcnt; 116195972f6Sopenharmony_ci 117195972f6Sopenharmony_ci /* UDP */ 118195972f6Sopenharmony_ci u32_t udpindatagrams; 119195972f6Sopenharmony_cidiff --git a/src/include/lwipopts.h b/src/include/lwipopts.h 120195972f6Sopenharmony_ciindex 06b3ae5..5fe647f 100644 121195972f6Sopenharmony_ci--- a/src/include/lwipopts.h 122195972f6Sopenharmony_ci+++ b/src/include/lwipopts.h 123195972f6Sopenharmony_ci@@ -269,6 +269,9 @@ 124195972f6Sopenharmony_ci #define LWIP_DEBUG 1 125195972f6Sopenharmony_ci 126195972f6Sopenharmony_ci #define GAZELLE_DEBUG LWIP_DBG_ON 127195972f6Sopenharmony_ci+#define GAZELLE_DEBUG_WARNING (LWIP_DBG_ON | LWIP_DBG_LEVEL_WARNING) 128195972f6Sopenharmony_ci+#define GAZELLE_DEBUG_SERIOUS (LWIP_DBG_ON | LWIP_DBG_LEVEL_SERIOUS) 129195972f6Sopenharmony_ci+#define GAZELLE_DEBUG_SEVERE (LWIP_DBG_ON | LWIP_DBG_LEVEL_SEVERE) 130195972f6Sopenharmony_ci 131195972f6Sopenharmony_ci /* 132195972f6Sopenharmony_ci ------------------------------------ 133195972f6Sopenharmony_ci-- 134195972f6Sopenharmony_ci2.33.0 135195972f6Sopenharmony_ci 136