diff --git a/0003-set-localhost-ip-when-bind-ip-is-same-as-ip-in-lstac.patch b/0003-set-localhost-ip-when-bind-ip-is-same-as-ip-in-lstac.patch new file mode 100644 index 0000000..f89791e --- /dev/null +++ b/0003-set-localhost-ip-when-bind-ip-is-same-as-ip-in-lstac.patch @@ -0,0 +1,27 @@ +From c13dd0c6ae71dd7547b9c1c6240585ae0f5c7c6b Mon Sep 17 00:00:00 2001 +From: chengyechun +Date: Tue, 11 Jul 2023 10:57:35 +0800 +Subject: [PATCH] set localhost ip when bind ip is same as ip in lstack.conf + +--- + src/lstack/api/lstack_wrap.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 6a1a2c4..956d661 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -245,6 +245,10 @@ bool is_dst_ip_localhost(const struct sockaddr *addr) + char *p; + size_t linel = 0; + int linenum = 0; ++ if (get_global_cfg_params()->host_addr.addr == servaddr->sin_addr.s_addr) { ++ return true; ++ } ++ + FILE *ifh = fopen("/proc/net/dev", "r"); + if (ifh == NULL) { + LSTACK_LOG(ERR, LSTACK, "failed to open /proc/net/dev, errno is %d\n", errno); +-- +2.23.0 + diff --git a/0004-refactoring-preload-module.patch b/0004-refactoring-preload-module.patch new file mode 100644 index 0000000..4f82116 --- /dev/null +++ b/0004-refactoring-preload-module.patch @@ -0,0 +1,158 @@ +From c2703d07662909f228e7e93ecec585bc4c826449 Mon Sep 17 00:00:00 2001 +From: yanan-rock +Date: Fri, 21 Jul 2023 08:34:53 +0000 +Subject: [PATCH] refactoring preload module + +Signed-off-by: yanan-rock +--- + src/lstack/core/lstack_init.c | 40 +-------------------- + src/lstack/core/lstack_preload.c | 55 +++++++++++++++++++++++++++++ + src/lstack/include/lstack_preload.h | 16 +++++++++ + 3 files changed, 72 insertions(+), 39 deletions(-) + create mode 100644 src/lstack/core/lstack_preload.c + create mode 100644 src/lstack/include/lstack_preload.h + +diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c +index 4fbbc14..53bc541 100644 +--- a/src/lstack/core/lstack_init.c ++++ b/src/lstack/core/lstack_init.c +@@ -46,11 +46,7 @@ + #include "posix/lstack_unistd.h" + #include "gazelle_base_func.h" + #include "lstack_protocol_stack.h" +- +-#define LSTACK_PRELOAD_ENV_SYS "LD_PRELOAD" +-#define LSTACK_SO_NAME "liblstack.so" +-#define LSTACK_PRELOAD_NAME_LEN PATH_MAX +-#define LSTACK_PRELOAD_ENV_PROC "GAZELLE_BIND_PROCNAME" ++#include "lstack_preload.h" + + static volatile bool g_init_fail = false; + +@@ -64,40 +60,6 @@ bool get_init_fail(void) + return g_init_fail; + } + +-struct lstack_preload { +- int32_t preload_switch; +- char env_procname[LSTACK_PRELOAD_NAME_LEN]; +-}; +-static struct lstack_preload g_preload_info = {0}; +- +-static int32_t preload_info_init(void) +-{ +- char *enval = NULL; +- +- g_preload_info.preload_switch = 0; +- +- enval = getenv(LSTACK_PRELOAD_ENV_SYS); +- if (enval == NULL) { +- return 0; +- } +- +- if (strstr(enval, LSTACK_SO_NAME) == NULL) { +- return 0; +- } +- +- enval = getenv(LSTACK_PRELOAD_ENV_PROC); +- if (enval == NULL) { +- return -1; +- } +- if (strcpy_s(g_preload_info.env_procname, LSTACK_PRELOAD_NAME_LEN, enval) != EOK) { +- return -1; +- } +- +- g_preload_info.preload_switch = 1; +- LSTACK_PRE_LOG(LSTACK_INFO, "LD_PRELOAD ok\n"); +- return 0; +-} +- + static void check_process_start(void) + { + if (get_global_cfg_params()->is_primary) { +diff --git a/src/lstack/core/lstack_preload.c b/src/lstack/core/lstack_preload.c +new file mode 100644 +index 0000000..9fc5819 +--- /dev/null ++++ b/src/lstack/core/lstack_preload.c +@@ -0,0 +1,55 @@ ++/* ++* Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. ++* gazelle is licensed under the Mulan PSL v2. ++* You can use this software according to the terms and conditions of the Mulan PSL v2. ++* You may obtain a copy of Mulan PSL v2 at: ++* http://license.coscl.org.cn/MulanPSL2 ++* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++* PURPOSE. ++* See the Mulan PSL v2 for more details. ++*/ ++#include ++#include ++#include ++ ++#include "lstack_preload.h" ++ ++#define LSTACK_PRELOAD_ENV_SYS "LD_PRELOAD" ++#define LSTACK_SO_NAME "liblstack.so" ++#define LSTACK_PRELOAD_NAME_LEN PATH_MAX ++#define LSTACK_PRELOAD_ENV_PROC "GAZELLE_BIND_PROCNAME" ++ ++struct lstack_preload { ++ int32_t preload_switch; ++ char env_procname[LSTACK_PRELOAD_NAME_LEN]; ++}; ++static struct lstack_preload g_preload_info = {0}; ++ ++static int32_t preload_info_init(void) ++{ ++ char *enval = NULL; ++ ++ g_preload_info.preload_switch = 0; ++ ++ enval = getenv(LSTACK_PRELOAD_ENV_SYS); ++ if (enval == NULL) { ++ return 0; ++ } ++ ++ if (strstr(enval, LSTACK_SO_NAME) == NULL) { ++ return 0; ++ } ++ ++ enval = getenv(LSTACK_PRELOAD_ENV_PROC); ++ if (enval == NULL) { ++ return -1; ++ } ++ if (strcpy_s(g_preload_info.env_procname, LSTACK_PRELOAD_NAME_LEN, enval) != EOK) { ++ return -1; ++ } ++ ++ g_preload_info.preload_switch = 1; ++ LSTACK_PRE_LOG(LSTACK_INFO, "LD_PRELOAD ok\n"); ++ return 0; ++} +diff --git a/src/lstack/include/lstack_preload.h b/src/lstack/include/lstack_preload.h +new file mode 100644 +index 0000000..4ba6525 +--- /dev/null ++++ b/src/lstack/include/lstack_preload.h +@@ -0,0 +1,16 @@ ++/* ++* Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. ++* gazelle is licensed under the Mulan PSL v2. ++* You can use this software according to the terms and conditions of the Mulan PSL v2. ++* You may obtain a copy of Mulan PSL v2 at: ++* http://license.coscl.org.cn/MulanPSL2 ++* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR ++* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR ++* PURPOSE. ++* See the Mulan PSL v2 for more details. ++*/ ++#ifndef __LSTACK_PRELOAD_H__ ++#define __LSTACK_PRELOAD_H__ ++ ++int preload_info_init(void); ++#endif +-- +2.23.0 + diff --git a/0005-fix-previous-commit-refactoring-preload-module.patch b/0005-fix-previous-commit-refactoring-preload-module.patch new file mode 100644 index 0000000..5669435 --- /dev/null +++ b/0005-fix-previous-commit-refactoring-preload-module.patch @@ -0,0 +1,99 @@ +From 6a5bb82feba31762f6c977e618bcee47a5f06d26 Mon Sep 17 00:00:00 2001 +From: yanan-rock +Date: Sun, 14 May 2023 15:02:58 -0400 +Subject: [PATCH] fix previous commit "refactoring preload module" + +Signed-off-by: yanan-rock +--- + src/lstack/core/lstack_init.c | 26 -------------------------- + src/lstack/core/lstack_preload.c | 25 ++++++++++++++++++++++++- + 2 files changed, 24 insertions(+), 27 deletions(-) + +diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c +index 53bc541..406a0b8 100644 +--- a/src/lstack/core/lstack_init.c ++++ b/src/lstack/core/lstack_init.c +@@ -118,29 +118,6 @@ static int32_t check_process_conflict(void) + return 0; + } + +-static int32_t check_preload_bind_proc(void) +-{ +- char proc_path[PATH_MAX] = {0}; +- +- if (!g_preload_info.preload_switch) { +- return 0; +- } +- +- if (readlink("/proc/self/exe", proc_path, PATH_MAX - 1) <= 0) { +- return -1; +- } +- +- char *proc_name = strrchr(proc_path, '/'); +- if (!proc_name) { +- return -1; +- } +- +- if (strncmp(++proc_name, g_preload_info.env_procname, PATH_MAX) == 0) { +- return 0; +- } +- return -1; +-} +- + __attribute__((destructor)) void gazelle_network_exit(void) + { + if (posix_api != NULL && !posix_api->ues_posix) { +@@ -262,9 +239,6 @@ __attribute__((constructor)) void gazelle_network_init(void) + if (preload_info_init() < 0) { + return; + } +- if (check_preload_bind_proc() < 0) { +- return; +- } + + /* Read configure from lstack.cfg */ + if (cfg_init() != 0) { +diff --git a/src/lstack/core/lstack_preload.c b/src/lstack/core/lstack_preload.c +index 9fc5819..e04f49b 100644 +--- a/src/lstack/core/lstack_preload.c ++++ b/src/lstack/core/lstack_preload.c +@@ -26,6 +26,29 @@ struct lstack_preload { + }; + static struct lstack_preload g_preload_info = {0}; + ++static int32_t preload_check_bind_proc(void) ++{ ++ char proc_path[PATH_MAX] = {0}; ++ ++ if (!g_preload_info.preload_switch) { ++ return 0; ++ } ++ ++ if (readlink("/proc/self/exe", proc_path, PATH_MAX - 1) <= 0) { ++ return -1; ++ } ++ ++ char *proc_name = strrchr(proc_path, '/'); ++ if (!proc_name) { ++ return -1; ++ } ++ ++ if (strncmp(++proc_name, g_preload_info.env_procname, PATH_MAX) == 0) { ++ return 0; ++ } ++ return -1; ++} ++ + static int32_t preload_info_init(void) + { + char *enval = NULL; +@@ -51,5 +74,5 @@ static int32_t preload_info_init(void) + + g_preload_info.preload_switch = 1; + LSTACK_PRE_LOG(LSTACK_INFO, "LD_PRELOAD ok\n"); +- return 0; ++ return preload_check_bind_proc(); + } +-- +2.23.0 + diff --git a/0006-add-lstack_preload.c-to-makefile.patch b/0006-add-lstack_preload.c-to-makefile.patch new file mode 100644 index 0000000..5788730 --- /dev/null +++ b/0006-add-lstack_preload.c-to-makefile.patch @@ -0,0 +1,49 @@ +From 28cf0ab6a58444ee9e1fa36ce6d5b6aa6f37f5ad Mon Sep 17 00:00:00 2001 +From: yanan-rock +Date: Sun, 14 May 2023 21:47:21 -0400 +Subject: [PATCH] add lstack_preload.c to makefile fix compile failure + +Signed-off-by: yanan-rock +--- + src/lstack/core/dir.mk | 2 +- + src/lstack/core/lstack_preload.c | 5 ++++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/core/dir.mk b/src/lstack/core/dir.mk +index 88c1e08..e2d10a5 100644 +--- a/src/lstack/core/dir.mk ++++ b/src/lstack/core/dir.mk +@@ -8,6 +8,6 @@ + # PURPOSE. + # See the Mulan PSL v2 for more details. + +-SRC = lstack_init.c lstack_cfg.c lstack_dpdk.c lstack_control_plane.c lstack_stack_stat.c lstack_lwip.c lstack_protocol_stack.c lstack_thread_rpc.c ++SRC = lstack_preload.c lstack_init.c lstack_cfg.c lstack_dpdk.c lstack_control_plane.c lstack_stack_stat.c lstack_lwip.c lstack_protocol_stack.c lstack_thread_rpc.c + $(eval $(call register_dir, core, $(SRC))) + +diff --git a/src/lstack/core/lstack_preload.c b/src/lstack/core/lstack_preload.c +index e04f49b..e3a98fc 100644 +--- a/src/lstack/core/lstack_preload.c ++++ b/src/lstack/core/lstack_preload.c +@@ -13,6 +13,9 @@ + #include + #include + ++#include "securec.h" ++ ++#include "lstack_log.h" + #include "lstack_preload.h" + + #define LSTACK_PRELOAD_ENV_SYS "LD_PRELOAD" +@@ -49,7 +52,7 @@ static int32_t preload_check_bind_proc(void) + return -1; + } + +-static int32_t preload_info_init(void) ++int preload_info_init(void) + { + char *enval = NULL; + +-- +2.23.0 + diff --git a/gazelle.spec b/gazelle.spec index 4e2b7b8..236b841 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 2 +Release: 3 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -18,6 +18,10 @@ Requires: numactl libpcap libconfig libboundscheck Patch9001: 0001-remove-unused-dpdk-dynamic-libraries.patch Patch9002: 0002-gazelle_stat_pkts-gazelle_stat_low_power_info.patch +Patch9003: 0003-set-localhost-ip-when-bind-ip-is-same-as-ip-in-lstac.patch +Patch9004: 0004-refactoring-preload-module.patch +Patch9005: 0005-fix-previous-commit-refactoring-preload-module.patch +Patch9006: 0006-add-lstack_preload.c-to-makefile.patch %description %{name} is a high performance user-mode stack. @@ -59,6 +63,12 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Sat Aug 19 2023 jiangheng12 - 1.0.2-3 +- add lstack_preload.c to makefile fix compile failure +- fix previous commit "refactoring preload module" +- refactoring preload module +- set localhost ip when bind ip is same as ip in lstack.conf + * Sat Jul 8 2023 jiangheng12 - 1.0.2-2 - sync remove unused dpdk dynamic libraries