1195972f6Sopenharmony_ciFrom d7b0ffc7604075639f3eedbfe63fc0f12b87d23f Mon Sep 17 00:00:00 2001 2195972f6Sopenharmony_ciFrom: jiangheng <jiangheng14@huawei.com> 3195972f6Sopenharmony_ciDate: Tue, 28 Nov 2023 16:34:16 +0800 4195972f6Sopenharmony_ciSubject: [PATCH] log: add errevent log and tcp exception statistics 5195972f6Sopenharmony_ci 6195972f6Sopenharmony_ci--- 7195972f6Sopenharmony_ci src/api/api_msg.c | 1 + 8195972f6Sopenharmony_ci src/api/sockets.c | 3 ++- 9195972f6Sopenharmony_ci src/core/tcp_in.c | 2 ++ 10195972f6Sopenharmony_ci src/include/lwip/stats.h | 3 +++ 11195972f6Sopenharmony_ci 4 files changed, 8 insertions(+), 1 deletion(-) 12195972f6Sopenharmony_ci 13195972f6Sopenharmony_cidiff --git a/src/api/api_msg.c b/src/api/api_msg.c 14195972f6Sopenharmony_ciindex 8d98be6..531da40 100644 15195972f6Sopenharmony_ci--- a/src/api/api_msg.c 16195972f6Sopenharmony_ci+++ b/src/api/api_msg.c 17195972f6Sopenharmony_ci@@ -613,6 +613,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) 18195972f6Sopenharmony_ci sys_mbox_free(&newconn->recvmbox); 19195972f6Sopenharmony_ci sys_mbox_set_invalid(&newconn->recvmbox); 20195972f6Sopenharmony_ci netconn_free(newconn); 21195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcpacceptmboxfull); 22195972f6Sopenharmony_ci return ERR_MEM; 23195972f6Sopenharmony_ci } else { 24195972f6Sopenharmony_ci /* Register event with callback */ 25195972f6Sopenharmony_cidiff --git a/src/api/sockets.c b/src/api/sockets.c 26195972f6Sopenharmony_ciindex 62052f2..65c69d4 100644 27195972f6Sopenharmony_ci--- a/src/api/sockets.c 28195972f6Sopenharmony_ci+++ b/src/api/sockets.c 29195972f6Sopenharmony_ci@@ -2797,9 +2797,10 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) 30195972f6Sopenharmony_ci #endif 31195972f6Sopenharmony_ci break; 32195972f6Sopenharmony_ci case NETCONN_EVT_ERROR: 33195972f6Sopenharmony_ci+ LWIP_DEBUGF(GAZELLE_DEBUG_SERIOUS, ("event_callback: have errevent, err=%d\n", conn->pending_err)); 34195972f6Sopenharmony_ci sock->errevent = 1; 35195972f6Sopenharmony_ci #if GAZELLE_ENABLE 36195972f6Sopenharmony_ci- if (netif_is_rtc_mode(netif_default)) { 37195972f6Sopenharmony_ci+ if (netif_is_rtc_mode(netif_default)) { 38195972f6Sopenharmony_ci add_sock_event_nolock(sock, EPOLLERR); 39195972f6Sopenharmony_ci } else { 40195972f6Sopenharmony_ci add_sock_event(sock, EPOLLERR); 41195972f6Sopenharmony_cidiff --git a/src/core/tcp_in.c b/src/core/tcp_in.c 42195972f6Sopenharmony_ciindex 1076f20..03b9942 100644 43195972f6Sopenharmony_ci--- a/src/core/tcp_in.c 44195972f6Sopenharmony_ci+++ b/src/core/tcp_in.c 45195972f6Sopenharmony_ci@@ -770,6 +770,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb) 46195972f6Sopenharmony_ci #if TCP_LISTEN_BACKLOG 47195972f6Sopenharmony_ci if (pcb->accepts_pending >= pcb->backlog) { 48195972f6Sopenharmony_ci LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest)); 49195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcplistendrops); 50195972f6Sopenharmony_ci return; 51195972f6Sopenharmony_ci } 52195972f6Sopenharmony_ci #endif /* TCP_LISTEN_BACKLOG */ 53195972f6Sopenharmony_ci@@ -1845,6 +1846,7 @@ tcp_receive(struct tcp_pcb *pcb) 54195972f6Sopenharmony_ci 55195972f6Sopenharmony_ci } else { 56195972f6Sopenharmony_ci /* We get here if the incoming segment is out-of-sequence. */ 57195972f6Sopenharmony_ci+ MIB2_STATS_INC(mib2.tcpoutofseq); 58195972f6Sopenharmony_ci 59195972f6Sopenharmony_ci #if TCP_QUEUE_OOSEQ 60195972f6Sopenharmony_ci /* We queue the segment on the ->ooseq queue. */ 61195972f6Sopenharmony_cidiff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h 62195972f6Sopenharmony_ciindex 5953a74..805836c 100644 63195972f6Sopenharmony_ci--- a/src/include/lwip/stats.h 64195972f6Sopenharmony_ci+++ b/src/include/lwip/stats.h 65195972f6Sopenharmony_ci@@ -153,6 +153,9 @@ struct stats_mib2 { 66195972f6Sopenharmony_ci u32_t tcpfinackcnt; 67195972f6Sopenharmony_ci u32_t tcpdelayackcnt; 68195972f6Sopenharmony_ci u32_t tcpredusedcnt; 69195972f6Sopenharmony_ci+ u32_t tcpoutofseq; 70195972f6Sopenharmony_ci+ u32_t tcpacceptmboxfull; 71195972f6Sopenharmony_ci+ u32_t tcplistendrops; 72195972f6Sopenharmony_ci 73195972f6Sopenharmony_ci /* UDP */ 74195972f6Sopenharmony_ci u32_t udpindatagrams; 75195972f6Sopenharmony_ci-- 76195972f6Sopenharmony_ci2.27.0 77195972f6Sopenharmony_ci 78