!1098 [sync] PR-1094: sync fix free null pointer when no matching device is found
From: @openeuler-sync-bot Reviewed-by: @jiangheng12 Signed-off-by: @jiangheng12
This commit is contained in:
commit
ffe96224fd
@ -0,0 +1,36 @@
|
||||
From 0f3a61700b17bed0ed39c7c5433952b72dc82b84 Mon Sep 17 00:00:00 2001
|
||||
From: jiangheng <jiangheng14@huawei.com>
|
||||
Date: Wed, 20 Nov 2024 11:26:55 +0800
|
||||
Subject: [PATCH] fix socket of control thread is overwirtten due to another
|
||||
primary process start
|
||||
|
||||
---
|
||||
src/lstack/core/lstack_init.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
|
||||
index 276cdf8..29796ee 100644
|
||||
--- a/src/lstack/core/lstack_init.c
|
||||
+++ b/src/lstack/core/lstack_init.c
|
||||
@@ -166,14 +166,14 @@ static void create_control_thread(void)
|
||||
LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
|
||||
}
|
||||
} else {
|
||||
- ret = pthread_create(&tid, NULL, (void *(*)(void *))control_server_thread, NULL);
|
||||
- if (ret != 0) {
|
||||
- LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
|
||||
- }
|
||||
ret = dpdk_eal_init();
|
||||
if (ret < 0) {
|
||||
LSTACK_EXIT(1, "dpdk_eal_init failed ret=%d errno=%d\n", ret, errno);
|
||||
}
|
||||
+ ret = pthread_create(&tid, NULL, (void *(*)(void *))control_server_thread, NULL);
|
||||
+ if (ret != 0) {
|
||||
+ LSTACK_EXIT(1, "pthread_create failed ret=%d errno=%d\n", ret, errno);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (pthread_setname_np(tid, CONTROL_THREAD_NAME) != 0) {
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From 1d4bdf6a14afe7459d2fa9d2da19a36c45ae91f5 Mon Sep 17 00:00:00 2001
|
||||
From: yinbin <yinbin8@huawei.com>
|
||||
Date: Wed, 20 Nov 2024 16:32:28 +0800
|
||||
Subject: [PATCH] LWIP: adjust position of shutdown in callback of connect
|
||||
|
||||
---
|
||||
src/lstack/core/lstack_lwip.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
||||
index 65acae2..648da58 100644
|
||||
--- a/src/lstack/core/lstack_lwip.c
|
||||
+++ b/src/lstack/core/lstack_lwip.c
|
||||
@@ -1273,10 +1273,10 @@ void do_lwip_connected_callback(struct netconn *conn)
|
||||
posix_api->epoll_ctl_fn(sock->wakeup->epollfd, EPOLL_CTL_DEL, fd, NULL);
|
||||
}
|
||||
|
||||
- posix_api->shutdown_fn(fd, SHUT_RDWR);
|
||||
-
|
||||
POSIX_SET_TYPE(sock, POSIX_LWIP);
|
||||
|
||||
+ posix_api->shutdown_fn(fd, SHUT_RDWR);
|
||||
+
|
||||
add_sock_event(sock, EPOLLOUT);
|
||||
}
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
154
0290-Fix-the-wrong-spelling-description-in-the-notes-and-.patch
Normal file
154
0290-Fix-the-wrong-spelling-description-in-the-notes-and-.patch
Normal file
@ -0,0 +1,154 @@
|
||||
From e5aa9e48521b3096ba9acb888d293eefeaf677da Mon Sep 17 00:00:00 2001
|
||||
From: Caohongtao <caohongtao_yewu@cmss.chinamobile.com>
|
||||
Date: Wed, 9 Oct 2024 02:55:56 +0000
|
||||
Subject: [PATCH] Fix the wrong spelling description in the notes and logs
|
||||
|
||||
Signed-off-by: Caohongtao <caohongtao_yewu@cmss.chinamobile.com>
|
||||
---
|
||||
src/ltran/ltran_forward.c | 6 +++---
|
||||
src/ltran/main.c | 4 ++--
|
||||
tools/gazelle_common.sh | 8 ++++----
|
||||
tools/gazelle_setup.sh | 4 ++--
|
||||
tools/sync-gazelle-src.sh | 4 ++--
|
||||
5 files changed, 13 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c
|
||||
index 0de9c1c..aef5e46 100644
|
||||
--- a/src/ltran/ltran_forward.c
|
||||
+++ b/src/ltran/ltran_forward.c
|
||||
@@ -58,7 +58,7 @@ static void calculate_ltran_latency(struct gazelle_stack *stack, const struct rt
|
||||
uint64_t latency;
|
||||
|
||||
lt = &mbuf_to_private(mbuf)->lt;
|
||||
- // vaild check
|
||||
+ // valid check
|
||||
if (lt->stamp != ~(lt->check)) {
|
||||
return;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ static __rte_always_inline void flush_rx_ring(struct gazelle_stack *stack)
|
||||
}
|
||||
|
||||
uint32_t flush_cnt = pkt_bufs_enque_rx_ring(stack);
|
||||
- /* cant't flush mbuf into backup */
|
||||
+ /* can't flush mbuf into backup */
|
||||
if (unlikely(flush_cnt < stack->pkt_cnt)) {
|
||||
pktbufs_move_to_backup_bufs(stack, &(stack->pkt_buf[flush_cnt]), stack->pkt_cnt - flush_cnt);
|
||||
}
|
||||
@@ -475,7 +475,7 @@ static __rte_always_inline void tcp_hash_table_add_conn(struct gazelle_stack *st
|
||||
tcp_conn->conn_timeout = -1;
|
||||
return;
|
||||
} else {
|
||||
- /* del old invaild conn */
|
||||
+ /* del old invalid conn */
|
||||
gazelle_conn_del_by_quintuple(conn_htable, transfer_qtuple);
|
||||
}
|
||||
}
|
||||
diff --git a/src/ltran/main.c b/src/ltran/main.c
|
||||
index 3d2310b..0320b29 100644
|
||||
--- a/src/ltran/main.c
|
||||
+++ b/src/ltran/main.c
|
||||
@@ -117,7 +117,7 @@ static int32_t ltran_core_init(int32_t argc, char *argv[])
|
||||
|
||||
ret = ltran_ethdev_init();
|
||||
if (ret != GAZELLE_OK) {
|
||||
- syslog(LOG_ERR, "ltran ethdev init faild. ret=%d.\n", ret);
|
||||
+ syslog(LOG_ERR, "ltran ethdev init failed. ret=%d.\n", ret);
|
||||
closelog();
|
||||
return ret;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ int32_t main(int32_t argc, char *argv[])
|
||||
}
|
||||
|
||||
/* create multi thread to receive and send packet for multi bond port */
|
||||
- LTRAN_INFO("Runing Process forward\n");
|
||||
+ LTRAN_INFO("Running Process forward\n");
|
||||
/* main thread is for port 0 receive packet */
|
||||
index = 0;
|
||||
upstream_forward((const void *)&index);
|
||||
diff --git a/tools/gazelle_common.sh b/tools/gazelle_common.sh
|
||||
index fac0d68..8febd16 100644
|
||||
--- a/tools/gazelle_common.sh
|
||||
+++ b/tools/gazelle_common.sh
|
||||
@@ -25,7 +25,7 @@ g_subnet_len=""
|
||||
g_gateway=""
|
||||
g_premask=""
|
||||
|
||||
-# globla varibles initialized when run
|
||||
+# global variables initialized when run
|
||||
g_netcard_mac=""
|
||||
g_kni_mac=""
|
||||
g_default_route="$(sudo ip route | grep default)"
|
||||
@@ -148,7 +148,7 @@ load_vfio_module() {
|
||||
msg_show "Loading vfio module"
|
||||
sudo /sbin/modprobe vfio enable_unsafe_noiommu_mode=1
|
||||
else
|
||||
- msg_err "the vfio mudule is not exist"
|
||||
+ msg_err "the vfio module is not exist"
|
||||
return 1
|
||||
fi
|
||||
sudo modinfo vfio-pci > /dev/null
|
||||
@@ -156,7 +156,7 @@ load_vfio_module() {
|
||||
msg_show "Loading vfio-pci module"
|
||||
sudo /sbin/modprobe vfio-pci
|
||||
else
|
||||
- msg_err "the vfio-pci mudule is not exist"
|
||||
+ msg_err "the vfio-pci module is not exist"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@@ -393,7 +393,7 @@ configure_nic() {
|
||||
fi
|
||||
|
||||
if [ $1 = "usr" ]; then
|
||||
- msg_show "use vitual kni card"
|
||||
+ msg_show "use virtual kni card"
|
||||
net_card=$g_conn_if_kni
|
||||
default_route="$(echo $g_default_route | grep $g_conn_if)"
|
||||
fi
|
||||
diff --git a/tools/gazelle_setup.sh b/tools/gazelle_setup.sh
|
||||
index c3ad830..8185e19 100644
|
||||
--- a/tools/gazelle_setup.sh
|
||||
+++ b/tools/gazelle_setup.sh
|
||||
@@ -117,7 +117,7 @@ check_nic_name() {
|
||||
|
||||
check_numa_pages() {
|
||||
numa_num=$(lscpu | grep "NUMA node(s)" | awk '{print $3}')
|
||||
- # todo : check the maxmum and minmum of the page numbers, make sure the system available mem support
|
||||
+ # todo : check the maxmum and minimum of the page numbers, make sure the system available mem support
|
||||
g_hugepages=${g_hugepages:-1024}
|
||||
msg_show "make sure the huge mem is large enough & not extend the maximum of system mem!"
|
||||
myPage=(${g_hugepages//\,/ })
|
||||
@@ -511,7 +511,7 @@ XDG_RUNTIME_DIR=/tmp nohup /usr/bin/ltran --config-file=$CONF_DIR/ltran.conf > /
|
||||
|
||||
check_ltran 120
|
||||
if [ $? -ne 0 ]; then
|
||||
- msg_err "ltran start faild! Please check ltran's log for the reason of the problem."
|
||||
+ msg_err "ltran start failed! Please check ltran's log for the reason of the problem."
|
||||
nic_recover
|
||||
exit 1
|
||||
else
|
||||
diff --git a/tools/sync-gazelle-src.sh b/tools/sync-gazelle-src.sh
|
||||
index ccfa8eb..326119b 100644
|
||||
--- a/tools/sync-gazelle-src.sh
|
||||
+++ b/tools/sync-gazelle-src.sh
|
||||
@@ -8,7 +8,7 @@
|
||||
# 2. COMMIT_ID is a committrf hash record from openeuler/gazelle (this repository).
|
||||
# Multiple committrf hash records should be separated by spaces;
|
||||
# 3. TARGET_BRANCH is a branch from src-openeuler/gazelle;
|
||||
-# 4. USER/EMAIL will be autimatically obtailed from the git configuration;
|
||||
+# 4. USER/EMAIL will be automatically obtailed from the git configuration;
|
||||
|
||||
# Example Usage:
|
||||
# > COMMIT_ID="123456789" TARGET_BRANCH="openEuler-20.03-LTS-SP1" bash tools/sync-gazelle-src.sh
|
||||
@@ -39,7 +39,7 @@ for commitid in ${COMMIT_ID};do
|
||||
cd ${workdir}
|
||||
patchname=$(git format-patch -1 ${commitid} | tail -n1)
|
||||
if [ $? -ne 0 ];then
|
||||
- echo "invaild commitid $commitid"
|
||||
+ echo "invalid commitid $commitid"
|
||||
exit 1
|
||||
fi
|
||||
gitmsg=$(git log --pretty=format:"%s" -1 $commitid | sed -e 's/^![0-9]* //g')
|
||||
--
|
||||
2.33.0
|
||||
|
||||
30
0291-update-test-unitest-ltran-ltran_param_test.c.patch
Normal file
30
0291-update-test-unitest-ltran-ltran_param_test.c.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From 6da24dc0e77efa68f7b8c7d9986634918ef6097e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?=E8=8F=A0=E8=90=9D=E6=9C=89=E7=82=B9=E9=85=B8?=
|
||||
<yanxiaoqiang_yewu@cmss.chinamobile.com>
|
||||
Date: Wed, 9 Oct 2024 07:55:56 +0000
|
||||
Subject: [PATCH] update test/unitest/ltran/ltran_param_test.c.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: 菠萝有点酸 <yanxiaoqiang_yewu@cmss.chinamobile.com>
|
||||
---
|
||||
test/unitest/ltran/ltran_param_test.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/unitest/ltran/ltran_param_test.c b/test/unitest/ltran/ltran_param_test.c
|
||||
index 3b2a24d..d43d20f 100644
|
||||
--- a/test/unitest/ltran/ltran_param_test.c
|
||||
+++ b/test/unitest/ltran/ltran_param_test.c
|
||||
@@ -74,7 +74,7 @@ void test_ltran_bad_params_clients(void)
|
||||
CU_ASSERT(ltran_bad_param("s/dispatch_max_clients = 32/dispatch_max_clients = 0/") != 0);
|
||||
CU_ASSERT(gazelle_get_errno() == GAZELLE_ERANGE);
|
||||
|
||||
- /* ltran start 999 clinet */
|
||||
+ /* ltran start 999 client */
|
||||
CU_ASSERT(ltran_bad_param("s/dispatch_max_clients = 32/dispatch_max_clients = 999/") != 0);
|
||||
CU_ASSERT(gazelle_get_errno() == GAZELLE_ERANGE);
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
From cd82f46b54e14898087ea1b051bce51eb50adef7 Mon Sep 17 00:00:00 2001
|
||||
From: yangchen <yangchen145@huawei.com>
|
||||
Date: Wed, 20 Nov 2024 14:17:09 +0800
|
||||
Subject: [PATCH] fix free null pointer when no matching device is found
|
||||
|
||||
---
|
||||
src/lstack/core/lstack_cfg.c | 15 ++++++---------
|
||||
1 file changed, 6 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
||||
index 2a3f1af..0ca838d 100644
|
||||
--- a/src/lstack/core/lstack_cfg.c
|
||||
+++ b/src/lstack/core/lstack_cfg.c
|
||||
@@ -179,7 +179,7 @@ struct cfg_params *get_global_cfg_params(void)
|
||||
|
||||
static int32_t str_to_eth_addr(const char *src, unsigned char *dst)
|
||||
{
|
||||
- if (strlen(src) > DEV_MAC_LEN) {
|
||||
+ if (src == NULL || strlen(src) > DEV_MAC_LEN) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,6 @@ static int32_t parse_mask_addr(void)
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
- freeifaddrs(ifa);
|
||||
}
|
||||
|
||||
if (g_config_params.netmask.addr == INADDR_NONE) {
|
||||
@@ -315,7 +314,6 @@ static int32_t parse_host_addr(void)
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
- freeifaddrs(ifa);
|
||||
}
|
||||
|
||||
if (g_config_params.host_addr.addr == INADDR_NONE) {
|
||||
@@ -404,7 +402,6 @@ static int32_t parse_devices(void)
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
- freeifaddrs(ifa);
|
||||
}
|
||||
|
||||
/* add dev */
|
||||
@@ -1048,7 +1045,7 @@ static int32_t parse_mbuf_count_per_conn(void)
|
||||
{
|
||||
int32_t ret;
|
||||
PARSE_ARG(g_config_params.mbuf_count_per_conn, "mbuf_count_per_conn",
|
||||
- MBUF_COUNT_PER_CONN, 1, INT32_MAX, ret);
|
||||
+ MBUF_COUNT_PER_CONN, 1, INT32_MAX, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1173,13 +1170,13 @@ static int32_t parse_unix_prefix(void)
|
||||
int32_t ret = 0;
|
||||
|
||||
ret = memset_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
|
||||
- 0, sizeof(g_config_params.unix_socket_filename));
|
||||
+ 0, sizeof(g_config_params.unix_socket_filename));
|
||||
if (ret != EOK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = strncpy_s(g_config_params.unix_socket_filename, sizeof(g_config_params.unix_socket_filename),
|
||||
- GAZELLE_RUN_DIR, strlen(GAZELLE_RUN_DIR) + 1);
|
||||
+ GAZELLE_RUN_DIR, strlen(GAZELLE_RUN_DIR) + 1);
|
||||
if (ret != EOK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -1200,10 +1197,10 @@ static int32_t parse_unix_prefix(void)
|
||||
|
||||
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);
|
||||
+ 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);
|
||||
+ LSTACK_DFX_SOCK_FILENAME, strlen(LSTACK_DFX_SOCK_FILENAME) + 1);
|
||||
}
|
||||
|
||||
if (ret != EOK) {
|
||||
--
|
||||
2.33.0
|
||||
|
||||
66
0293-cfg-show-dpdk-args-after-dpdk_adjust_args.patch
Normal file
66
0293-cfg-show-dpdk-args-after-dpdk_adjust_args.patch
Normal file
@ -0,0 +1,66 @@
|
||||
From f05ce4c32a5c4121f41a69fa8b78c0a6a69e29d8 Mon Sep 17 00:00:00 2001
|
||||
From: yangchen <yangchen145@huawei.com>
|
||||
Date: Wed, 20 Nov 2024 11:42:00 +0800
|
||||
Subject: [PATCH] cfg: show dpdk args after dpdk_adjust_args
|
||||
|
||||
---
|
||||
src/lstack/core/lstack_cfg.c | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
||||
index 2a3f1af..72dbb18 100644
|
||||
--- a/src/lstack/core/lstack_cfg.c
|
||||
+++ b/src/lstack/core/lstack_cfg.c
|
||||
@@ -905,7 +905,7 @@ static void dpdk_fill_socket_mem(void)
|
||||
}
|
||||
}
|
||||
|
||||
-static void dpdk_add_args(void)
|
||||
+static void dpdk_adjust_args(void)
|
||||
{
|
||||
int idx;
|
||||
uint16_t lcore_id;
|
||||
@@ -936,6 +936,15 @@ static void dpdk_add_args(void)
|
||||
}
|
||||
}
|
||||
|
||||
+static void dpdk_show_args(void)
|
||||
+{
|
||||
+ (void)fprintf(stderr, "dpdk argv: ");
|
||||
+ for (uint32_t i = 1; i < g_config_params.dpdk_argc; i++) {
|
||||
+ (void)fprintf(stderr, "%s ", g_config_params.dpdk_argv[i]);
|
||||
+ }
|
||||
+ (void)fprintf(stderr, "\n");
|
||||
+}
|
||||
+
|
||||
static int32_t parse_dpdk_args(void)
|
||||
{
|
||||
int32_t i;
|
||||
@@ -957,8 +966,6 @@ static int32_t parse_dpdk_args(void)
|
||||
if (!g_config_params.dpdk_argv)
|
||||
return -EINVAL;
|
||||
|
||||
- (void)fprintf(stderr, "dpdk argv: ");
|
||||
-
|
||||
g_config_params.dpdk_argv[0] = strdup("lstack");
|
||||
if (!g_config_params.dpdk_argv[0]) {
|
||||
goto free_dpdk_args;
|
||||
@@ -981,13 +988,11 @@ static int32_t parse_dpdk_args(void)
|
||||
if (strcmp(p, secondary) == 0) {
|
||||
global_params->is_primary = 0;
|
||||
}
|
||||
-
|
||||
- (void)fprintf(stderr, "%s ", g_config_params.dpdk_argv[start_index + i]);
|
||||
}
|
||||
- (void)fprintf(stderr, "\n");
|
||||
g_config_params.dpdk_argc++;
|
||||
|
||||
- dpdk_add_args();
|
||||
+ dpdk_adjust_args();
|
||||
+ dpdk_show_args();
|
||||
|
||||
if (turn_args_to_config(g_config_params.dpdk_argc, g_config_params.dpdk_argv))
|
||||
goto free_dpdk_args;
|
||||
--
|
||||
2.33.0
|
||||
|
||||
27
0294-fix-build-error-in-2003SP4.patch
Normal file
27
0294-fix-build-error-in-2003SP4.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 83b65f8da77f586cc58278944f840016817ba9f7 Mon Sep 17 00:00:00 2001
|
||||
From: yangchen <yangchen145@huawei.com>
|
||||
Date: Sat, 23 Nov 2024 16:14:25 +0800
|
||||
Subject: [PATCH] fix build error in 2003SP4
|
||||
|
||||
---
|
||||
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 7e724cd..d22847a 100644
|
||||
--- a/src/lstack/api/lstack_wrap.c
|
||||
+++ b/src/lstack/api/lstack_wrap.c
|
||||
@@ -31,6 +31,10 @@
|
||||
#include "lstack_rtw_api.h"
|
||||
#include "lstack_dummy_api.h"
|
||||
|
||||
+#ifndef SOL_XDP
|
||||
+#define SOL_XDP 283 /* same as define in bits/socket.h */
|
||||
+#endif
|
||||
+
|
||||
static posix_api_t g_wrap_api_value;
|
||||
static posix_api_t *g_wrap_api;
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
166
0295-CFG-fix-xdp-iface-check-error.patch
Normal file
166
0295-CFG-fix-xdp-iface-check-error.patch
Normal file
@ -0,0 +1,166 @@
|
||||
From fb7be13ec41f31261fb32741cab2f9903b05d246 Mon Sep 17 00:00:00 2001
|
||||
From: yinbin <yinbin8@huawei.com>
|
||||
Date: Fri, 22 Nov 2024 16:04:14 +0800
|
||||
Subject: [PATCH] CFG: fix xdp iface check error
|
||||
|
||||
---
|
||||
src/lstack/core/lstack_cfg.c | 47 ++++++++++++++++++++++++++----------
|
||||
1 file changed, 34 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
||||
index 0ca838d..45c695e 100644
|
||||
--- a/src/lstack/core/lstack_cfg.c
|
||||
+++ b/src/lstack/core/lstack_cfg.c
|
||||
@@ -92,6 +92,7 @@ static int32_t parse_flow_bifurcation(void);
|
||||
static int32_t parse_stack_interrupt(void);
|
||||
static int32_t parse_stack_num(void);
|
||||
static int32_t parse_xdp_eth_name(void);
|
||||
+static bool xdp_eth_enabled(void);
|
||||
|
||||
#define PARSE_ARG(_arg, _arg_string, _default_val, _min_val, _max_val, _ret) \
|
||||
do { \
|
||||
@@ -223,7 +224,7 @@ static int32_t parse_gateway_addr(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (strlen(g_config_params.xdp_eth_name) == 0) {
|
||||
+ if (!xdp_eth_enabled()) {
|
||||
ok = config_lookup_string(&g_config, "gateway_addr", (const char **)&value);
|
||||
if (!ok) {
|
||||
return -EINVAL;
|
||||
@@ -252,7 +253,7 @@ static int32_t parse_mask_addr(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (strlen(g_config_params.xdp_eth_name) == 0) {
|
||||
+ if (!xdp_eth_enabled()) {
|
||||
ret = config_lookup_string(&g_config, "mask_addr", (const char **)&mask_addr);
|
||||
if (!ret) {
|
||||
return -EINVAL;
|
||||
@@ -266,7 +267,7 @@ static int32_t parse_mask_addr(void)
|
||||
|
||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET ||
|
||||
- strncmp(ifa->ifa_name, g_config_params.xdp_eth_name, strlen(g_config_params.xdp_eth_name))) {
|
||||
+ strcmp(ifa->ifa_name, g_config_params.xdp_eth_name)) {
|
||||
continue;
|
||||
}
|
||||
g_config_params.netmask.addr = ((struct sockaddr_in *)ifa->ifa_netmask)->sin_addr.s_addr;
|
||||
@@ -293,7 +294,7 @@ static int32_t parse_host_addr(void)
|
||||
struct ifaddrs *ifaddr;
|
||||
struct ifaddrs *ifa;
|
||||
|
||||
- if (strlen(g_config_params.xdp_eth_name) == 0) {
|
||||
+ if (!xdp_eth_enabled()) {
|
||||
ret = config_lookup_string(&g_config, "host_addr", (const char **)&host_addr);
|
||||
if (!ret) {
|
||||
return 0;
|
||||
@@ -307,7 +308,7 @@ static int32_t parse_host_addr(void)
|
||||
|
||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_INET ||
|
||||
- strncmp(ifa->ifa_name, g_config_params.xdp_eth_name, strlen(g_config_params.xdp_eth_name))) {
|
||||
+ strcmp(ifa->ifa_name, g_config_params.xdp_eth_name)) {
|
||||
continue;
|
||||
}
|
||||
g_config_params.host_addr.addr = ((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr;
|
||||
@@ -334,7 +335,7 @@ static int32_t parse_host_addr6(void)
|
||||
|
||||
ok = config_lookup_string(&g_config, "host_addr6", (const char **)&value);
|
||||
if (!ok) {
|
||||
- if (ip4_addr_isany_val(g_config_params.host_addr) && (strlen(g_config_params.xdp_eth_name) == 0)) {
|
||||
+ if (ip4_addr_isany_val(g_config_params.host_addr) && (!xdp_eth_enabled())) {
|
||||
LSTACK_PRE_LOG(LSTACK_ERR, "cfg: host_addr and host_addr6 must have a valid one.");
|
||||
return -EINVAL;
|
||||
} else {
|
||||
@@ -377,7 +378,7 @@ static int32_t parse_devices(void)
|
||||
struct ifaddrs *ifaddr;
|
||||
char temp_dev[DEV_MAC_LEN + 1] = {0};
|
||||
|
||||
- if (strlen(g_config_params.xdp_eth_name) == 0) {
|
||||
+ if (!xdp_eth_enabled()) {
|
||||
ret = config_lookup_string(&g_config, "devices", (const char **)&dev);
|
||||
if (!ret) {
|
||||
return -EINVAL;
|
||||
@@ -390,7 +391,7 @@ static int32_t parse_devices(void)
|
||||
|
||||
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL || ifa->ifa_addr->sa_family != AF_PACKET ||
|
||||
- strncmp(ifa->ifa_name, g_config_params.xdp_eth_name, strlen(g_config_params.xdp_eth_name))) {
|
||||
+ strcmp(ifa->ifa_name, g_config_params.xdp_eth_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -399,9 +400,16 @@ static int32_t parse_devices(void)
|
||||
((struct sockaddr_ll *)ifa->ifa_addr)->sll_addr[i], i < (ETHER_ADDR_LEN - 1) ? ":" : "");
|
||||
}
|
||||
dev = strdup_assert_return(temp_dev);
|
||||
+ break;
|
||||
}
|
||||
|
||||
freeifaddrs(ifaddr);
|
||||
+
|
||||
+ if (dev == NULL) {
|
||||
+ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: can not find the iface \"%s\" specified in dpdk_args."
|
||||
+ " devices parsing exit!\n", g_config_params.xdp_eth_name);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* add dev */
|
||||
@@ -1497,7 +1505,7 @@ static int32_t parse_stack_interrupt(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-static void dpdk_dev_get_iface_name(char *vdev_str)
|
||||
+static int dpdk_dev_get_iface_name(char *vdev_str)
|
||||
{
|
||||
char *token = NULL;
|
||||
char *iface_value = NULL;
|
||||
@@ -1507,7 +1515,7 @@ static void dpdk_dev_get_iface_name(char *vdev_str)
|
||||
/* To prevent the original string from being modified, use a copied string. */
|
||||
if (strcpy_s(vdev_str_cp, sizeof(vdev_str_cp), vdev_str) != 0) {
|
||||
LSTACK_PRE_LOG(LSTACK_ERR, "vdev_str strcpy_s fail \n");
|
||||
- return;
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
token = strtok_s(vdev_str_cp, ",", &next_token);
|
||||
@@ -1519,8 +1527,12 @@ static void dpdk_dev_get_iface_name(char *vdev_str)
|
||||
token = strtok_s(NULL, ",", &next_token);
|
||||
}
|
||||
|
||||
- if (iface_value) {
|
||||
+ if (iface_value && strlen(iface_value) > 0) {
|
||||
strncpy_s(g_config_params.xdp_eth_name, IFNAMSIZ, iface_value, IFNAMSIZ - 1);
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ LSTACK_PRE_LOG(LSTACK_ERR, "xdp iface name bas not been specified in dpdk_args.\n");
|
||||
+ return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1536,9 +1548,18 @@ static int32_t parse_xdp_eth_name(void)
|
||||
|
||||
for (uint32_t i = 0; i < g_config_params.dpdk_argc; i++) {
|
||||
if (!strncmp(g_config_params.dpdk_argv[i], OPT_VDEV, strlen(OPT_VDEV))) {
|
||||
- dpdk_dev_get_iface_name(g_config_params.dpdk_argv[i + 1]);
|
||||
+ ret = dpdk_dev_get_iface_name(g_config_params.dpdk_argv[i + 1]);
|
||||
+ break;
|
||||
}
|
||||
}
|
||||
|
||||
- return 0;
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static bool xdp_eth_enabled(void)
|
||||
+{
|
||||
+ if (strlen(g_config_params.xdp_eth_name)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
425
0296-xdp-support-stack-bind-numa.patch
Normal file
425
0296-xdp-support-stack-bind-numa.patch
Normal file
@ -0,0 +1,425 @@
|
||||
From 4b5ead09ab19b08a46a9ffba7cbc5e42e361dcc1 Mon Sep 17 00:00:00 2001
|
||||
From: yangchen <yangchen145@huawei.com>
|
||||
Date: Sat, 23 Nov 2024 18:04:55 +0800
|
||||
Subject: [PATCH] xdp: support stack bind numa
|
||||
|
||||
---
|
||||
src/common/gazelle_opt.h | 5 +-
|
||||
src/lstack/core/lstack_cfg.c | 101 ++++++++----------------
|
||||
src/lstack/core/lstack_dpdk.c | 20 -----
|
||||
src/lstack/core/lstack_protocol_stack.c | 82 +++++++++++++++++--
|
||||
src/lstack/include/lstack_cfg.h | 11 +--
|
||||
src/lstack/include/lstack_dpdk.h | 1 -
|
||||
6 files changed, 119 insertions(+), 101 deletions(-)
|
||||
|
||||
diff --git a/src/common/gazelle_opt.h b/src/common/gazelle_opt.h
|
||||
index 6d787b9..98f1afd 100644
|
||||
--- a/src/common/gazelle_opt.h
|
||||
+++ b/src/common/gazelle_opt.h
|
||||
@@ -105,8 +105,11 @@
|
||||
|
||||
#define LSTACK_SEND_THREAD_NAME "lstack_send"
|
||||
#define LSTACK_RECV_THREAD_NAME "lstack_recv"
|
||||
-#define LSTACK_THREAD_NAME "gazellelstack"
|
||||
+#define LSTACK_THREAD_NAME "gazellelstack"
|
||||
|
||||
#define SLEEP_US_BEFORE_LINK_UP 10000
|
||||
|
||||
+#define CPUS_MAX_NUM 640
|
||||
+#define GAZELLE_MAX_NUMA_NODES 4
|
||||
+
|
||||
#endif /* _GAZELLE_OPT_H_ */
|
||||
diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c
|
||||
index 0ca838d..c8ce5c3 100644
|
||||
--- a/src/lstack/core/lstack_cfg.c
|
||||
+++ b/src/lstack/core/lstack_cfg.c
|
||||
@@ -43,7 +43,6 @@
|
||||
#define NUMA_CPULIST_PATH "/sys/devices/system/node/node%u/cpulist"
|
||||
#define DEV_MAC_LEN 17
|
||||
#define DEV_PCI_ADDR_LEN 12
|
||||
-#define CPUS_MAX_NUM 256
|
||||
#define BOND_MIIMON_MIN 1
|
||||
#define BOND_MIIMON_MAX INT_MAX
|
||||
|
||||
@@ -127,6 +126,7 @@ static struct config_vector_t g_config_tbl[] = {
|
||||
{ "send_ring_size", parse_send_ring_size },
|
||||
{ "recv_ring_size", parse_recv_ring_size },
|
||||
{ "rpc_msg_max", parse_rpc_msg_max },
|
||||
+ { "app_bind_numa", parse_app_bind_numa },
|
||||
{ "stack_num", parse_stack_num },
|
||||
{ "num_cpus", parse_stack_cpu_number },
|
||||
{ "dpdk_args", parse_dpdk_args },
|
||||
@@ -139,7 +139,6 @@ static struct config_vector_t g_config_tbl[] = {
|
||||
{ "low_power_mode", parse_low_power_mode },
|
||||
{ "kni_switch", parse_kni_switch },
|
||||
{ "listen_shadow", parse_listen_shadow },
|
||||
- { "app_bind_numa", parse_app_bind_numa },
|
||||
{ "app_exclude_cpus", parse_app_exclude_cpus },
|
||||
{ "main_thread_affinity", parse_main_thread_affinity },
|
||||
{ "unix_prefix", parse_unix_prefix },
|
||||
@@ -446,6 +445,7 @@ static int32_t stack_bind_no_cpu(void)
|
||||
g_config_params.num_cpu = g_config_params.stack_num;
|
||||
g_config_params.num_queue = g_config_params.num_cpu;
|
||||
g_config_params.tot_queue_num = g_config_params.num_queue;
|
||||
+ g_config_params.app_bind_numa = true;
|
||||
|
||||
LSTACK_PRE_LOG(LSTACK_INFO, "NUMA node: %d\n", g_config_params.numa_id);
|
||||
|
||||
@@ -473,11 +473,11 @@ static int32_t stack_bind_cpus(void)
|
||||
strcpy(g_config_params.lcores, args);
|
||||
|
||||
tmp_arg = strdup_assert_return(args);
|
||||
- cnt = separate_str_to_array(tmp_arg, g_config_params.cpus, CFG_MAX_CPUS, CFG_MAX_CPUS);
|
||||
+ cnt = separate_str_to_array(tmp_arg, g_config_params.cpus, CPUS_MAX_NUM, CPUS_MAX_NUM);
|
||||
free(tmp_arg);
|
||||
if (cnt <= 0) {
|
||||
return stack_bind_no_cpu();
|
||||
- } else if (cnt > CFG_MAX_CPUS) {
|
||||
+ } else if (cnt > CPUS_MAX_NUM) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -534,9 +534,9 @@ static int32_t parse_app_exclude_cpus(void)
|
||||
}
|
||||
|
||||
tmp_arg = strdup_assert_return(args);
|
||||
- cnt = separate_str_to_array(tmp_arg, g_config_params.app_exclude_cpus, CFG_MAX_CPUS, CFG_MAX_CPUS);
|
||||
+ cnt = separate_str_to_array(tmp_arg, g_config_params.app_exclude_cpus, CPUS_MAX_NUM, CPUS_MAX_NUM);
|
||||
free(tmp_arg);
|
||||
- if (cnt <= 0 || cnt > CFG_MAX_CPUS) {
|
||||
+ if (cnt <= 0 || cnt > CPUS_MAX_NUM) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -544,18 +544,20 @@ static int32_t parse_app_exclude_cpus(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int32_t numa_to_cpusnum(unsigned numa_id, uint32_t *cpulist, int32_t num)
|
||||
+int numa_to_cpusnum(uint16_t numa_id, uint32_t *cpulist, int num)
|
||||
{
|
||||
+ int ret;
|
||||
+ int fd;
|
||||
char path[PATH_MAX] = {0};
|
||||
char strbuf[PATH_MAX] = {0};
|
||||
|
||||
- int32_t ret = snprintf_s(path, sizeof(path), PATH_MAX - 1, NUMA_CPULIST_PATH, numa_id);
|
||||
+ ret = snprintf_s(path, sizeof(path), PATH_MAX - 1, NUMA_CPULIST_PATH, numa_id);
|
||||
if (ret < 0) {
|
||||
LSTACK_LOG(ERR, LSTACK, "snprintf numa_cpulist failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
- int32_t fd = open(path, O_RDONLY);
|
||||
+ fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
LSTACK_LOG(ERR, LSTACK, "open %s failed\n", path);
|
||||
return -1;
|
||||
@@ -568,55 +570,7 @@ static int32_t numa_to_cpusnum(unsigned numa_id, uint32_t *cpulist, int32_t num)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- int32_t count = separate_str_to_array(strbuf, cpulist, num, CFG_MAX_CPUS);
|
||||
- return count;
|
||||
-}
|
||||
-
|
||||
-static int32_t stack_idle_cpuset(struct protocol_stack *stack, cpu_set_t *exclude)
|
||||
-{
|
||||
- uint32_t cpulist[CPUS_MAX_NUM];
|
||||
-
|
||||
- int32_t cpunum = numa_to_cpusnum(stack->numa_id, cpulist, CPUS_MAX_NUM);
|
||||
- if (cpunum <= 0) {
|
||||
- LSTACK_LOG(ERR, LSTACK, "numa_to_cpusnum failed\n");
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- CPU_ZERO(&stack->idle_cpuset);
|
||||
- for (int32_t i = 0; i < cpunum; i++) {
|
||||
- /* skip stack cpu */
|
||||
- if (CPU_ISSET(cpulist[i], exclude)) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- CPU_SET(cpulist[i], &stack->idle_cpuset);
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-int32_t init_stack_numa_cpuset(struct protocol_stack *stack)
|
||||
-{
|
||||
- int32_t ret;
|
||||
- struct cfg_params *cfg = get_global_cfg_params();
|
||||
-
|
||||
- cpu_set_t stack_cpuset;
|
||||
- CPU_ZERO(&stack_cpuset);
|
||||
- for (int32_t idx = 0; idx < cfg->num_cpu; ++idx) {
|
||||
- CPU_SET(cfg->cpus[idx], &stack_cpuset);
|
||||
- }
|
||||
-
|
||||
- for (int32_t idx = 0; idx < cfg->app_exclude_num_cpu; ++idx) {
|
||||
- CPU_SET(cfg->app_exclude_cpus[idx], &stack_cpuset);
|
||||
- }
|
||||
-
|
||||
- ret = stack_idle_cpuset(stack, &stack_cpuset);
|
||||
- if (ret < 0) {
|
||||
- LSTACK_LOG(ERR, LSTACK, "thread_get_cpuset stack(%u) failed\n", stack->tid);
|
||||
- return -1;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
+ return separate_str_to_array(strbuf, cpulist, num, CPUS_MAX_NUM);
|
||||
}
|
||||
|
||||
static int32_t gazelle_parse_base_virtaddr(const char *arg, uintptr_t *base_vaddr)
|
||||
@@ -883,6 +837,28 @@ static bool dpdk_have_socket_mem(int32_t argc, char **argv)
|
||||
return false;
|
||||
}
|
||||
|
||||
+static void dpdk_fill_lcore(void)
|
||||
+{
|
||||
+ uint16_t lcore_id;
|
||||
+ cpu_set_t cpuset;
|
||||
+
|
||||
+ CPU_ZERO(&cpuset);
|
||||
+ if (sched_getaffinity(0, sizeof(cpu_set_t), &cpuset) == -1) {
|
||||
+ LSTACK_LOG(ERR, LSTACK, "sched_getaffinity failed\n");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (lcore_id = 0; lcore_id < CPU_SETSIZE; lcore_id++) {
|
||||
+ if (CPU_ISSET(lcore_id, &cpuset) &&
|
||||
+ numa_node_of_cpu(lcore_id) == g_config_params.numa_id &&
|
||||
+ rte_lcore_is_enabled(lcore_id)) {
|
||||
+ snprintf_s(g_config_params.lcores, sizeof(g_config_params.lcores),
|
||||
+ sizeof(g_config_params.lcores) - 1, "%d", lcore_id);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static void dpdk_fill_socket_mem(void)
|
||||
{
|
||||
uint32_t socket_mem_size = dpdk_total_socket_memory();
|
||||
@@ -905,17 +881,10 @@ static void dpdk_fill_socket_mem(void)
|
||||
static void dpdk_adjust_args(void)
|
||||
{
|
||||
int idx;
|
||||
- uint16_t lcore_id;
|
||||
|
||||
if (!dpdk_have_corelist(g_config_params.dpdk_argc, g_config_params.dpdk_argv)) {
|
||||
if (g_config_params.stack_num > 0) {
|
||||
- RTE_LCORE_FOREACH(lcore_id) {
|
||||
- if (numa_node_of_cpu(lcore_id) == g_config_params.numa_id && rte_lcore_is_enabled(lcore_id)) {
|
||||
- snprintf_s(g_config_params.lcores, sizeof(g_config_params.lcores),
|
||||
- sizeof(g_config_params.lcores) - 1, "%d", lcore_id);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ dpdk_fill_lcore();
|
||||
}
|
||||
g_config_params.dpdk_argv[g_config_params.dpdk_argc++] = strdup_assert_return(OPT_BIND_CORELIST);
|
||||
g_config_params.dpdk_argv[g_config_params.dpdk_argc++] = strdup_assert_return(g_config_params.lcores);
|
||||
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
|
||||
index 5141c3a..3023a6c 100644
|
||||
--- a/src/lstack/core/lstack_dpdk.c
|
||||
+++ b/src/lstack/core/lstack_dpdk.c
|
||||
@@ -104,26 +104,6 @@ int32_t thread_affinity_default(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int32_t thread_affinity_init(int32_t cpu_id)
|
||||
-{
|
||||
- int32_t ret;
|
||||
- cpu_set_t cpuset;
|
||||
-
|
||||
- if (get_global_cfg_params()->stack_num > 0) {
|
||||
- return 0;
|
||||
- }
|
||||
-
|
||||
- CPU_ZERO(&cpuset);
|
||||
- CPU_SET(cpu_id, &cpuset);
|
||||
-
|
||||
- ret = rte_thread_set_affinity(&cpuset);
|
||||
- if (ret != 0) {
|
||||
- LSTACK_LOG(ERR, LSTACK, "thread %d pthread_setaffinity_np failed ret=%d\n", rte_gettid(), ret);
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
int32_t dpdk_eal_init(void)
|
||||
{
|
||||
int32_t ret;
|
||||
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
|
||||
index 9cfd54f..2c60a49 100644
|
||||
--- a/src/lstack/core/lstack_protocol_stack.c
|
||||
+++ b/src/lstack/core/lstack_protocol_stack.c
|
||||
@@ -32,9 +32,8 @@
|
||||
#include "lstack_epoll.h"
|
||||
#include "lstack_stack_stat.h"
|
||||
#include "lstack_virtio.h"
|
||||
-#include "lstack_protocol_stack.h"
|
||||
-
|
||||
#include "lstack_interrupt.h"
|
||||
+#include "lstack_protocol_stack.h"
|
||||
|
||||
#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
|
||||
#include <rte_kni.h>
|
||||
@@ -161,6 +160,7 @@ void bind_to_stack_numa(struct protocol_stack *stack)
|
||||
pthread_t tid = pthread_self();
|
||||
|
||||
if (get_global_cfg_params()->stack_num > 0) {
|
||||
+ numa_run_on_node(stack->numa_id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,75 @@ void thread_bind_stack(struct protocol_stack *stack)
|
||||
}
|
||||
}
|
||||
|
||||
+static int stack_affinity_cpu(int cpu_id)
|
||||
+{
|
||||
+ int32_t ret;
|
||||
+ cpu_set_t cpuset;
|
||||
+
|
||||
+ CPU_ZERO(&cpuset);
|
||||
+ CPU_SET(cpu_id, &cpuset);
|
||||
+
|
||||
+ ret = rte_thread_set_affinity(&cpuset);
|
||||
+ if (ret != 0) {
|
||||
+ LSTACK_LOG(ERR, LSTACK, "thread %d pthread_setaffinity_np failed ret=%d\n", rte_gettid(), ret);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void stack_affinity_numa(int numa_id)
|
||||
+{
|
||||
+ numa_run_on_node(numa_id);
|
||||
+}
|
||||
+
|
||||
+static int32_t stack_idle_cpuset(struct protocol_stack *stack, cpu_set_t *exclude)
|
||||
+{
|
||||
+ int32_t cpunum;
|
||||
+ uint32_t cpulist[CPUS_MAX_NUM];
|
||||
+
|
||||
+ cpunum = numa_to_cpusnum(stack->numa_id, cpulist, CPUS_MAX_NUM);
|
||||
+ if (cpunum <= 0) {
|
||||
+ LSTACK_LOG(ERR, LSTACK, "numa_to_cpusnum failed\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ CPU_ZERO(&stack->idle_cpuset);
|
||||
+ for (uint32_t i = 0; i < cpunum; i++) {
|
||||
+ /* skip stack cpu */
|
||||
+ if (CPU_ISSET(cpulist[i], exclude)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ CPU_SET(cpulist[i], &stack->idle_cpuset);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int32_t init_stack_numa_cpuset(struct protocol_stack *stack)
|
||||
+{
|
||||
+ int32_t ret;
|
||||
+ struct cfg_params *cfg = get_global_cfg_params();
|
||||
+
|
||||
+ cpu_set_t stack_cpuset;
|
||||
+ CPU_ZERO(&stack_cpuset);
|
||||
+ for (int32_t idx = 0; idx < cfg->num_cpu; ++idx) {
|
||||
+ CPU_SET(cfg->cpus[idx], &stack_cpuset);
|
||||
+ }
|
||||
+
|
||||
+ for (int32_t idx = 0; idx < cfg->app_exclude_num_cpu; ++idx) {
|
||||
+ CPU_SET(cfg->app_exclude_cpus[idx], &stack_cpuset);
|
||||
+ }
|
||||
+
|
||||
+ ret = stack_idle_cpuset(stack, &stack_cpuset);
|
||||
+ if (ret < 0) {
|
||||
+ LSTACK_LOG(ERR, LSTACK, "thread_get_cpuset stack(%u) failed\n", stack->tid);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static uint32_t get_protocol_traffic(struct protocol_stack *stack)
|
||||
{
|
||||
if (use_ltran()) {
|
||||
@@ -412,12 +481,13 @@ static struct protocol_stack *stack_thread_init(void *arg)
|
||||
goto END;
|
||||
}
|
||||
|
||||
- if (thread_affinity_init(stack->cpu_id) != 0) {
|
||||
- goto END;
|
||||
- }
|
||||
-
|
||||
if (get_global_cfg_params()->stack_num == 0) {
|
||||
+ if (stack_affinity_cpu(stack->cpu_id) != 0) {
|
||||
+ goto END;
|
||||
+ }
|
||||
RTE_PER_LCORE(_lcore_id) = stack->cpu_id;
|
||||
+ } else {
|
||||
+ stack_affinity_numa(stack->numa_id);
|
||||
}
|
||||
|
||||
lwip_init();
|
||||
diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h
|
||||
index 0fd5323..07a97cb 100644
|
||||
--- a/src/lstack/include/lstack_cfg.h
|
||||
+++ b/src/lstack/include/lstack_cfg.h
|
||||
@@ -36,7 +36,6 @@
|
||||
#define RX_RING_NAME 64
|
||||
#define MBUF_POOL_NAME 64
|
||||
|
||||
-#define CFG_MAX_CPUS 512
|
||||
#define CFG_MAX_PORTS UINT8_MAX
|
||||
#define ARP_MAX_ENTRIES 1024
|
||||
#define LOG_DIR_PATH PATH_MAX
|
||||
@@ -118,12 +117,12 @@ struct cfg_params {
|
||||
uint16_t num_cpu;
|
||||
uint16_t numa_id;
|
||||
uint16_t stack_num;
|
||||
- uint32_t cpus[CFG_MAX_CPUS];
|
||||
+ uint32_t cpus[CPUS_MAX_NUM];
|
||||
|
||||
bool main_thread_affinity;
|
||||
bool app_bind_numa;
|
||||
uint16_t app_exclude_num_cpu;
|
||||
- uint32_t app_exclude_cpus[CFG_MAX_CPUS];
|
||||
+ uint32_t app_exclude_cpus[CPUS_MAX_NUM];
|
||||
|
||||
bool stack_mode_rtc;
|
||||
bool listen_shadow; // true:listen in all stack thread. false:listen in one stack thread.
|
||||
@@ -168,10 +167,8 @@ static inline uint8_t use_ltran(void)
|
||||
|
||||
int cfg_init(void);
|
||||
int gazelle_param_init(int *argc, char **argv);
|
||||
-int gazelle_copy_param(const char *param, bool is_double,
|
||||
- int *argc, char argv[][PATH_MAX]);
|
||||
-
|
||||
+int gazelle_copy_param(const char *param, bool is_double, int *argc, char argv[][PATH_MAX]);
|
||||
int match_host_addr(ip_addr_t *addr);
|
||||
-int32_t init_stack_numa_cpuset(struct protocol_stack *stack);
|
||||
+int numa_to_cpusnum(uint16_t numa_id, uint32_t *cpulist, int num);
|
||||
|
||||
#endif /* GAZELLE_NET_CFG_H */
|
||||
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
|
||||
index 87219c2..c2142d6 100644
|
||||
--- a/src/lstack/include/lstack_dpdk.h
|
||||
+++ b/src/lstack/include/lstack_dpdk.h
|
||||
@@ -45,7 +45,6 @@ int dpdk_ethdev_start(void);
|
||||
int init_dpdk_ethdev(void);
|
||||
|
||||
int thread_affinity_default(void);
|
||||
-int thread_affinity_init(int cpu_id);
|
||||
|
||||
int32_t create_shared_ring(struct protocol_stack *stack);
|
||||
int32_t fill_mbuf_to_ring(struct rte_mempool *mempool, struct rte_ring *ring, uint32_t mbuf_num);
|
||||
--
|
||||
2.33.0
|
||||
|
||||
125
0297-openGauss-support-kernel-connnect.patch
Normal file
125
0297-openGauss-support-kernel-connnect.patch
Normal file
@ -0,0 +1,125 @@
|
||||
From b29d2ce72651ac91728278cb9b31029b397c6ea5 Mon Sep 17 00:00:00 2001
|
||||
From: hankangkang <hankangkang5@huawei.com>
|
||||
Date: Wed, 27 Nov 2024 09:50:08 +0800
|
||||
Subject: [PATCH] openGauss: support kernel connnect
|
||||
|
||||
Signed-off-by: hankangkang <hankangkang5@huawei.com>
|
||||
---
|
||||
src/lstack/api/lstack_wrap.c | 71 ++++++++++++++++++++++++++++--------
|
||||
1 file changed, 56 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c
|
||||
index d22847a..4416bd8 100644
|
||||
--- a/src/lstack/api/lstack_wrap.c
|
||||
+++ b/src/lstack/api/lstack_wrap.c
|
||||
@@ -250,7 +250,7 @@ static int32_t do_bind(int32_t s, const struct sockaddr *name, socklen_t namelen
|
||||
return g_wrap_api->bind_fn(s, name, namelen);
|
||||
}
|
||||
|
||||
-static bool is_dst_ip_localhost(const struct sockaddr *addr)
|
||||
+static bool kernel_ip_route(const struct sockaddr *addr)
|
||||
{
|
||||
struct ifaddrs *ifap;
|
||||
struct ifaddrs *ifa;
|
||||
@@ -292,43 +292,84 @@ static bool is_dst_ip_localhost(const struct sockaddr *addr)
|
||||
freeifaddrs(ifap);
|
||||
return false;
|
||||
}
|
||||
+static bool is_relatived_kernel_ip(const struct sockaddr *dst_addr)
|
||||
+{
|
||||
+ struct ifaddrs *ifap;
|
||||
+ struct ifaddrs *ifa;
|
||||
+ uint32_t local_ip;
|
||||
+ uint32_t local_mask;
|
||||
+ uint32_t dst_ip;
|
||||
+ bool ret = false;
|
||||
+
|
||||
+ if (getifaddrs(&ifap) == -1) {
|
||||
+ LSTACK_LOG(ERR, LSTACK, "get interface IP address failed\n");
|
||||
+ return false;
|
||||
+ }
|
||||
|
||||
-static int32_t do_connect(int32_t s, const struct sockaddr *name, socklen_t namelen)
|
||||
+ for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
+ if (ifa->ifa_addr == NULL) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (ifa->ifa_addr->sa_family == AF_INET) {
|
||||
+ struct sockaddr_in *if_addr = (struct sockaddr_in *)ifa->ifa_addr;
|
||||
+ if (get_global_cfg_params()->host_addr.addr == if_addr->sin_addr.s_addr) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (ifa->ifa_addr->sa_family == AF_INET && dst_addr->sa_family == AF_INET) {
|
||||
+ struct sockaddr_in *if_addr = (struct sockaddr_in *)ifa->ifa_addr;
|
||||
+ struct sockaddr_in *ifa_netmask = (struct sockaddr_in *)ifa->ifa_netmask;
|
||||
+ local_ip = if_addr->sin_addr.s_addr;
|
||||
+ local_mask = ifa_netmask->sin_addr.s_addr;
|
||||
+ dst_ip = ((struct sockaddr_in *)dst_addr) ->sin_addr.s_addr;
|
||||
+ if ((local_ip & local_mask) == (dst_ip & local_mask)) {
|
||||
+ ret = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ freeifaddrs(ifap);
|
||||
+ return ret;
|
||||
+}
|
||||
+static int32_t do_connect(int32_t s, const struct sockaddr *addr, socklen_t addrlen)
|
||||
{
|
||||
- if (name == NULL) {
|
||||
+ if (addr == NULL) {
|
||||
GAZELLE_RETURN(EINVAL);
|
||||
}
|
||||
|
||||
struct lwip_sock *sock = lwip_get_socket(s);
|
||||
if (select_sock_posix_path(sock) == POSIX_KERNEL) {
|
||||
- return posix_api->connect_fn(s, name, namelen);
|
||||
+ return posix_api->connect_fn(s, addr, addrlen);
|
||||
}
|
||||
|
||||
int32_t ret = 0;
|
||||
int32_t remote_port;
|
||||
- bool is_local = is_dst_ip_localhost(name);
|
||||
+ bool is_kernel = kernel_ip_route(addr);
|
||||
+ bool is_to_kernel_connect = is_relatived_kernel_ip(addr);
|
||||
|
||||
- remote_port = htons(((struct sockaddr_in *)name)->sin_port);
|
||||
+ remote_port = htons(((struct sockaddr_in *)addr)->sin_port);
|
||||
|
||||
char listen_ring_name[RING_NAME_LEN];
|
||||
snprintf_s(listen_ring_name, sizeof(listen_ring_name), sizeof(listen_ring_name) - 1,
|
||||
"listen_rx_ring_%d", remote_port);
|
||||
- if (is_local && rte_ring_lookup(listen_ring_name) == NULL) {
|
||||
- ret = posix_api->connect_fn(s, name, namelen);
|
||||
+
|
||||
+ if ((is_kernel && rte_ring_lookup(listen_ring_name) == NULL) || is_to_kernel_connect) {
|
||||
+ ret = posix_api->connect_fn(s, addr, addrlen);
|
||||
POSIX_SET_TYPE(sock, POSIX_KERNEL);
|
||||
} else {
|
||||
/* When the socket is POSIX_LWIP_OR_KERNEL, connect to lwip first and then connect to kernel. */
|
||||
- ret = g_wrap_api->connect_fn(s, name, namelen);
|
||||
+ ret = g_wrap_api->connect_fn(s, addr, addrlen);
|
||||
if (ret == 0 || (ret != 0 && errno == EINPROGRESS)) {
|
||||
POSIX_SET_TYPE(sock, POSIX_LWIP);
|
||||
- } else {
|
||||
- ret = posix_api->connect_fn(s, name, namelen);
|
||||
+ } else {
|
||||
+ ret = posix_api->connect_fn(s, addr, addrlen);
|
||||
if (ret == 0) {
|
||||
- POSIX_SET_TYPE(sock, POSIX_KERNEL);
|
||||
- }
|
||||
- }
|
||||
+ POSIX_SET_TYPE(sock, POSIX_KERNEL);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
-
|
||||
return ret;
|
||||
}
|
||||
|
||||
--
|
||||
2.33.0
|
||||
|
||||
24
gazelle.spec
24
gazelle.spec
@ -2,7 +2,7 @@
|
||||
|
||||
Name: gazelle
|
||||
Version: 1.0.2
|
||||
Release: 76
|
||||
Release: 77
|
||||
Summary: gazelle is a high performance user-mode stack
|
||||
License: MulanPSL-2.0
|
||||
URL: https://gitee.com/openeuler/gazelle
|
||||
@ -304,6 +304,16 @@ Patch9284: 0284-support-auto-set-xdp-addr.patch
|
||||
Patch9285: 0285-suport-kernel-accept-for-openGauss.patch
|
||||
Patch9286: 0286-openGauss-support-kernel-accept4.patch
|
||||
Patch9287: 0287-socket-init-wakeup-in-blocking-socket.patch
|
||||
Patch9288: 0288-fix-socket-of-control-thread-is-overwirtten-due-to-a.patch
|
||||
Patch9289: 0289-LWIP-adjust-position-of-shutdown-in-callback-of-conn.patch
|
||||
Patch9290: 0290-Fix-the-wrong-spelling-description-in-the-notes-and-.patch
|
||||
Patch9291: 0291-update-test-unitest-ltran-ltran_param_test.c.patch
|
||||
Patch9292: 0292-fix-free-null-pointer-when-no-matching-device-is-fou.patch
|
||||
Patch9293: 0293-cfg-show-dpdk-args-after-dpdk_adjust_args.patch
|
||||
Patch9294: 0294-fix-build-error-in-2003SP4.patch
|
||||
Patch9295: 0295-CFG-fix-xdp-iface-check-error.patch
|
||||
Patch9296: 0296-xdp-support-stack-bind-numa.patch
|
||||
Patch9297: 0297-openGauss-support-kernel-connnect.patch
|
||||
|
||||
%description
|
||||
%{name} is a high performance user-mode stack.
|
||||
@ -345,6 +355,18 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b
|
||||
%config(noreplace) %{conf_path}/ltran.conf
|
||||
|
||||
%changelog
|
||||
* Wed Nov 27 2024 yinbin <yinbin8@huawei.com> - 1.0.2-77
|
||||
- openGauss: support kernel connnect
|
||||
- xdp: support stack bind numa
|
||||
- CFG: fix xdp iface check error
|
||||
- fix build error in 2003SP4
|
||||
- cfg: show dpdk args after dpdk_adjust_args
|
||||
- fix free null pointer when no matching device is found
|
||||
- update test/unitest/ltran/ltran_param_test.c.
|
||||
- Fix the wrong spelling description in the notes and logs
|
||||
- LWIP: adjust position of shutdown in callback of connect
|
||||
- fix socket of control thread is overwirtten due to another primary process start
|
||||
|
||||
* Wed Nov 20 2024 yinbin <yinbin8@huawei.com> - 1.0.2-76
|
||||
- socket: init wakeup in blocking socket
|
||||
- openGauss: support kernel accept4
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user