From c5143b13679a8c6545774a936011882a011d9a82 Mon Sep 17 00:00:00 2001 From: yinbin Date: Wed, 29 Nov 2023 15:01:29 +0800 Subject: [PATCH] sync support vlan offload (cherry picked from commit 6a6a7340497bb871db688bc401e4ecb97339dc06) --- 0053-add-gazelle-log.patch | 258 +++++++++++++++++ ...og-info-while-there-are-repeated-ite.patch | 43 +++ 0055-add-gazelle-log.patch | 100 +++++++ ...-wrong-port-after-addr-bind-two-port.patch | 38 +++ 0057-cfg-rm-ipv6_enable.patch | 88 ++++++ 0058-ltran-support-vlan.patch | 102 +++++++ 0059-update-src-ltran-ltran_param.c.patch | 33 +++ 0060-dfx-support-bond-get-dpdk-xstats.patch | 262 ++++++++++++++++++ 0061-add-tcp-faste-timer-cnt.patch | 73 +++++ ...ump-caused-by-gazelleclt-in-rtc-mode.patch | 124 +++++++++ ...xception-and-kernel-event-statistics.patch | 109 ++++++++ 0064-add-vlan_id-in-netif.patch | 88 ++++++ 0065-support-vlan-offload.patch | 89 ++++++ gazelle.spec | 32 ++- 14 files changed, 1436 insertions(+), 3 deletions(-) create mode 100644 0053-add-gazelle-log.patch create mode 100644 0054-PRE_LOG-modify-log-info-while-there-are-repeated-ite.patch create mode 100644 0055-add-gazelle-log.patch create mode 100644 0056-wrap-fix-connect-wrong-port-after-addr-bind-two-port.patch create mode 100644 0057-cfg-rm-ipv6_enable.patch create mode 100644 0058-ltran-support-vlan.patch create mode 100644 0059-update-src-ltran-ltran_param.c.patch create mode 100644 0060-dfx-support-bond-get-dpdk-xstats.patch create mode 100644 0061-add-tcp-faste-timer-cnt.patch create mode 100644 0062-stack-fix-coredump-caused-by-gazelleclt-in-rtc-mode.patch create mode 100644 0063-dfx-add-tcp-exception-and-kernel-event-statistics.patch create mode 100644 0064-add-vlan_id-in-netif.patch create mode 100644 0065-support-vlan-offload.patch diff --git a/0053-add-gazelle-log.patch b/0053-add-gazelle-log.patch new file mode 100644 index 0000000..ec5036a --- /dev/null +++ b/0053-add-gazelle-log.patch @@ -0,0 +1,258 @@ +From 9980175dfd8e33ed17bbe928c5adaeee10907e4b Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Sat, 18 Nov 2023 10:28:59 +0800 +Subject: [PATCH] add gazelle log + +--- + src/common/gazelle_dfx_msg.c | 6 ++--- + src/lstack/core/lstack_control_plane.c | 9 ++++++++ + src/lstack/core/lstack_dpdk.c | 31 ++++++++++++++++++++------ + 3 files changed, 36 insertions(+), 10 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.c b/src/common/gazelle_dfx_msg.c +index b8472be..5fe4e06 100644 +--- a/src/common/gazelle_dfx_msg.c ++++ b/src/common/gazelle_dfx_msg.c +@@ -32,16 +32,16 @@ int read_specied_len(int fd, char *buf, size_t target_size) + printf("read_specied_len:: poll ret=%d \n", ret); + return -1; + } else if (ret == 0) { +- printf("read_specied_len:: time out"); ++ printf("read_specied_len:: time out \n"); + return -1; + } + if (fds[0].revents & POLLIN) { + int n = read(fd, buf + total_read, target_size - total_read); + if (n < 0) { +- printf("read_specied_len:: read ret=%d", ret); ++ printf("read_specied_len:: read ret=%d \n", ret); + return -1; + } else if (n == 0) { +- printf("read_specied_len:: Connection closed"); ++ printf("read_specied_len:: Connection closed \n"); + return -1; + } + total_read += n; +diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c +index be156dc..746c209 100644 +--- a/src/lstack/core/lstack_control_plane.c ++++ b/src/lstack/core/lstack_control_plane.c +@@ -134,11 +134,13 @@ static int32_t msg_proc_init(enum request_type rqt_type, struct reg_request_msg + + ret = strncpy_s(conf->file_prefix, PATH_MAX, global_params->sec_attach_arg.file_prefix, PATH_MAX - 1); + if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "strncpy_s fail ret=%d \n", ret); + return ret; + } + + ret = memcpy_s(conf->mac_addr, ETHER_ADDR_LEN, global_params->mac_addr, ETHER_ADDR_LEN); + if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "memcpy_s fail ret=%d \n", ret); + return ret; + } + switch (rqt_type) { +@@ -153,14 +155,17 @@ static int32_t msg_proc_init(enum request_type rqt_type, struct reg_request_msg + conf->argc = 0; + ret = gazelle_copy_param(OPT_SOCKET_MEM, true, (int32_t *)&conf->argc, conf->argv); + if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "gazelle_copy_param OPT_SOCKET_MEM fail ret=%d \n", ret); + return ret; + } + ret = gazelle_copy_param(OPT_FILE_PREFIX, true, (int32_t *)&conf->argc, conf->argv); + if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "gazelle_copy_param OPT_FILE_PREFIX fail ret=%d \n", ret); + return ret; + } + ret = gazelle_copy_param(OPT_LEGACY_MEM, false, (int32_t *)&conf->argc, conf->argv); + if (ret != EOK) { ++ LSTACK_LOG(ERR, LSTACK, "gazelle_copy_param OPT_LEGACY_MEM fail ret=%d \n", ret); + return ret; + } + +@@ -494,6 +499,7 @@ int32_t control_init_client(bool is_reconnect) + + ret = client_reg_proc_memory(is_reconnect); + if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "client_reg_proc_memory ret=%d \n", ret); + posix_api->close_fn(g_data_fd); + g_data_fd = -1; + return -1; +@@ -501,6 +507,7 @@ int32_t control_init_client(bool is_reconnect) + + ret = client_reg_proc_attach(is_reconnect); + if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "client_reg_proc_memory ret=%d \n", ret); + posix_api->close_fn(g_data_fd); + g_data_fd = -1; + return -1; +@@ -636,12 +643,14 @@ static int32_t client_reg_proc_reconnect(int32_t epfd) + /* longterm connect g_data_fd; init process info */ + ret = control_init_client(true); + if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "control_init_client fail ret=%d\n", ret); + return -1; + } + sockfd = g_data_fd; + + ret = thread_register(); + if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "thread_register fail ret=%d\n", ret); + posix_api->close_fn(sockfd); + g_data_fd = -1; + return -1; +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index da6eda0..966507f 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -75,15 +75,20 @@ int32_t thread_affinity_default(void) + { + static cpu_set_t cpuset; + static bool first_flags = true; ++ int ret = 0; + if (first_flags) { + CPU_ZERO(&cpuset); +- if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset) != 0) { ++ ret = pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "pthread_getaffinity_np fail ret=%d\n", ret); + return -1; + } + first_flags = false; + } else { + /* cancel the core binding from DPDK initialization */ +- if (pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset) != 0) { ++ ret = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "pthread_setaffinity_np fail ret=%d\n", ret); + return -1; + } + } +@@ -167,6 +172,7 @@ static struct rte_mempool* get_pktmbuf_mempool(const char *name, uint16_t queue_ + + ret = snprintf_s(pool_name, sizeof(pool_name), PATH_MAX - 1, "%s_%hu", name, queue_id); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "snprintf_s fail ret=%d\n", ret); + return NULL; + } + pool = rte_mempool_lookup(pool_name); +@@ -185,6 +191,7 @@ static struct reg_ring_msg *create_reg_mempool(const char *name, uint16_t queue_ + + ret = snprintf_s(pool_name, sizeof(pool_name), PATH_MAX - 1, "%s_%hu", name, queue_id); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "snprintf_s fail ret=%d\n", ret); + return NULL; + } + +@@ -205,12 +212,14 @@ int32_t pktmbuf_pool_init(struct protocol_stack *stack, uint16_t stack_num) + + stack->rxtx_pktmbuf_pool = get_pktmbuf_mempool("rxtx_mbuf", stack->queue_id); + if (stack->rxtx_pktmbuf_pool == NULL) { ++ LSTACK_LOG(ERR, LSTACK, "rxtx_pktmbuf_pool is NULL\n"); + return -1; + } + + if (use_ltran()) { + stack->reg_buf = create_reg_mempool("reg_ring_msg", stack->queue_id); + if (stack->reg_buf == NULL) { ++ LSTACK_LOG(ERR, LSTACK, "rxtx_pktmbuf_pool is NULL\n"); + return -1; + } + } +@@ -226,6 +235,7 @@ struct rte_mempool *create_mempool(const char *name, uint32_t count, uint32_t si + int32_t ret = snprintf_s(pool_name, sizeof(pool_name), RTE_MEMPOOL_NAMESIZE - 1, + "%s_%d", name, idx); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "snprintf_s fail ret=%d\n", ret); + return NULL; + } + +@@ -246,6 +256,7 @@ struct rte_ring *create_ring(const char *name, uint32_t count, uint32_t flags, i + int32_t ret = snprintf_s(ring_name, sizeof(ring_name), RTE_RING_NAMESIZE - 1, + "%s_%d_%d", name, get_global_cfg_params()->process_idx, queue_id); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "snprintf_s fail ret=%d\n", ret); + return NULL; + } + +@@ -286,6 +297,8 @@ int32_t dpdk_alloc_pktmbuf(struct rte_mempool *pool, struct rte_mbuf **mbufs, ui + { + int32_t ret = rte_pktmbuf_alloc_bulk(pool, mbufs, num); + if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_pktmbuf_alloc_bulk fail allocNum=%d, ret=%d, info:=%s \n", ++ num, ret, rte_strerror(-ret)); + return ret; + } + +@@ -477,6 +490,7 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + if (get_global_cfg_params()->bond_mode < 0) { + port_id = ethdev_port_id(get_global_cfg_params()->mac_addr); + if (port_id < 0) { ++ LSTACK_LOG(ERR, LSTACK, "ethdev_port_id FAIL port_id=%d\n", port_id); + return port_id; + } + } +@@ -589,7 +603,7 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + + ret = dpdk_ethdev_start(); + if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_start failed\n"); ++ LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_start failed ret=%d\n", ret); + stack_group->eth_params = NULL; + free(eth_params); + return ret; +@@ -644,6 +658,7 @@ int32_t dpdk_ethdev_start(void) + for (int32_t i = 0; i < get_global_cfg_params()->tot_queue_num; i++) { + ret = dpdk_ethdev_setup(stack_group->eth_params, i); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_setup fail queueid=%d, ret=%d\n", i, ret); + return ret; + } + } +@@ -666,11 +681,13 @@ int32_t dpdk_init_lstack_kni(void) + struct protocol_stack_group *stack_group = get_protocol_stack_group(); + stack_group->kni_pktmbuf_pool = create_pktmbuf_mempool("kni_mbuf", KNI_NB_MBUF, 0, 0, rte_socket_id()); + if (stack_group->kni_pktmbuf_pool == NULL) { ++ LSTACK_LOG(ERR, LSTACK, "kni_mbuf is NULL\n"); + return -1; + } + + int32_t ret = dpdk_kni_init(stack_group->port_id, stack_group->kni_pktmbuf_pool); + if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk_kni_init fail ret=%d\n", ret); + return -1; + } + +@@ -706,18 +723,18 @@ int32_t init_dpdk_ethdev(void) + } + + ret = dpdk_ethdev_init(bond_port_id, 1); +- if (ret != 0) { ++ if (ret != 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed ret = %d\n", ret); + return -1; + } + + ret = rte_eth_bond_xmit_policy_set(bond_port_id, BALANCE_XMIT_POLICY_LAYER34); + if (ret < 0) { +- LSTACK_LOG(ERR, LSTACK, "dpdk set bond xmit policy failed ret = %d\n", ret); ++ LSTACK_LOG(ERR, LSTACK, "dpdk set bond xmit policy failed ret = %d\n", ret); + return -1; + } + +- if (get_global_cfg_params()->bond_mode == BONDING_MODE_8023AD) { ++ if (get_global_cfg_params()->bond_mode == BONDING_MODE_8023AD) { + ret = rte_eth_bond_8023ad_dedicated_queues_enable(bond_port_id); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk enable 8023 dedicated queues failed ret = %d\n", ret); +@@ -743,7 +760,7 @@ int32_t init_dpdk_ethdev(void) + } + + ret = rte_eth_dev_start(bond_port_id); +- if (ret < 0) { ++ if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk start bond port failed ret = %d\n", ret); + return -1; + } +-- +2.27.0 + diff --git a/0054-PRE_LOG-modify-log-info-while-there-are-repeated-ite.patch b/0054-PRE_LOG-modify-log-info-while-there-are-repeated-ite.patch new file mode 100644 index 0000000..5345a88 --- /dev/null +++ b/0054-PRE_LOG-modify-log-info-while-there-are-repeated-ite.patch @@ -0,0 +1,43 @@ +From 38ce070bc6922470a92b925e030ba61586a6e92a Mon Sep 17 00:00:00 2001 +From: yinbin +Date: Mon, 20 Nov 2023 11:08:10 +0800 +Subject: [PATCH] PRE_LOG: modify log info while there are repeated items in + conf file + +--- + src/lstack/core/lstack_cfg.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 9f3143f..7a4504f 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -946,6 +946,7 @@ static int32_t parse_conf_file(const char *path) + int32_t ret; + + if (realpath(path, real_path) == NULL) { ++ LSTACK_PRE_LOG(LSTACK_ERR, "Config path error. Errno: %d. Please check conf file path: %s\n", errno, path); + return -1; + } + +@@ -953,7 +954,7 @@ static int32_t parse_conf_file(const char *path) + + ret = config_read_file(&g_config, real_path); + if (ret == 0) { +- LSTACK_PRE_LOG(LSTACK_ERR, "Config file path error, Please check conf file path.\n"); ++ LSTACK_PRE_LOG(LSTACK_ERR, "Read config file \"%s\" error: %s\n", real_path, config_error_text(&g_config)); + config_destroy(&g_config); + return -EINVAL; + } +@@ -961,7 +962,7 @@ static int32_t parse_conf_file(const char *path) + for (int32_t i = 0; g_config_tbl[i].name && g_config_tbl[i].f; ++i) { + ret = g_config_tbl[i].f(); + if (ret != 0) { +- LSTACK_PRE_LOG(LSTACK_ERR, "error parsing parameter '%s' ret=%d\n.", g_config_tbl[i].name, ret); ++ LSTACK_PRE_LOG(LSTACK_ERR, "error parsing parameter '%s' ret=%d.\n", g_config_tbl[i].name, ret); + config_destroy(&g_config); + return ret; + } +-- +2.27.0 + diff --git a/0055-add-gazelle-log.patch b/0055-add-gazelle-log.patch new file mode 100644 index 0000000..bd4827c --- /dev/null +++ b/0055-add-gazelle-log.patch @@ -0,0 +1,100 @@ +From c136185db539fe2a7de58a4677b293f0c24f0e2a Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Mon, 20 Nov 2023 09:56:50 +0800 +Subject: [PATCH] add gazelle log + +--- + src/lstack/api/lstack_epoll.c | 3 +++ + src/lstack/core/lstack_protocol_stack.c | 12 +++++++++--- + 2 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c +index f2c4a8b..eacbe33 100644 +--- a/src/lstack/api/lstack_epoll.c ++++ b/src/lstack/api/lstack_epoll.c +@@ -821,6 +821,7 @@ int32_t lstack_poll(struct pollfd *fds, nfds_t nfds, int32_t timeout) + if (wakeup == NULL) { + wakeup = calloc(1, sizeof(struct wakeup_poll)); + if (wakeup == NULL) { ++ LSTACK_LOG(ERR, LSTACK, "calloc failed errno=%d\n", errno); + GAZELLE_RETURN(EINVAL); + } + +@@ -938,10 +939,12 @@ static nfds_t fds_select2poll(int maxfd, fd_set *readfds, fd_set *writefds, fd_s + int lstack_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeval) + { + if (maxfd == 0) { ++ LSTACK_LOG(ERR, LSTACK, "select maxfd is zero\n"); + return 0; + } + + if (maxfd < 0 || maxfd > FD_SETSIZE || (readfds == NULL && writefds == NULL && exceptfds == NULL)) { ++ LSTACK_LOG(ERR, LSTACK, "select input param error, fd num=%d\n", maxfd); + GAZELLE_RETURN(EINVAL); + } + +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index 74a17d4..aedf9c5 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -325,6 +325,7 @@ static int32_t init_stack_value(struct protocol_stack *stack, void *arg) + + stack->epollfd = posix_api->epoll_create_fn(GAZELLE_LSTACK_MAX_CONN); + if (stack->epollfd < 0) { ++ LSTACK_LOG(ERR, LSTACK, "kernel epoll_create failed\n"); + return -1; + } + +@@ -349,10 +350,12 @@ static int32_t init_stack_value(struct protocol_stack *stack, void *arg) + } + + if (pktmbuf_pool_init(stack, stack_group->stack_num) != 0) { ++ LSTACK_LOG(ERR, LSTACK, "pktmbuf_pool_init failed\n"); + return -1; + } + + if (create_shared_ring(stack) != 0) { ++ LSTACK_LOG(ERR, LSTACK, "create_shared_ring failed\n"); + return -1; + } + +@@ -583,6 +586,7 @@ int32_t stack_group_init(void) + + if (get_global_cfg_params()->is_primary) { + if (stack_group_init_mempool() != 0) { ++ LSTACK_LOG(ERR, LSTACK, "stack group init mempool failed\n"); + return -1; + } + } +@@ -789,7 +793,8 @@ void stack_getsockopt(struct rpc_msg *msg) + msg->result = lwip_getsockopt(msg->args[MSG_ARG_0].i, msg->args[MSG_ARG_1].i, msg->args[MSG_ARG_2].i, + msg->args[MSG_ARG_3].p, msg->args[MSG_ARG_4].p); + if (msg->result != 0) { +- LSTACK_LOG(ERR, LSTACK, "tid %ld, fd %d fail %ld\n", get_stack_tid(), msg->args[MSG_ARG_0].i, msg->result); ++ LSTACK_LOG(ERR, LSTACK, "tid %ld, fd %d, level %d, optname %d, fail %ld\n", get_stack_tid(), ++ msg->args[MSG_ARG_0].i, msg->args[MSG_ARG_1].i, msg->args[MSG_ARG_2].i, msg->result); + } + } + +@@ -798,7 +803,8 @@ void stack_setsockopt(struct rpc_msg *msg) + msg->result = lwip_setsockopt(msg->args[MSG_ARG_0].i, msg->args[MSG_ARG_1].i, msg->args[MSG_ARG_2].i, + msg->args[MSG_ARG_3].cp, msg->args[MSG_ARG_4].socklen); + if (msg->result != 0) { +- LSTACK_LOG(ERR, LSTACK, "tid %ld, fd %d fail %ld\n", get_stack_tid(), msg->args[MSG_ARG_0].i, msg->result); ++ LSTACK_LOG(ERR, LSTACK, "tid %ld, fd %d, level %d, optname %d, fail %ld\n", get_stack_tid(), ++ msg->args[MSG_ARG_0].i, msg->args[MSG_ARG_1].i, msg->args[MSG_ARG_2].i, msg->result); + } + } + +@@ -834,7 +840,7 @@ void stack_send(struct rpc_msg *msg) + struct lwip_sock *sock = get_socket(fd); + if (sock == NULL) { + msg->result = -1; +- LSTACK_LOG(ERR, LSTACK, "stack_send: sock error!\n"); ++ LSTACK_LOG(ERR, LSTACK, "get sock error! fd=%d, len=%ld\n", fd, len); + rpc_msg_free(msg); + return; + } +-- +2.27.0 + diff --git a/0056-wrap-fix-connect-wrong-port-after-addr-bind-two-port.patch b/0056-wrap-fix-connect-wrong-port-after-addr-bind-two-port.patch new file mode 100644 index 0000000..5e42a15 --- /dev/null +++ b/0056-wrap-fix-connect-wrong-port-after-addr-bind-two-port.patch @@ -0,0 +1,38 @@ +From c7a9c71456844b164477f329f79f5e10de7898a4 Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Wed, 15 Nov 2023 11:23:04 +0800 +Subject: [PATCH] wrap: fix connect wrong port after addr bind two ports + +--- + src/lstack/api/lstack_wrap.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 5bad513..f427d33 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -219,7 +219,20 @@ static int32_t do_bind(int32_t s, const struct sockaddr *name, socklen_t namelen + + if (match_host_addr(((struct sockaddr_in *)name)->sin_addr.s_addr)) { + /* maybe kni addr */ +- posix_api->bind_fn(s, name, namelen); ++ if (posix_api->bind_fn(s, name, namelen) != 0) { ++ SET_CONN_TYPE_LIBOS(sock->conn); ++ } else { ++ /* reuse the port allocated by kernel when port == 0 */ ++ if (((struct sockaddr_in *)name)->sin_port == 0) { ++ struct sockaddr_in kerneladdr; ++ socklen_t len = sizeof(kerneladdr); ++ if (posix_api->getsockname_fn(s, (struct sockaddr *)&kerneladdr, &len) < 0) { ++ LSTACK_LOG(ERR, LSTACK, "kernel getsockname failed, fd=%d, errno=%d\n", s, errno); ++ return -1; ++ } ++ ((struct sockaddr_in *)name)->sin_port = kerneladdr.sin_port; ++ } ++ } + return g_wrap_api->bind_fn(s, name, namelen); + } else { + SET_CONN_TYPE_HOST(sock->conn); +-- +2.27.0 + diff --git a/0057-cfg-rm-ipv6_enable.patch b/0057-cfg-rm-ipv6_enable.patch new file mode 100644 index 0000000..799a8c4 --- /dev/null +++ b/0057-cfg-rm-ipv6_enable.patch @@ -0,0 +1,88 @@ +From d0c8c259add3b170e413d4c3a9e248ba3e550680 Mon Sep 17 00:00:00 2001 +From: zhengjiebing +Date: Thu, 23 Nov 2023 11:19:01 +0800 +Subject: [PATCH] cfg: rm ipv6_enable + +--- + src/lstack/api/lstack_wrap.c | 2 +- + src/lstack/core/lstack_cfg.c | 8 -------- + src/lstack/include/lstack_cfg.h | 1 - + src/lstack/netif/lstack_ethdev.c | 4 ++-- + 4 files changed, 3 insertions(+), 12 deletions(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 43b9dad..abbf8a1 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -384,7 +384,7 @@ static inline int32_t do_socket(int32_t domain, int32_t type, int32_t protocol) + } + + if ((domain != AF_INET && domain != AF_UNSPEC && domain != AF_INET6) || +- ((domain == AF_INET6) && !get_global_cfg_params()->ipv6_enable) || ++ ((domain == AF_INET6) && ip6_addr_isany(&get_global_cfg_params()->host_addr6)) || + ((type & SOCK_DGRAM) && !get_global_cfg_params()->udp_enable)) { + return posix_api->socket_fn(domain, type, protocol); + } +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 7a4504f..d1cbd1d 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -76,7 +76,6 @@ static int32_t parse_bond_mode(void); + static int32_t parse_bond_slave_mac(void); + static int32_t parse_use_sockmap(void); + static int32_t parse_udp_enable(void); +-static int32_t parse_ipv6_enable(void); + static int32_t parse_nic_rxqueue_size(void); + static int32_t parse_nic_txqueue_size(void); + static int32_t parse_stack_thread_mode(void); +@@ -139,7 +138,6 @@ static struct config_vector_t g_config_tbl[] = { + { "bond_slave_mac", parse_bond_slave_mac }, + { "use_sockmap", parse_use_sockmap }, + { "udp_enable", parse_udp_enable }, +- { "ipv6_enable", parse_ipv6_enable }, + { "nic_rxqueue_size", parse_nic_rxqueue_size}, + { "nic_txqueue_size", parse_nic_txqueue_size}, + { "stack_thread_mode", parse_stack_thread_mode }, +@@ -1271,9 +1269,3 @@ static int32_t parse_nic_vlan_mode(void) + return ret; + } + +-static int32_t parse_ipv6_enable(void) +-{ +- int32_t ret; +- PARSE_ARG(g_config_params.ipv6_enable, "ipv6_enable", 0, 0, 1, ret); +- return ret; +-} +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index e3edc57..26da357 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -117,7 +117,6 @@ struct cfg_params { + struct rte_ether_addr bond_slave_mac_addr[GAZELLE_MAX_BOND_NUM]; + bool use_sockmap; + bool udp_enable; +- bool ipv6_enable; + struct cfg_nic_params nic; + bool stack_mode_rtc; + }; +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 02aa611..9912858 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -961,11 +961,11 @@ int32_t ethdev_init(struct protocol_stack *stack) + } + if (netif == NULL) { + LSTACK_LOG(ERR, LSTACK, "netif_add failed\n"); +- return ERR_IF; ++ return ERR_IF; + } + if (!ip6_addr_isany(&cfg->host_addr6)) { + netif_ip6_addr_set(&stack->netif, 0, &cfg->host_addr6); +- netif_ip6_addr_set_state(&stack->netif, 0, IP6_ADDR_VALID); ++ netif_ip6_addr_set_state(&stack->netif, 0, IP6_ADDR_VALID); + } + + netif_set_link_up(&stack->netif); +-- +2.27.0 + diff --git a/0058-ltran-support-vlan.patch b/0058-ltran-support-vlan.patch new file mode 100644 index 0000000..f3d9370 --- /dev/null +++ b/0058-ltran-support-vlan.patch @@ -0,0 +1,102 @@ +From 0b7daa128d4b6dc231814537594158f8d928ef6c Mon Sep 17 00:00:00 2001 +From: zhengjiebing +Date: Thu, 23 Nov 2023 16:20:50 +0800 +Subject: [PATCH] ltran support vlan + +--- + src/ltran/ltran_forward.c | 35 ++++++++++++++++++++++++++++------- + 1 file changed, 28 insertions(+), 7 deletions(-) + +diff --git a/src/ltran/ltran_forward.c b/src/ltran/ltran_forward.c +index b41e1e2..a6f2d71 100644 +--- a/src/ltran/ltran_forward.c ++++ b/src/ltran/ltran_forward.c +@@ -281,14 +281,26 @@ static __rte_always_inline int32_t tcp_handle(struct rte_mbuf *m, const struct r + return GAZELLE_OK; + } + ++static uint32_t get_vlan_offset(const struct rte_mbuf *m) ++{ ++ uint32_t offset = 0; ++ struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); ++ u16_t type = ethh->ether_type; ++ if (type == PP_HTONS(RTE_ETHER_TYPE_VLAN)) { ++ offset += sizeof(struct rte_vlan_hdr); ++ } ++ return offset; ++} ++ + static struct gazelle_stack* get_icmp_handle_stack(const struct rte_mbuf *m) + { + int32_t i; + struct gazelle_stack** stack_array = NULL; + struct rte_ipv4_hdr *ipv4_hdr = NULL; + struct gazelle_instance *instance = NULL; ++ uint32_t offset = get_vlan_offset(m); + +- ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); ++ ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr) + offset); + instance = gazelle_instance_get_by_ip(get_instance_mgr(), ipv4_hdr->dst_addr); + if (instance == NULL) { + return NULL; +@@ -321,10 +333,11 @@ static __rte_always_inline int32_t ipv4_handle(struct rte_mbuf *m, struct rte_ip + { + struct rte_tcp_hdr *tcp_hdr = NULL; + int32_t ret = -1; ++ uint32_t offset = get_vlan_offset(m); + + if (likely(ipv4_hdr->next_proto_id == IPPROTO_TCP)) { + tcp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *, sizeof(struct rte_ether_hdr) + +- sizeof(struct rte_ipv4_hdr)); ++ sizeof(struct rte_ipv4_hdr) + offset); + get_statistics()->port_stats[g_port_index].tcp_pkt++; + ret = tcp_handle(m, ipv4_hdr, tcp_hdr); + } else if (ipv4_hdr->next_proto_id == IPPROTO_ICMP) { +@@ -336,7 +349,8 @@ static __rte_always_inline int32_t ipv4_handle(struct rte_mbuf *m, struct rte_ip + + static __rte_always_inline void arp_handle(struct rte_mbuf *m) + { +- struct rte_arp_hdr *arph = rte_pktmbuf_mtod_offset(m, struct rte_arp_hdr *, sizeof(struct rte_ether_hdr)); ++ uint32_t offset = get_vlan_offset(m); ++ struct rte_arp_hdr *arph = rte_pktmbuf_mtod_offset(m, struct rte_arp_hdr *, sizeof(struct rte_ether_hdr) + offset); + + get_statistics()->port_stats[g_port_index].arp_pkt++; + +@@ -367,14 +381,14 @@ static __rte_always_inline void arp_handle(struct rte_mbuf *m) + static __rte_always_inline void upstream_forward_one(struct rte_mbuf *m) + { + struct rte_ipv4_hdr *iph = NULL; +- struct rte_ether_hdr *ethh = NULL; + uint8_t ip_version; + const int32_t ipv4_version_offset = 4; + const int32_t ipv4_version = 4; ++ uint32_t offset = get_vlan_offset(m); + + get_statistics()->port_stats[g_port_index].rx_bytes += m->data_len; + +- iph = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr)); ++ iph = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, sizeof(struct rte_ether_hdr) + offset); + ip_version = (iph->version_ihl & 0xf0) >> ipv4_version_offset; + if (likely(ip_version == ipv4_version)) { + int32_t ret = ipv4_handle(m, iph); +@@ -385,8 +399,15 @@ static __rte_always_inline void upstream_forward_one(struct rte_mbuf *m) + goto forward_to_kni; + } + +- ethh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); +- if (unlikely(RTE_BE16(RTE_ETHER_TYPE_ARP) == ethh->ether_type)) { ++ uint16_t type = 0; ++ if (offset > 0) { ++ struct rte_vlan_hdr *vlan_hdr = rte_pktmbuf_mtod_offset(m, struct rte_vlan_hdr *, sizeof(struct rte_ether_hdr)); ++ type = vlan_hdr->eth_proto; ++ } else { ++ struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); ++ type = ethh->ether_type; ++ } ++ if (unlikely(RTE_BE16(RTE_ETHER_TYPE_ARP) == type)) { + arp_handle(m); + // arp packets are sent to kni by default + goto forward_to_kni; +-- +2.27.0 + diff --git a/0059-update-src-ltran-ltran_param.c.patch b/0059-update-src-ltran-ltran_param.c.patch new file mode 100644 index 0000000..1498d4f --- /dev/null +++ b/0059-update-src-ltran-ltran_param.c.patch @@ -0,0 +1,33 @@ +From a82c372c3dc55167b2a83a2f3b5632bd0771d306 Mon Sep 17 00:00:00 2001 +From: gaojiazhen +Date: Thu, 23 Nov 2023 17:43:11 +0000 +Subject: [PATCH] =?UTF-8?q?update=20src/ltran/ltran=5Fparam.c.=20=E8=A7=84?= + =?UTF-8?q?=E8=8C=83679=E8=A1=8C=E7=9A=84=E6=8A=A5=E9=94=99=E6=97=A5?= + =?UTF-8?q?=E5=BF=97=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=B0=86=E2=80=9C,?= + =?UTF-8?q?=E2=80=9D=E4=B9=8B=E5=90=8E=E7=9A=84=E2=80=9CPlease=E2=80=9D?= + =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=BA=E2=80=9Cplease=E2=80=9D?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: gaojiazhen +--- + src/ltran/ltran_param.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/ltran/ltran_param.c b/src/ltran/ltran_param.c +index e16e648..11a4bc8 100644 +--- a/src/ltran/ltran_param.c ++++ b/src/ltran/ltran_param.c +@@ -676,7 +676,7 @@ int32_t parse_config_file_args(const char *conf_file_path, struct ltran_config * + ret = config_read_file(&config, conf_file_path); + if (ret == 0) { + config_destroy(&config); +- syslog(LOG_ERR, "Err: Config file path %s error, Please check conf file path.\n", conf_file_path); ++ syslog(LOG_ERR, "Err: Config file path %s error, please check conf file path.\n", conf_file_path); + return -GAZELLE_EPATH; + } + +-- +2.27.0 + diff --git a/0060-dfx-support-bond-get-dpdk-xstats.patch b/0060-dfx-support-bond-get-dpdk-xstats.patch new file mode 100644 index 0000000..2f5b1e4 --- /dev/null +++ b/0060-dfx-support-bond-get-dpdk-xstats.patch @@ -0,0 +1,262 @@ +From 75e11463d7bd67732d3c7f0e7ed3a9dece8c4982 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Sat, 25 Nov 2023 09:26:23 +0800 +Subject: [PATCH] dfx: support bond get dpdk xstats + +--- + src/lstack/core/lstack_control_plane.c | 2 + + src/lstack/core/lstack_dpdk.c | 93 +++++++++++++++++++------ + src/lstack/core/lstack_protocol_stack.c | 2 +- + src/lstack/core/lstack_stack_stat.c | 14 ++-- + src/lstack/include/lstack_cfg.h | 1 - + src/lstack/include/lstack_dpdk.h | 1 - + src/lstack/include/lstack_stack_stat.h | 3 +- + src/lstack/netif/lstack_ethdev.c | 4 +- + 8 files changed, 89 insertions(+), 31 deletions(-) + +diff --git a/src/lstack/core/lstack_control_plane.c b/src/lstack/core/lstack_control_plane.c +index b97ee7f..4633834 100644 +--- a/src/lstack/core/lstack_control_plane.c ++++ b/src/lstack/core/lstack_control_plane.c +@@ -586,6 +586,8 @@ static int32_t handle_stat_request(int32_t sockfd) + if (msg.stat_mode == GAZELLE_STAT_LSTACK_LOG_LEVEL_SET || + msg.stat_mode == GAZELLE_STAT_LSTACK_LOW_POWER_MDF) { + return handle_proc_cmd(sockfd, &msg); ++ } else if (msg.stat_mode == GAZELLE_STAT_LSTACK_SHOW_XSTATS) { ++ return handle_dpdk_cmd(sockfd, msg.stat_mode); + } else { + ret = handle_stack_cmd(sockfd, msg.stat_mode); + if (ret != 0) { +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 703fd0d..19a7bf4 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -346,13 +346,6 @@ void lstack_log_level_init(void) + } + } + +-// get port id +-inline uint16_t get_port_id(void) +-{ +- uint16_t port_id = get_global_cfg_params()->port_id; +- return port_id; +-} +- + static int32_t ethdev_port_id(uint8_t *mac) + { + int32_t port_id; +@@ -497,8 +490,6 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + } + } + +- get_global_cfg_params()->port_id = port_id; +- + struct rte_eth_dev_info dev_info; + int32_t ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) { +@@ -814,23 +805,83 @@ bool port_in_stack_queue(ip_addr_t src_ip, ip_addr_t dst_ip, uint16_t src_port, + return (reta_index % stack_group->nb_queues) == stack->queue_id; + } + +-void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id) ++static int dpdk_nic_xstats_value_get(uint64_t *values, unsigned int len, uint16_t *ports, unsigned int count) + { +- int32_t ret; +- int32_t len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL); +- dfx->data.nic_xstats.len = len; +- dfx->data.nic_xstats.port_id = port_id; ++ uint64_t tmp_values[RTE_ETH_XSTATS_MAX_LEN]; ++ int p_idx; ++ int v_idx; ++ int ret; ++ ++ for (p_idx = 0; p_idx < count; p_idx++) { ++ ret = rte_eth_xstats_get_by_id(ports[p_idx], NULL, tmp_values, len); ++ if (ret < 0 || ret > len) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_xstats_get_by_id failed.\n"); ++ return -1; ++ } ++ ++ for (v_idx = 0; v_idx < len; v_idx++) { ++ values[v_idx] += tmp_values[v_idx]; ++ } ++ } ++ return 0; ++} ++ ++static int dpdk_nic_xstats_name_get(struct nic_eth_xstats_name *names, uint16_t port_id) ++{ ++ int len; ++ ++ len = rte_eth_xstats_get_names_by_id(port_id, NULL, 0, NULL); + if (len < 0) { +- return; ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_xstats_get_names_by_id failed.\n"); ++ return -1; ++ } ++ ++ if (len != rte_eth_xstats_get_names_by_id(port_id, (struct rte_eth_xstat_name *)names, len, NULL)) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_xstats_get_names_by_id failed.\n"); ++ return -1; + } +- if (len != rte_eth_xstats_get_names_by_id(port_id, +- (struct rte_eth_xstat_name *)dfx->data.nic_xstats.xstats_name, len, NULL)) { +- dfx->data.nic_xstats.len = -1; ++ ++ return len; ++} ++ ++void dpdk_nic_xstats_get(struct gazelle_stack_dfx_data *dfx, uint16_t port_id) ++{ ++ struct rte_eth_dev_info dev_info; ++ int len; ++ int ret; ++ ++ dfx->data.nic_xstats.len = -1; ++ dfx->data.nic_xstats.port_id = port_id; ++ ret = rte_eth_dev_info_get(port_id, &dev_info); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_dev_info_get failed.\n"); + return; + } + +- ret = rte_eth_xstats_get_by_id(port_id, NULL, dfx->data.nic_xstats.values, len); +- if (ret < 0 || ret > len) { +- dfx->data.nic_xstats.len = -1; ++ /* bond not support get xstats, we get xstats from slave device of bond */ ++ if (strcmp(dev_info.driver_name, "net_bonding") == 0) { ++ uint16_t slaves[RTE_MAX_ETHPORTS]; ++ int slave_count; ++ slave_count = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); ++ if (slave_count <= 0) { ++ LSTACK_LOG(ERR, LSTACK, "rte_eth_bond_slaves_get failed.\n"); ++ return; ++ } ++ len = dpdk_nic_xstats_name_get(dfx->data.nic_xstats.xstats_name, slaves[0]); ++ if (len <= 0) { ++ return; ++ } ++ if (dpdk_nic_xstats_value_get(dfx->data.nic_xstats.values, len, slaves, slave_count) != 0) { ++ return; ++ } ++ } else { ++ len = dpdk_nic_xstats_name_get(dfx->data.nic_xstats.xstats_name, port_id); ++ if (len <= 0) { ++ return; ++ } ++ if (dpdk_nic_xstats_value_get(dfx->data.nic_xstats.values, len, &port_id, 1) != 0) { ++ return; ++ } + } ++ dfx->data.nic_xstats.len = len; + } +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index cbc8b8f..dfebfcc 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -479,7 +479,7 @@ void stack_polling(uint32_t wakeup_tick) + if (kni_switch && !stack->queue_id && !(wakeup_tick & 0xfff)) { + rte_kni_handle_request(get_gazelle_kni()); + if (get_kni_started()) { +- kni_handle_rx(get_port_id()); ++ kni_handle_rx(stack->port_id); + } + } + return; +diff --git a/src/lstack/core/lstack_stack_stat.c b/src/lstack/core/lstack_stack_stat.c +index 60832b4..18548ab 100644 +--- a/src/lstack/core/lstack_stack_stat.c ++++ b/src/lstack/core/lstack_stack_stat.c +@@ -256,19 +256,25 @@ static int32_t send_control_cmd_data(int32_t fd, struct gazelle_stack_dfx_data * + return 0; + } + +-int32_t handle_stack_cmd(int32_t fd, enum GAZELLE_STAT_MODE stat_mode) ++int handle_dpdk_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode) + { + struct gazelle_stack_dfx_data dfx; +- struct protocol_stack_group *stack_group = get_protocol_stack_group(); + + if (stat_mode == GAZELLE_STAT_LSTACK_SHOW_XSTATS) { +- dpdk_nic_xstats_get(&dfx, get_port_id()); ++ dpdk_nic_xstats_get(&dfx, get_protocol_stack_group()->port_id); + dfx.tid = 0; + dfx.eof = 1; + send_control_cmd_data(fd, &dfx); +- return 0; + } + ++ return 0; ++} ++ ++int handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode) ++{ ++ struct gazelle_stack_dfx_data dfx; ++ struct protocol_stack_group *stack_group = get_protocol_stack_group(); ++ + for (uint32_t i = 0; i < stack_group->stack_num; i++) { + struct protocol_stack *stack = stack_group->stacks[i]; + +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index 26da357..e33f4fe 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -94,7 +94,6 @@ struct cfg_params { + + uint16_t num_process; + uint16_t num_listen_port; +- uint16_t port_id; + uint16_t is_primary; + uint16_t num_queue; + uint16_t tot_queue_num; +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index 3a621d0..e3daefa 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -55,7 +55,6 @@ void dpdk_skip_nic_init(void); + int32_t dpdk_init_lstack_kni(void); + void dpdk_restore_pci(void); + bool port_in_stack_queue(ip_addr_t src_ip, ip_addr_t dst_ip, uint16_t src_port, uint16_t dst_port); +-uint16_t get_port_id(void); + struct rte_mempool *create_pktmbuf_mempool(const char *name, uint32_t nb_mbuf, + uint32_t mbuf_cache_size, uint16_t queue_id, unsigned numa_id); + +diff --git a/src/lstack/include/lstack_stack_stat.h b/src/lstack/include/lstack_stack_stat.h +index 5737bae..d5a4ec7 100644 +--- a/src/lstack/include/lstack_stack_stat.h ++++ b/src/lstack/include/lstack_stack_stat.h +@@ -24,7 +24,8 @@ enum GAZELLE_STAT_MODE; + void calculate_lstack_latency(struct gazelle_stack_latency *stack_latency, const struct pbuf *pbuf, + enum GAZELLE_LATENCY_TYPE type); + void stack_stat_init(void); +-int32_t handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode); ++int handle_stack_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode); ++int handle_dpdk_cmd(int fd, enum GAZELLE_STAT_MODE stat_mode); + uint64_t get_current_time(void); + void lstack_get_low_power_info(struct gazelle_stat_low_power_info *low_power_info); + void unregister_wakeup(struct protocol_stack *stack, struct wakeup_poll *wakeup); +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 9912858..29bef21 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -330,7 +330,7 @@ struct rte_flow *create_flow_director(uint16_t port_id, uint16_t queue_id, + void config_flow_director(uint16_t queue_id, uint32_t src_ip, + uint32_t dst_ip, uint16_t src_port, uint16_t dst_port) + { +- uint16_t port_id = get_port_id(); ++ uint16_t port_id = get_protocol_stack_group()->port_id; + char rule_key[RULE_KEY_LEN] = {0}; + sprintf_s(rule_key, sizeof(rule_key), "%u_%u_%u", src_ip, src_port, dst_port); + struct flow_rule *fl_exist = find_rule(rule_key); +@@ -357,7 +357,7 @@ void config_flow_director(uint16_t queue_id, uint32_t src_ip, + + void delete_flow_director(uint32_t dst_ip, uint16_t src_port, uint16_t dst_port) + { +- uint16_t port_id = get_port_id(); ++ uint16_t port_id = get_protocol_stack_group()->port_id; + char rule_key[RULE_KEY_LEN] = {0}; + sprintf_s(rule_key, RULE_KEY_LEN, "%u_%u_%u",dst_ip, dst_port, src_port); + struct flow_rule *fl = find_rule(rule_key); +-- +2.27.0 + diff --git a/0061-add-tcp-faste-timer-cnt.patch b/0061-add-tcp-faste-timer-cnt.patch new file mode 100644 index 0000000..7052525 --- /dev/null +++ b/0061-add-tcp-faste-timer-cnt.patch @@ -0,0 +1,73 @@ +From 4098ba1fbc9f382d0f9d6b6b071d7ed9a2682cfc Mon Sep 17 00:00:00 2001 +From: hantwofish +Date: Fri, 24 Nov 2023 14:19:16 +0800 +Subject: [PATCH] add tcp faste timer cnt + +--- + src/common/gazelle_dfx_msg.h | 3 +++ + src/ltran/ltran_dfx.c | 28 ++++++++++++++++++---------- + 2 files changed, 21 insertions(+), 10 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index 93fe3df..8071108 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -117,6 +117,9 @@ struct gazelle_stat_lstack_snmp { + uint32_t tcp_in_seg; + uint32_t tcp_in_err; + uint32_t tcp_out_rst; ++ uint32_t tcp_fin_ack_cnt; ++ uint32_t tcp_delay_ack_cnt; ++ uint32_t tcp_refused_cnt; + + /* UDP */ + uint32_t udp_in_datagrams; +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index 582a4b7..98e23dc 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -825,6 +825,22 @@ static void gazelle_print_lstack_stat_rate(void *buf, const struct gazelle_stat_ + } while (true); + } + ++static void gazelle_print_lstack_tcp_stat(const struct gazelle_stat_lstack_snmp *snmp) ++{ ++ printf("tcp_act_open: %u\n", snmp->tcp_act_open); ++ printf("tcp_passive_open: %u\n", snmp->tcp_passive_open); ++ printf("tcp_attempt_fail: %u\n", snmp->tcp_attempt_fail); ++ printf("tcp_estab_rst: %u\n", snmp->tcp_estab_rst); ++ printf("tcp_out_seg: %u\n", snmp->tcp_out_seg); ++ printf("tcp_retran_seg: %u\n", snmp->tcp_retran_seg); ++ printf("tcp_in_seg: %u\n", snmp->tcp_in_seg); ++ printf("tcp_in_err: %u\n", snmp->tcp_in_err); ++ printf("tcp_out_rst: %u\n", snmp->tcp_out_rst); ++ printf("tcp_fin_ack_cnt: %u\n", snmp->tcp_fin_ack_cnt); ++ printf("tcp_delay_ack_cnt: %u\n", snmp->tcp_delay_ack_cnt); ++ printf("tcp_refused_cnt: %u\n", snmp->tcp_refused_cnt); ++} ++ + static void gazelle_print_lstack_stat_snmp_core(const struct gazelle_stack_dfx_data *stat, + const struct gazelle_stat_lstack_snmp *snmp) + { +@@ -850,16 +866,8 @@ static void gazelle_print_lstack_stat_snmp_core(const struct gazelle_stack_dfx_d + printf("udp_no_ports: %u\n", snmp->udp_no_ports); + printf("udp_in_errors: %u\n", snmp->udp_in_errors); + printf("udp_out_datagrams: %u\n", snmp->udp_out_datagrams); +- +- printf("tcp_act_open: %u\n", snmp->tcp_act_open); +- printf("tcp_passive_open: %u\n", snmp->tcp_passive_open); +- printf("tcp_attempt_fail: %u\n", snmp->tcp_attempt_fail); +- printf("tcp_estab_rst: %u\n", snmp->tcp_estab_rst); +- printf("tcp_out_seg: %u\n", snmp->tcp_out_seg); +- printf("tcp_retran_seg: %u\n", snmp->tcp_retran_seg); +- printf("tcp_in_seg: %u\n", snmp->tcp_in_seg); +- printf("tcp_in_err: %u\n", snmp->tcp_in_err); +- printf("tcp_out_rst: %u\n", snmp->tcp_out_rst); ++ ++ gazelle_print_lstack_tcp_stat(snmp); + + printf("icmp_in_msgs: %u\n", snmp->icmp_in_msgs); + printf("icmp_in_errors: %u\n", snmp->icmp_in_errors); +-- +2.27.0 + diff --git a/0062-stack-fix-coredump-caused-by-gazelleclt-in-rtc-mode.patch b/0062-stack-fix-coredump-caused-by-gazelleclt-in-rtc-mode.patch new file mode 100644 index 0000000..4f5a698 --- /dev/null +++ b/0062-stack-fix-coredump-caused-by-gazelleclt-in-rtc-mode.patch @@ -0,0 +1,124 @@ +From 94e60e452e11fcc785fe44a66358608b5e2d90a7 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Mon, 27 Nov 2023 21:41:13 +0800 +Subject: [PATCH] stack: fix coredump caused by gazelleclt in rtc mode when + stack num defined is greater than the hijacked thread num + +--- + src/lstack/core/lstack_dpdk.c | 7 +------ + src/lstack/core/lstack_protocol_stack.c | 20 ++++++++------------ + src/lstack/include/lstack_dpdk.h | 2 +- + 3 files changed, 10 insertions(+), 19 deletions(-) + +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 19a7bf4..839516e 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -205,13 +205,8 @@ static struct reg_ring_msg *create_reg_mempool(const char *name, uint16_t queue_ + return reg_buf; + } + +-int32_t pktmbuf_pool_init(struct protocol_stack *stack, uint16_t stack_num) ++int32_t pktmbuf_pool_init(struct protocol_stack *stack) + { +- if (stack_num == 0) { +- LSTACK_LOG(ERR, LSTACK, "stack_num=0.\n"); +- return -1; +- } +- + stack->rxtx_pktmbuf_pool = get_pktmbuf_mempool("rxtx_mbuf", stack->queue_id); + if (stack->rxtx_pktmbuf_pool == NULL) { + LSTACK_LOG(ERR, LSTACK, "rxtx_pktmbuf_pool is NULL\n"); +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index dfebfcc..baacaa9 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -349,7 +349,7 @@ static int32_t init_stack_value(struct protocol_stack *stack, void *arg) + return -1; + } + +- if (pktmbuf_pool_init(stack, stack_group->stack_num) != 0) { ++ if (pktmbuf_pool_init(stack) != 0) { + LSTACK_LOG(ERR, LSTACK, "pktmbuf_pool_init failed\n"); + return -1; + } +@@ -529,7 +529,7 @@ static void gazelle_listen_thread(void *arg) + int32_t stack_group_init_mempool(void) + { + struct cfg_params *global_cfg_parmas = get_global_cfg_params(); +- struct protocol_stack_group *stack_group = get_protocol_stack_group(); ++ uint32_t total_mbufs = get_global_cfg_params()->mbuf_count_per_conn * get_global_cfg_params()->tcp_conn_count; + struct rte_mempool *rxtx_mbuf = NULL; + uint32_t cpu_id = 0; + unsigned numa_id = 0; +@@ -537,10 +537,8 @@ int32_t stack_group_init_mempool(void) + + LSTACK_LOG(INFO, LSTACK, + "config::num_cpu=%d num_process=%d \n", global_cfg_parmas->num_cpu, global_cfg_parmas->num_process); +- +- uint32_t total_mbufs = get_global_cfg_params()->mbuf_count_per_conn * get_global_cfg_params()->tcp_conn_count; + +- for (int cpu_idx = 0; cpu_idx < global_cfg_parmas->num_cpu; cpu_idx++) { ++ for (int cpu_idx = 0; cpu_idx < get_global_cfg_params()->num_queue; cpu_idx++) { + cpu_id = global_cfg_parmas->cpus[cpu_idx]; + numa_id = numa_node_of_cpu(cpu_id); + +@@ -552,7 +550,7 @@ int32_t stack_group_init_mempool(void) + } + + rxtx_mbuf = create_pktmbuf_mempool( +- "rxtx_mbuf", total_mbufs / stack_group->stack_num, RXTX_CACHE_SZ, queue_id, numa_id); ++ "rxtx_mbuf", total_mbufs / get_global_cfg_params()->num_queue, RXTX_CACHE_SZ, queue_id, numa_id); + if (rxtx_mbuf == NULL) { + LSTACK_LOG(ERR, LSTACK, "cpuid=%u, numid=%d , rxtx_mbuf idx= %d create_pktmbuf_mempool fail\n", + cpu_id, numa_id, queue_id); +@@ -569,11 +567,7 @@ int32_t stack_group_init_mempool(void) + int32_t stack_group_init(void) + { + struct protocol_stack_group *stack_group = get_protocol_stack_group(); +- if (!get_global_cfg_params()->seperate_send_recv) { +- stack_group->stack_num = get_global_cfg_params()->num_cpu; +- } else { +- stack_group->stack_num = get_global_cfg_params()->num_cpu * 2; +- } ++ stack_group->stack_num = 0; + + init_list_node(&stack_group->poll_list); + pthread_spin_init(&stack_group->poll_list_lock, PTHREAD_PROCESS_PRIVATE); +@@ -627,6 +621,7 @@ int32_t stack_setup_app_thread(void) + LSTACK_LOG(INFO, LSTACK, "stack setup failed in app thread\n"); + return -1; + } ++ atomic_fetch_add(&g_stack_group.stack_num, 1); + + return 0; + } +@@ -670,10 +665,11 @@ int32_t stack_setup_thread(void) + } + + /* 2: wait stack thread and kernel_event thread init finish */ +- wait_sem_value(&g_stack_group.sem_stack_setup, g_stack_group.stack_num * 2); ++ wait_sem_value(&g_stack_group.sem_stack_setup, queue_num * 2); + if (g_stack_group.stack_setup_fail) { + return -1; + } ++ g_stack_group.stack_num = queue_num; + + return 0; + } +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index e3daefa..6554a7e 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -43,7 +43,7 @@ struct rte_ring; + struct rte_mbuf; + int32_t fill_mbuf_to_ring(struct rte_mempool *mempool, struct rte_ring *ring, uint32_t mbuf_num); + int32_t dpdk_eal_init(void); +-int32_t pktmbuf_pool_init(struct protocol_stack *stack, uint16_t stack_num); ++int32_t pktmbuf_pool_init(struct protocol_stack *stack); + struct rte_ring *create_ring(const char *name, uint32_t count, uint32_t flags, int32_t queue_id); + struct rte_mempool *create_mempool(const char *name, uint32_t count, uint32_t size, + uint32_t flags, int32_t idx); +-- +2.27.0 + diff --git a/0063-dfx-add-tcp-exception-and-kernel-event-statistics.patch b/0063-dfx-add-tcp-exception-and-kernel-event-statistics.patch new file mode 100644 index 0000000..c1a9119 --- /dev/null +++ b/0063-dfx-add-tcp-exception-and-kernel-event-statistics.patch @@ -0,0 +1,109 @@ +From 66f2015f6710d86966b8abcf028f69a3165c10aa Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Tue, 28 Nov 2023 18:43:42 +0800 +Subject: [PATCH] dfx: add tcp exception and kernel event statistics + +--- + src/common/gazelle_dfx_msg.h | 4 ++++ + src/lstack/api/lstack_epoll.c | 9 +++++++-- + src/ltran/ltran_dfx.c | 7 ++++++- + 3 files changed, 17 insertions(+), 3 deletions(-) + +diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h +index 8071108..bfc4992 100644 +--- a/src/common/gazelle_dfx_msg.h ++++ b/src/common/gazelle_dfx_msg.h +@@ -75,6 +75,7 @@ struct gazelle_wakeup_stat { + uint64_t app_write_cnt; + uint64_t app_read_cnt; + uint64_t read_null; ++ uint64_t kernel_events; + }; + + struct gazelle_stat_pkts { +@@ -120,6 +121,9 @@ struct gazelle_stat_lstack_snmp { + uint32_t tcp_fin_ack_cnt; + uint32_t tcp_delay_ack_cnt; + uint32_t tcp_refused_cnt; ++ uint32_t tcp_out_of_seq; ++ uint32_t tcp_acceptmbox_full; ++ uint32_t tcp_listen_drops; + + /* UDP */ + uint32_t udp_in_datagrams; +diff --git a/src/lstack/api/lstack_epoll.c b/src/lstack/api/lstack_epoll.c +index 2cb459e..a2d2a9b 100644 +--- a/src/lstack/api/lstack_epoll.c ++++ b/src/lstack/api/lstack_epoll.c +@@ -493,7 +493,6 @@ int32_t epoll_lwip_event_nolock(struct wakeup_poll *wakeup, struct epoll_event * + } + } + +- wakeup->stat.app_events += event_num; + return event_num; + } + +@@ -611,6 +610,7 @@ int32_t lstack_rtc_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t + + lwip_num = epoll_lwip_event_nolock(wakeup, &events[kernel_num], tmpmaxevents - kernel_num); + wakeup->stat.app_events += lwip_num; ++ wakeup->stat.kernel_events += kernel_num; + + return lwip_num + kernel_num; + } +@@ -634,7 +634,6 @@ int32_t lstack_rtw_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t + do { + __atomic_store_n(&wakeup->in_wait, true, __ATOMIC_RELEASE); + lwip_num = epoll_lwip_event(wakeup, events, maxevents); +- wakeup->stat.app_events += lwip_num; + + if (__atomic_load_n(&wakeup->have_kernel_event, __ATOMIC_ACQUIRE)) { + kernel_num = posix_api->epoll_wait_fn(epfd, &events[lwip_num], maxevents - lwip_num, 0); +@@ -661,6 +660,9 @@ int32_t lstack_rtw_epoll_wait(int32_t epfd, struct epoll_event* events, int32_t + } while (ret == 0); + + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); ++ wakeup->stat.app_events += lwip_num; ++ wakeup->stat.kernel_events += kernel_num; ++ + return lwip_num + kernel_num; + } + +@@ -870,6 +872,9 @@ int32_t lstack_poll(struct pollfd *fds, nfds_t nfds, int32_t timeout) + } while (ret == 0); + + __atomic_store_n(&wakeup->in_wait, false, __ATOMIC_RELEASE); ++ wakeup->stat.app_events += lwip_num; ++ wakeup->stat.kernel_events += kernel_num; ++ + return lwip_num + kernel_num; + } + +diff --git a/src/ltran/ltran_dfx.c b/src/ltran/ltran_dfx.c +index 98e23dc..3bd120c 100644 +--- a/src/ltran/ltran_dfx.c ++++ b/src/ltran/ltran_dfx.c +@@ -604,7 +604,9 @@ static void show_lstack_stats(struct gazelle_stack_dfx_data *lstack_stat) + printf("write_lwip: %-17"PRIu64" ", lstack_stat->data.pkts.stack_stat.write_lwip_cnt); + printf("app_write_rpc: %-14"PRIu64" \n", lstack_stat->data.pkts.wakeup_stat.app_write_rpc); + printf("recv_list: %-18"PRIu64" ", lstack_stat->data.pkts.recv_list_cnt); +- printf("conn_num: %-19hu \n", lstack_stat->data.pkts.conn_num); ++ printf("conn_num: %-19hu ", lstack_stat->data.pkts.conn_num); ++ ++ printf("kernel_events: %-14"PRIu64"\n", lstack_stat->data.pkts.wakeup_stat.kernel_events); + printf("wakeup_events: %-14"PRIu64" ", lstack_stat->data.pkts.stack_stat.wakeup_events); + printf("app_events: %-17"PRIu64" ", lstack_stat->data.pkts.wakeup_stat.app_events); + printf("read_null: %-18"PRIu64" \n", lstack_stat->data.pkts.wakeup_stat.read_null); +@@ -839,6 +841,9 @@ static void gazelle_print_lstack_tcp_stat(const struct gazelle_stat_lstack_snmp + printf("tcp_fin_ack_cnt: %u\n", snmp->tcp_fin_ack_cnt); + printf("tcp_delay_ack_cnt: %u\n", snmp->tcp_delay_ack_cnt); + printf("tcp_refused_cnt: %u\n", snmp->tcp_refused_cnt); ++ printf("tcp_out_of_seq: %u\n", snmp->tcp_out_of_seq); ++ printf("tcp_acceptmbox_full: %u\n", snmp->tcp_acceptmbox_full); ++ printf("tcp_listen_drops: %u\n", snmp->tcp_listen_drops); + } + + static void gazelle_print_lstack_stat_snmp_core(const struct gazelle_stack_dfx_data *stat, +-- +2.27.0 + diff --git a/0064-add-vlan_id-in-netif.patch b/0064-add-vlan_id-in-netif.patch new file mode 100644 index 0000000..c35d11e --- /dev/null +++ b/0064-add-vlan_id-in-netif.patch @@ -0,0 +1,88 @@ +From fcdf8a09859cc0ba148a5c0a410997931fb4fa20 Mon Sep 17 00:00:00 2001 +From: zhengjiebing +Date: Wed, 22 Nov 2023 16:08:22 +0800 +Subject: [PATCH] add vlan_id in netif + +--- + src/lstack/core/lstack_cfg.c | 4 ++-- + src/lstack/core/lstack_lwip.c | 3 --- + src/lstack/include/lstack_cfg.h | 2 +- + src/lstack/netif/lstack_ethdev.c | 5 +++++ + src/lstack/netif/lstack_vdev.c | 2 +- + 5 files changed, 9 insertions(+), 7 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index d1cbd1d..6324c97 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -1261,9 +1261,9 @@ static int32_t parse_stack_thread_mode(void) + static int32_t parse_nic_vlan_mode(void) + { + int32_t ret; +- PARSE_ARG(g_config_params.nic.vlan_mode, "nic_vlan_mode", 0, 0, 4094, ret); ++ PARSE_ARG(g_config_params.nic.vlan_mode, "nic_vlan_mode", -1, -1, 4094, ret); + if (ret != 0) { +- LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid vlan mode value %d ret=%d. only support 0~4094\n", \ ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid vlan mode value %d ret=%d. only support -1~4094\n", \ + g_config_params.nic.vlan_mode, ret); + } + return ret; +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index c8b4e8f..af9bf73 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -196,9 +196,6 @@ void do_lwip_init_sock(int32_t fd) + (void)replenish_send_idlembuf(stack, sock); + + sock->stack = stack; +- if (get_global_cfg_params()->nic.vlan_mode > 0 && get_global_cfg_params()->nic.vlan_mode < 4095) { +- sock->conn->pcb.udp->netif_hints.tci = get_global_cfg_params()->nic.vlan_mode; +- } + + init_list_node_null(&sock->recv_list); + init_list_node_null(&sock->event_list); +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index e33f4fe..a6bdfd5 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -63,7 +63,7 @@ struct secondary_attach_arg { + struct cfg_nic_params { + uint32_t rxqueue_size; + uint32_t txqueue_size; +- uint16_t vlan_mode; ++ int32_t vlan_mode; + }; + + struct cfg_params { +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 29bef21..cce2fcf 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -967,6 +967,11 @@ int32_t ethdev_init(struct protocol_stack *stack) + netif_ip6_addr_set(&stack->netif, 0, &cfg->host_addr6); + netif_ip6_addr_set_state(&stack->netif, 0, IP6_ADDR_VALID); + } ++ ++ /* 0-4094: The vlaue range for VLAN IDs is 0 to 4094. */ ++ if (get_global_cfg_params()->nic.vlan_mode >= 0 && get_global_cfg_params()->nic.vlan_mode <= 4094) { ++ netif_set_vlan_tci(&stack->netif, (u16_t)get_global_cfg_params()->nic.vlan_mode); ++ } + + netif_set_link_up(&stack->netif); + +diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c +index d57ce59..18322a6 100644 +--- a/src/lstack/netif/lstack_vdev.c ++++ b/src/lstack/netif/lstack_vdev.c +@@ -84,7 +84,7 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt + } + + /* skip gro when tcp/ip cksum offloads disable */ +- if (get_protocol_stack_group()->rx_offload == 0 || get_global_cfg_params()->nic.vlan_mode > 0) { ++ if (get_protocol_stack_group()->rx_offload == 0 || get_global_cfg_params()->nic.vlan_mode >= 0) { + return pkt_num; + } + +-- +2.27.0 + diff --git a/0065-support-vlan-offload.patch b/0065-support-vlan-offload.patch new file mode 100644 index 0000000..2d5beb1 --- /dev/null +++ b/0065-support-vlan-offload.patch @@ -0,0 +1,89 @@ +From a449111fed8c0c4cd7b8021ff20b3ea12f334479 Mon Sep 17 00:00:00 2001 +From: zhengjiebing +Date: Tue, 28 Nov 2023 14:14:15 +0800 +Subject: [PATCH] support vlan offload + +--- + src/common/dpdk_common.c | 12 ++++++++++++ + src/lstack/netif/lstack_ethdev.c | 13 +++++++------ + src/lstack/netif/lstack_vdev.c | 3 ++- + 3 files changed, 21 insertions(+), 7 deletions(-) + +diff --git a/src/common/dpdk_common.c b/src/common/dpdk_common.c +index 52a163f..50f0bf0 100644 +--- a/src/common/dpdk_common.c ++++ b/src/common/dpdk_common.c +@@ -104,6 +104,12 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev + COMMON_INFO("DEV_RX_OFFLOAD_UDP_CKSUM\n"); + } + ++ // rx vlan ++ if (rx_ol_capa & DEV_RX_OFFLOAD_VLAN_STRIP) { ++ rx_ol |= DEV_RX_OFFLOAD_VLAN_STRIP; ++ COMMON_INFO("DEV_RX_OFFLOAD_VLAN_STRIP\n"); ++ } ++ + // tx ip + if (tx_ol_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) { + tx_ol |= DEV_TX_OFFLOAD_IPV4_CKSUM; +@@ -128,6 +134,12 @@ void eth_params_checksum(struct rte_eth_conf *conf, struct rte_eth_dev_info *dev + COMMON_INFO("DEV_TX_OFFLOAD_TCP_TSO\n"); + } + ++ // tx vlan ++ if (tx_ol_capa & DEV_TX_OFFLOAD_VLAN_INSERT) { ++ tx_ol |= DEV_TX_OFFLOAD_VLAN_INSERT; ++ COMMON_INFO("DEV_TX_OFFLOAD_VLAN_INSERT\n"); ++ } ++ + if (!(rx_ol & DEV_RX_OFFLOAD_UDP_CKSUM) || + !(rx_ol & DEV_RX_OFFLOAD_TCP_CKSUM) || + !(rx_ol & DEV_RX_OFFLOAD_IPV4_CKSUM)) { +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index cce2fcf..31856f2 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -815,12 +815,12 @@ int32_t gazelle_eth_dev_poll(struct protocol_stack *stack, uint8_t use_ltran_fla + /* copy arp into other stack */ + if (!use_ltran_flag) { + struct rte_ether_hdr *ethh = rte_pktmbuf_mtod(stack->pkts[i], struct rte_ether_hdr *); +- u16_t type; +- type = ethh->ether_type; +- if (type == PP_HTONS(ETHTYPE_VLAN)) { +- struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr *)(((char *)ethh) + SIZEOF_ETH_HDR); +- type = vlan->tpid; +- } ++ u16_t type; ++ type = ethh->ether_type; ++ if (type == PP_HTONS(ETHTYPE_VLAN)) { ++ struct eth_vlan_hdr *vlan = (struct eth_vlan_hdr *)(((char *)ethh) + SIZEOF_ETH_HDR); ++ type = vlan->tpid; ++ } + if (unlikely(RTE_BE16(RTE_ETHER_TYPE_ARP) == type)) { + stack_broadcast_arp(stack->pkts[i], stack); + /* copy arp into other process */ +@@ -860,6 +860,7 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf) + mbuf->data_len = pbuf->len; + mbuf->pkt_len = pbuf->tot_len; + mbuf->ol_flags = pbuf->ol_flags; ++ mbuf->vlan_tci = pbuf->vlan_tci; + mbuf->next = NULL; + buf_addr = rte_pktmbuf_mtod(mbuf, void *); + +diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c +index 18322a6..e1438da 100644 +--- a/src/lstack/netif/lstack_vdev.c ++++ b/src/lstack/netif/lstack_vdev.c +@@ -84,7 +84,8 @@ static uint32_t vdev_rx_poll(struct protocol_stack *stack, struct rte_mbuf **pkt + } + + /* skip gro when tcp/ip cksum offloads disable */ +- if (get_protocol_stack_group()->rx_offload == 0 || get_global_cfg_params()->nic.vlan_mode >= 0) { ++ if (get_protocol_stack_group()->rx_offload == 0 || (get_global_cfg_params()->nic.vlan_mode >= 0 ++ && !(get_protocol_stack_group()->rx_offload & DEV_RX_OFFLOAD_VLAN_STRIP))) { + return pkt_num; + } + +-- +2.27.0 + diff --git a/gazelle.spec b/gazelle.spec index a42651a..1f9fd74 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 16 +Release: 17 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -54,20 +54,31 @@ Patch9035: 0035-cfg-nic-queue-size-only-support-power-of-2.patch Patch9036: 0036-stack-fix-possible-coredump-when-arp-packet-broadcas.patch Patch9037: 0037-Fix-coredump-issue-and-skip-rte_pdump_init-for-secon.patch Patch9038: 0038-solve-problem-that-rte_pktmbuf_poll_creat-in-same-nu.patch -Patch9039: 0039-build-add-mlx5-pmd-dependency.patch Patch9040: 0040-when-timeout-occurs-process-exits.patch Patch9041: 0041-wrap-support-select.patch Patch9042: 0042-add-vlan-support.patch Patch9043: 0043-slave-mac-addr.patch Patch9044: 0044-PRE_LOG-modify-prelog-info-transfer-to-terminal-at-t.patch Patch9045: 0045-ethdev-mbuf-data-start-pointer-pbuf-payload.patch -Patch9046: 0046-build-fix-ltran-build-error.patch Patch9047: 0047-cfg-fix-lstack-mempool-lookup-failed-in-ltran-mode.patch Patch9048: 0048-add-tx-package-timeout.patch Patch9049: 0049-modif-mem.patch Patch9050: 0050-enable-ipv6.patch Patch9051: 0051-wrap-dont-hijack-select-temporarily.patch Patch9052: 0052-ipv6.patch +Patch9053: 0053-add-gazelle-log.patch +Patch9054: 0054-PRE_LOG-modify-log-info-while-there-are-repeated-ite.patch +Patch9055: 0055-add-gazelle-log.patch +Patch9056: 0056-wrap-fix-connect-wrong-port-after-addr-bind-two-port.patch +Patch9057: 0057-cfg-rm-ipv6_enable.patch +Patch9058: 0058-ltran-support-vlan.patch +Patch9059: 0059-update-src-ltran-ltran_param.c.patch +Patch9060: 0060-dfx-support-bond-get-dpdk-xstats.patch +Patch9061: 0061-add-tcp-faste-timer-cnt.patch +Patch9062: 0062-stack-fix-coredump-caused-by-gazelleclt-in-rtc-mode.patch +Patch9063: 0063-dfx-add-tcp-exception-and-kernel-event-statistics.patch +Patch9064: 0064-add-vlan_id-in-netif.patch +Patch9065: 0065-support-vlan-offload.patch %description %{name} is a high performance user-mode stack. @@ -109,6 +120,21 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Wed Nov 29 2023 yinbin6 - 1.0.2-17 +- support vlan offload +- add vlan_id in netif +- dfx: add tcp exception and kernel event statistics +- stack: fix coredump caused by gazelleclt in rtc mode when stack num defined is greater than the hijacked thread num +- add tcp faste timer cnt +- dfx: support bond get dpdk xstats +- update src/ltran/ltran_param.c. 规范679行的报错日志信息,将“,”之后的“Please”修正为“please” +- ltran support vlan +- cfg: rm ipv6_enable +- wrap: fix connect wrong port after addr bind two ports +- add gazelle log +- PRE_LOG: modify log info while there are repeated items in conf file +- add gazelle log + * Wed Nov 22 2023 yinbin6 - 1.0.2-16 - ipv6