From db89062f34f8bcccf80a82d6589e5f3b5bc63cfe Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Sat, 13 Jan 2024 17:03:07 +0800
Subject: [PATCH] diff lstack and ltran dfx sock

---
 src/common/gazelle_opt.h     |  9 +++++++--
 src/lstack/core/lstack_cfg.c | 10 ++++++++--
 src/ltran/ltran_base.h       |  3 ---
 src/ltran/ltran_dfx.c        |  8 ++++----
 src/ltran/ltran_monitor.c    |  8 ++++----
 src/ltran/ltran_param.c      |  4 ++--
 6 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
index 36915c6..1d1c5f5 100644
--- a/src/common/gazelle_opt.h
+++ b/src/common/gazelle_opt.h
@@ -85,8 +85,13 @@
 
 #define GAZELLE_MAX_STACK_ARRAY_SIZE    GAZELLE_CLIENT_NUM
 
-#define GAZELLE_REG_SOCK_PATHNAME       "/var/run/gazelle/gazelle_client.sock"
-#define GAZELLE_REG_SOCK_FILENAME       "gazelle_client.sock"
+#define LTRAN_REG_SOCK_PATHNAME       "/var/run/gazelle/ltran_client.sock"
+#define LTRAN_REG_SOCK_FILENAME       "ltran_client.sock"
+#define LTRAN_DFX_SOCK_PATHNAME       "/var/run/gazelle/ltran_cmd.sock"
+#define LTRAN_DFX_SOCK_FILENAME       "ltran_cmd.sock"
+#define LSTACK_DFX_SOCK_PATHNAME       "/var/run/gazelle/lstack_cmd.sock"
+#define LSTACK_DFX_SOCK_FILENAME       "lstack_cmd.sock"
+
 #define GAZELLE_SOCK_FILENAME_MAXLEN    128
 
 #define GAZELLE_RUN_DIR                  "/var/run/gazelle/"
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
index c1f5680..87df790 100644
--- a/src/lstack/core/lstack_cfg.c
+++ b/src/lstack/core/lstack_cfg.c
@@ -1043,8 +1043,14 @@ static int32_t parse_unix_prefix(void)
         }
     }
 
-    ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
-            GAZELLE_REG_SOCK_FILENAME, strlen(GAZELLE_REG_SOCK_FILENAME) + 1);
+    if (g_config_params.use_ltran) {
+        ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
+                LTRAN_REG_SOCK_FILENAME, strlen(LTRAN_REG_SOCK_FILENAME) + 1);
+    } else {
+        ret = strncat_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
+                LSTACK_DFX_SOCK_FILENAME, strlen(LSTACK_DFX_SOCK_FILENAME) + 1);
+    }
+
     if (ret != EOK) {
         return ret;
     }
diff --git a/src/ltran/ltran_base.h b/src/ltran/ltran_base.h
index 6be9152..f174a40 100644
--- a/src/ltran/ltran_base.h
+++ b/src/ltran/ltran_base.h
@@ -98,7 +98,4 @@
 
 #define GAZELLE_INET_ADDRSTRLEN                         16
 
-#define GAZELLE_DFX_SOCK_PATHNAME                       "/var/run/gazelle/gazelle_cmd.sock"
-#define GAZELLE_DFX_SOCK_FILENAME                       "gazelle_cmd.sock"
-
 #endif /* ifndef __GAZELLE_BASE_H__ */
diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c
index a64c1d5..05234de 100644
--- a/src/ltran/ltran_dfx.c
+++ b/src/ltran/ltran_dfx.c
@@ -254,15 +254,15 @@ static int32_t dfx_connect_ltran(bool use_ltran, bool probe)
 
     addr.sun_family = AF_UNIX;
     if (use_ltran) {
-        ret = strncat_s(addr.sun_path, sizeof(addr.sun_path), GAZELLE_DFX_SOCK_FILENAME,
-            strlen(GAZELLE_DFX_SOCK_FILENAME) + 1);
+        ret = strncat_s(addr.sun_path, sizeof(addr.sun_path), LTRAN_DFX_SOCK_FILENAME,
+            strlen(LTRAN_DFX_SOCK_FILENAME) + 1);
         if (ret != EOK) {
             printf("%s:%d strncat_s fail ret=%d\n", __FUNCTION__, __LINE__, ret);
             goto END;
         }
     } else {
-        ret = strncat_s(addr.sun_path, sizeof(addr.sun_path), GAZELLE_REG_SOCK_FILENAME,
-            strlen(GAZELLE_REG_SOCK_FILENAME) + 1);
+        ret = strncat_s(addr.sun_path, sizeof(addr.sun_path), LSTACK_DFX_SOCK_FILENAME,
+            strlen(LSTACK_DFX_SOCK_FILENAME) + 1);
         if (ret != EOK) {
             printf("%s:%d strncat_s fail ret=%d\n", __FUNCTION__, __LINE__, ret);
             goto END;
diff --git a/src/ltran/ltran_monitor.c b/src/ltran/ltran_monitor.c
index b2bcc07..ea31e84 100644
--- a/src/ltran/ltran_monitor.c
+++ b/src/ltran/ltran_monitor.c
@@ -238,13 +238,13 @@ static void gazelle_ctl_destroy(void)
     close(g_epoll_fd);
     g_epoll_fd = -1;
 
-    ret = unlink(GAZELLE_DFX_SOCK_PATHNAME);
+    ret = unlink(LTRAN_DFX_SOCK_PATHNAME);
     if (ret != 0) {
-        LTRAN_WARN("unlink %s ERROR. errno: %d. ret=%d\n", GAZELLE_DFX_SOCK_PATHNAME, errno, ret);
+        LTRAN_WARN("unlink %s ERROR. errno: %d. ret=%d\n", LTRAN_DFX_SOCK_PATHNAME, errno, ret);
     }
-    ret = unlink(GAZELLE_REG_SOCK_PATHNAME);
+    ret = unlink(LTRAN_REG_SOCK_PATHNAME);
     if (ret != 0) {
-        LTRAN_WARN("unlink %s ERROR. errno: %d. ret=%d\n", GAZELLE_REG_SOCK_PATHNAME, errno, ret);
+        LTRAN_WARN("unlink %s ERROR. errno: %d. ret=%d\n", LTRAN_REG_SOCK_PATHNAME, errno, ret);
     }
 }
 
diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c
index 1eaace4..bd5a8e1 100644
--- a/src/ltran/ltran_param.c
+++ b/src/ltran/ltran_param.c
@@ -598,14 +598,14 @@ static int32_t parse_unix_prefix(const config_t *config, const char *key, struct
     }
 
     ret = strncat_s(ltran_config->unix_socket_filename, sizeof(ltran_config->unix_socket_filename),
-        GAZELLE_REG_SOCK_FILENAME, strlen(GAZELLE_REG_SOCK_FILENAME) + 1);
+        LTRAN_REG_SOCK_FILENAME, strlen(LTRAN_REG_SOCK_FILENAME) + 1);
     if (ret != EOK) {
         gazelle_set_errno(GAZELLE_EINETATON);
         return GAZELLE_ERR;
     }
 
     ret = strncat_s(ltran_config->dfx_socket_filename, sizeof(ltran_config->dfx_socket_filename),
-        GAZELLE_DFX_SOCK_FILENAME, strlen(GAZELLE_DFX_SOCK_FILENAME) + 1);
+        LTRAN_DFX_SOCK_FILENAME, strlen(LTRAN_DFX_SOCK_FILENAME) + 1);
     if (ret != EOK) {
         gazelle_set_errno(GAZELLE_EINETATON);
         return GAZELLE_ERR;
-- 
2.33.0

