From 0093be5afee0264c669111a0137a580b2c314b6c Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Wed, 18 Sep 2024 15:24:17 +0800
Subject: [PATCH] DFX: adapt log optimization

---
 src/common/gazelle_dfx_msg.h            | 8 ++++++++
 src/lstack/core/lstack_protocol_stack.c | 2 --
 src/ltran/ltran_dfx.c                   | 7 +++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h
index 8eb54ff..08f9df1 100644
--- a/src/common/gazelle_dfx_msg.h
+++ b/src/common/gazelle_dfx_msg.h
@@ -195,6 +195,14 @@ struct gazelle_stat_lstack_snmp {
     uint32_t tcp_acceptmbox_full;
     uint32_t tcp_listen_drops;
     uint32_t tcp_in_empty_acks;
+    /* GAZELLE TCP */
+    uint32_t tcp_rst_in_keepalive_timeout;
+    uint32_t tcp_rst_wrong_syn_in_timewait;
+    uint32_t tcp_rst_wrong_ack_in_syn_rcvd;
+    uint32_t tcp_ooseq_data_drop;
+    uint32_t tcp_free_pcb_in_syn_maxrtx;
+    uint32_t tcp_free_pcb_in_maxrtx;
+    uint32_t tcp_alloc_pcb_fails;
 
     /* UDP */
     uint32_t udp_in_datagrams;
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 49b3ec8..00900e7 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -886,7 +886,6 @@ void stack_tcp_send(struct rpc_msg *msg)
     struct lwip_sock *sock = lwip_get_socket(fd);
     if (POSIX_IS_CLOSED(sock)) {
         msg->result = -1;
-        LSTACK_LOG(ERR, LSTACK, "get sock error! fd=%d, len=%ld\n", fd, len);
         return;
     }
 
@@ -922,7 +921,6 @@ void stack_udp_send(struct rpc_msg *msg)
     struct lwip_sock *sock = lwip_get_socket(fd);
     if (POSIX_IS_CLOSED(sock)) {
         msg->result = -1;
-        LSTACK_LOG(ERR, LSTACK, "get sock error! fd=%d, len=%ld\n", fd, len);
         return;
     }
 
diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c
index 9815009..fc30054 100644
--- a/src/ltran/ltran_dfx.c
+++ b/src/ltran/ltran_dfx.c
@@ -1005,6 +1005,13 @@ static void gazelle_print_lstack_tcp_stat(const struct gazelle_stat_lstack_snmp
     printf("tcp_acceptmbox_full: %u\n",  snmp->tcp_acceptmbox_full);
     printf("tcp_listen_drops: %u\n",     snmp->tcp_listen_drops);
     printf("tcp_in_empty_acks: %u\n",    snmp->tcp_in_empty_acks);
+    printf("tcp_rst_in_keepalive_timeout: %u\n",   snmp->tcp_rst_in_keepalive_timeout);
+    printf("tcp_rst_wrong_syn_in_timewait: %u\n",  snmp->tcp_rst_wrong_syn_in_timewait);
+    printf("tcp_rst_wrong_ack_in_syn_rcvd: %u\n",  snmp->tcp_rst_wrong_ack_in_syn_rcvd);
+    printf("tcp_ooseq_data_drop: %u\n",            snmp->tcp_ooseq_data_drop);
+    printf("tcp_free_pcb_in_syn_maxrtx: %u\n",     snmp->tcp_free_pcb_in_syn_maxrtx);
+    printf("tcp_free_pcb_in_maxrtx: %u\n",         snmp->tcp_free_pcb_in_maxrtx);
+    printf("tcp_alloc_pcb_fails: %u\n",            snmp->tcp_alloc_pcb_fails);
 }
 
 static void gazelle_print_ltran_stat_lb_rate(void *buf, const struct gazelle_stat_msg_request *req_msg)
-- 
2.33.0

