1From d7b0ffc7604075639f3eedbfe63fc0f12b87d23f Mon Sep 17 00:00:00 2001 2From: jiangheng <jiangheng14@huawei.com> 3Date: Tue, 28 Nov 2023 16:34:16 +0800 4Subject: [PATCH] log: add errevent log and tcp exception statistics 5 6--- 7 src/api/api_msg.c | 1 + 8 src/api/sockets.c | 3 ++- 9 src/core/tcp_in.c | 2 ++ 10 src/include/lwip/stats.h | 3 +++ 11 4 files changed, 8 insertions(+), 1 deletion(-) 12 13diff --git a/src/api/api_msg.c b/src/api/api_msg.c 14index 8d98be6..531da40 100644 15--- a/src/api/api_msg.c 16+++ b/src/api/api_msg.c 17@@ -613,6 +613,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) 18 sys_mbox_free(&newconn->recvmbox); 19 sys_mbox_set_invalid(&newconn->recvmbox); 20 netconn_free(newconn); 21+ MIB2_STATS_INC(mib2.tcpacceptmboxfull); 22 return ERR_MEM; 23 } else { 24 /* Register event with callback */ 25diff --git a/src/api/sockets.c b/src/api/sockets.c 26index 62052f2..65c69d4 100644 27--- a/src/api/sockets.c 28+++ b/src/api/sockets.c 29@@ -2797,9 +2797,10 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) 30 #endif 31 break; 32 case NETCONN_EVT_ERROR: 33+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d\n", conn->pending_err)); 34 sock->errevent = 1; 35 #if GAZELLE_ENABLE 36- if (netif_is_rtc_mode(netif_default)) { 37+ if (netif_is_rtc_mode(netif_default)) { 38 add_sock_event_nolock(sock, EPOLLERR); 39 } else { 40 add_sock_event(sock, EPOLLERR); 41diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c 42index 1076f20..03b9942 100644 43--- a/src/core/tcp_in.c 44+++ b/src/core/tcp_in.c 45@@ -770,6 +770,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) 46 #if TCP_LISTEN_BACKLOG 47 if (pcb->accepts_pending >= pcb->backlog) { 48 LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest)); 49+ MIB2_STATS_INC(mib2.tcplistendrops); 50 return; 51 } 52 #endif /* TCP_LISTEN_BACKLOG */ 53@@ -1845,6 +1846,7 @@ tcp_receive(struct tcp_pcb *pcb) 54 55 } else { 56 /* We get here if the incoming segment is out-of-sequence. */ 57+ MIB2_STATS_INC(mib2.tcpoutofseq); 58 59 #if TCP_QUEUE_OOSEQ 60 /* We queue the segment on the ->ooseq queue. */ 61diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h 62index 5953a74..805836c 100644 63--- a/src/include/lwip/stats.h 64+++ b/src/include/lwip/stats.h 65@@ -153,6 +153,9 @@ struct stats_mib2 { 66 u32_t tcpfinackcnt; 67 u32_t tcpdelayackcnt; 68 u32_t tcpredusedcnt; 69+ u32_t tcpoutofseq; 70+ u32_t tcpacceptmboxfull; 71+ u32_t tcplistendrops; 72 73 /* UDP */ 74 u32_t udpindatagrams; 75-- 762.27.0 77 78