From f2080c02b864d6ce7f07b874e489bb5ea98b837a Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Wed, 6 Dec 2023 20:33:13 +0800
Subject: [PATCH] dfx: fix 'gazellectl lstack show ip' failed

---
 src/common/gazelle_dfx_msg.h | 3 ++-
 src/ltran/ltran_dfx.c        | 7 +++++--
 src/ltran/ltran_monitor.c    | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h
index ac6ea5e..d2c6ef9 100644
--- a/src/common/gazelle_dfx_msg.h
+++ b/src/common/gazelle_dfx_msg.h
@@ -35,9 +35,10 @@ enum GAZELLE_STAT_MODE {
     GAZELLE_STAT_LTRAN_LOG_LEVEL_SET,
     GAZELLE_STAT_LTRAN_SHOW_SOCKTABLE,
     GAZELLE_STAT_LTRAN_SHOW_CONNTABLE,
+    GAZELLE_STAT_LTRAN_SHOW_LSTACK,
 
-    GAZELLE_STAT_LSTACK_LOG_LEVEL_SET,
     GAZELLE_STAT_LSTACK_SHOW,
+    GAZELLE_STAT_LSTACK_LOG_LEVEL_SET,
     GAZELLE_STAT_LSTACK_SHOW_RATE,
     GAZELLE_STAT_LSTACK_SHOW_SNMP,
     GAZELLE_STAT_LSTACK_SHOW_CONN,
diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c
index d3ff527..c200b1d 100644
--- a/src/ltran/ltran_dfx.c
+++ b/src/ltran/ltran_dfx.c
@@ -105,8 +105,11 @@ static struct gazelle_dfx_list g_gazelle_dfx_tbl[] = {
     {GAZELLE_STAT_LTRAN_LOG_LEVEL_SET, 0,                                       gazelle_print_ltran_wait},
     {GAZELLE_STAT_LTRAN_SHOW_SOCKTABLE, sizeof(struct gazelle_stat_forward_table), gazelle_print_ltran_sock},
     {GAZELLE_STAT_LTRAN_SHOW_CONNTABLE, sizeof(struct gazelle_stat_forward_table), gazelle_print_ltran_conn},
+
+    {GAZELLE_STAT_LTRAN_SHOW_LSTACK,   sizeof(struct gazelle_stat_lstack_total), gazelle_print_lstack_stat_total},
+    {GAZELLE_STAT_LSTACK_SHOW,         sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_stat_total},
+
     {GAZELLE_STAT_LSTACK_LOG_LEVEL_SET, 0,                                      gazelle_print_ltran_wait},
-    {GAZELLE_STAT_LSTACK_SHOW,         sizeof(struct gazelle_stat_lstack_total), gazelle_print_lstack_stat_total},
     {GAZELLE_STAT_LSTACK_SHOW_RATE,    sizeof(struct gazelle_stack_dfx_data), gazelle_print_lstack_stat_rate},
     {GAZELLE_STAT_LSTACK_SHOW_SNMP,    sizeof(struct gazelle_stack_dfx_data),  gazelle_print_lstack_stat_snmp},
     {GAZELLE_STAT_LSTACK_SHOW_CONN,    sizeof(struct gazelle_stack_dfx_data),  gazelle_print_lstack_stat_conn},
@@ -1265,7 +1268,7 @@ static int32_t parse_dfx_lstack_show_args(int32_t argc, char *argv[], struct gaz
     long int delay = 1;
 
     if (argc == GAZELLE_LSTACK_PARAM_NUM) {
-        req_msg[cmd_index++].stat_mode = GAZELLE_STAT_LSTACK_SHOW;
+        req_msg[cmd_index++].stat_mode = g_use_ltran ? GAZELLE_STAT_LTRAN_SHOW_LSTACK : GAZELLE_STAT_LSTACK_SHOW;
         return cmd_index;
     }
 
diff --git a/src/ltran/ltran_monitor.c b/src/ltran/ltran_monitor.c
index 792db89..b2bcc07 100644
--- a/src/ltran/ltran_monitor.c
+++ b/src/ltran/ltran_monitor.c
@@ -338,7 +338,7 @@ static int32_t lstack_req_mode_process(int32_t fd, const struct gazelle_stat_msg
         case GAZELLE_STAT_LTRAN_SHOW_LB_RATE:
             handle_resp_lstack_total(req_msg, fd);
             break;
-        case GAZELLE_STAT_LSTACK_SHOW:
+        case GAZELLE_STAT_LTRAN_SHOW_LSTACK:
             handle_resp_lstack_total(req_msg, fd);
             handle_resp_lstack_transfer(req_msg, fd);
             break;
-- 
2.27.0

