From e7003279e8fd896ab7129f60548a00eb14837f4a Mon Sep 17 00:00:00 2001 From: yinbin6 Date: Sun, 4 Feb 2024 15:21:37 +0800 Subject: [PATCH] sync patches from upstream (cherry picked from commit b99f8a8adc9894b3b4bdb559dad9e0397b5fa7b3) --- 0120-modify-conf-vlan-default-vlaue.patch | 24 ++ ...riables-in-pbuf-and-reduce-mbuf-size.patch | 123 ++++++ ...it-process-for-FIN-and-unsupport-SO_.patch | 38 ++ 0123-remove-expand_send_ring.patch | 371 ++++++++++++++++++ 0124-set-ltran.patch | 25 ++ 0125-add-bond-doc.patch | 25 ++ 0126-cfg-host_addr-is-not-mandatory.patch | 61 +++ 0127-add-bond1-support.patch | 139 +++++++ 0128-fix-t_params-double-free.patch | 77 ++++ ...fix-receive-fin-packet-process-error.patch | 155 ++++++++ ...upport-netperf-UDP_STREAM-and-UDP_RR.patch | 129 ++++++ gazelle.spec | 26 +- 12 files changed, 1192 insertions(+), 1 deletion(-) create mode 100644 0120-modify-conf-vlan-default-vlaue.patch create mode 100644 0121-remove-unused-variables-in-pbuf-and-reduce-mbuf-size.patch create mode 100644 0122-optimize-recv-exit-process-for-FIN-and-unsupport-SO_.patch create mode 100644 0123-remove-expand_send_ring.patch create mode 100644 0124-set-ltran.patch create mode 100644 0125-add-bond-doc.patch create mode 100644 0126-cfg-host_addr-is-not-mandatory.patch create mode 100644 0127-add-bond1-support.patch create mode 100644 0128-fix-t_params-double-free.patch create mode 100644 0129-fix-receive-fin-packet-process-error.patch create mode 100644 0130-support-netperf-UDP_STREAM-and-UDP_RR.patch diff --git a/0120-modify-conf-vlan-default-vlaue.patch b/0120-modify-conf-vlan-default-vlaue.patch new file mode 100644 index 0000000..a679ded --- /dev/null +++ b/0120-modify-conf-vlan-default-vlaue.patch @@ -0,0 +1,24 @@ +From 560eb7939415f3cd8b10bbc829fd57141b757727 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Fri, 19 Jan 2024 01:47:26 +0000 +Subject: [PATCH] modify conf vlan default vlaue + +--- + src/lstack/lstack.conf | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index 3eb4685..ce86ec4 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -64,5 +64,5 @@ process_idx=0 + #tuple_filer=0, below cfg valid + listen_shadow=0 + +-#vlan mode; only support 0~4094, 0 is disabled +-nic_vlan_mode=0 ++#vlan mode; only support -1~4094, -1 is disabled ++nic_vlan_mode=-1 +-- +2.33.0 + diff --git a/0121-remove-unused-variables-in-pbuf-and-reduce-mbuf-size.patch b/0121-remove-unused-variables-in-pbuf-and-reduce-mbuf-size.patch new file mode 100644 index 0000000..911f70c --- /dev/null +++ b/0121-remove-unused-variables-in-pbuf-and-reduce-mbuf-size.patch @@ -0,0 +1,123 @@ +From 2bfb7f1dcaab4436db7345d6f9fcb6f4a1d27681 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Sun, 21 Jan 2024 16:42:46 +0800 +Subject: [PATCH] remove unused variables in pbuf and reduce mbuf size + +--- + src/lstack/core/lstack_lwip.c | 10 ---------- + src/lstack/include/lstack_dpdk.h | 2 +- + src/lstack/netif/lstack_ethdev.c | 11 ----------- + 3 files changed, 1 insertion(+), 22 deletions(-) + +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index 6ebe589..63044c2 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -114,14 +114,7 @@ static struct pbuf *init_mbuf_to_pbuf(struct rte_mbuf *mbuf, pbuf_layer layer, u + void *data = rte_pktmbuf_mtod(mbuf, void *); + struct pbuf *pbuf = pbuf_alloced_custom(layer, length, type, pbuf_custom, data, MAX_PACKET_SZ); + if (pbuf) { +- pbuf->ol_flags = 0; +- pbuf->l2_len = 0; +- pbuf->l3_len = 0; +- pbuf->l4_len = 0; +- pbuf->header_off = 0; +- pbuf->rexmit = 0; + pbuf->allow_in = 1; +- pbuf->head = 0; + pbuf->last = pbuf; + pbuf->addr = *IP_ANY_TYPE; + pbuf->port = 0; +@@ -290,7 +283,6 @@ struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_s + if (pbuf->tot_len > remain_size) { + pthread_spin_unlock(&pbuf->pbuf_lock); + *apiflags &= ~TCP_WRITE_FLAG_MORE; +- pbuf->head = 1; + return NULL; + } + if (pbuf->allow_in == 1) { +@@ -300,7 +292,6 @@ struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_s + } else { + if (pbuf->tot_len > remain_size) { + *apiflags &= ~TCP_WRITE_FLAG_MORE; +- pbuf->head = 1; + return NULL; + } + } +@@ -1354,7 +1345,6 @@ err_t netif_loop_output(struct netif *netif, struct pbuf *p) + LSTACK_LOG(ERR, LSTACK, "netif_loop_output: pbuf_alloc failed\n"); + return ERR_MEM; + } +- head->ol_flags = p->ol_flags; + memcpy_s(head->payload, head->len, p->payload, p->len); + + if ((flags & TCP_SYN) && !(flags & TCP_ACK)) { +diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h +index 2a44c6e..b39d199 100644 +--- a/src/lstack/include/lstack_dpdk.h ++++ b/src/lstack/include/lstack_dpdk.h +@@ -21,7 +21,7 @@ + + #define KNI_NB_MBUF (DEFAULT_RING_SIZE << 4) + +-#define MAX_PACKET_SZ 2048 ++#define MAX_PACKET_SZ 1530 + + #define RING_SIZE(x) ((x) - 1) + +diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c +index 5b0f83e..4d6f620 100644 +--- a/src/lstack/netif/lstack_ethdev.c ++++ b/src/lstack/netif/lstack_ethdev.c +@@ -103,9 +103,6 @@ void eth_dev_recv(struct rte_mbuf *mbuf, struct protocol_stack *stack) + } + next->tot_len = pkt_len; + pkt_len -= len; +-#if CHECKSUM_CHECK_IP_HW || CHECKSUM_CHECK_TCP_HW +- next->ol_flags = m->ol_flags; +-#endif + + if (head == NULL) { + head = next; +@@ -859,7 +856,6 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf) + struct protocol_stack *stack = get_protocol_stack(); + struct rte_mbuf *pre_mbuf = NULL; + struct rte_mbuf *first_mbuf = NULL; +- struct pbuf *first_pbuf = pbuf; + void *buf_addr; + + while (likely(pbuf != NULL)) { +@@ -867,8 +863,6 @@ 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 *); + +@@ -882,7 +876,6 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf) + + if (first_mbuf == NULL) { + first_mbuf = mbuf; +- first_pbuf = pbuf; + first_mbuf->nb_segs = 1; + } else { + first_mbuf->nb_segs++; +@@ -893,13 +886,9 @@ static err_t eth_dev_output(struct netif *netif, struct pbuf *pbuf) + mbuf->ol_flags |= RTE_MBUF_F_TX_TCP_SEG; + mbuf->tso_segsz = MBUF_MAX_DATA_LEN; + } +- mbuf->l2_len = first_pbuf->l2_len; +- mbuf->l3_len = first_pbuf->l3_len; +- mbuf->l4_len = first_pbuf->l4_len; + + pre_mbuf = mbuf; + rte_mbuf_refcnt_update(mbuf, 1); +- pbuf->rexmit = 1; + pbuf = pbuf->next; + } + +-- +2.33.0 + diff --git a/0122-optimize-recv-exit-process-for-FIN-and-unsupport-SO_.patch b/0122-optimize-recv-exit-process-for-FIN-and-unsupport-SO_.patch new file mode 100644 index 0000000..03af162 --- /dev/null +++ b/0122-optimize-recv-exit-process-for-FIN-and-unsupport-SO_.patch @@ -0,0 +1,38 @@ +From 7499d04834da6c3774923972d927229b10189e62 Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Mon, 22 Jan 2024 12:52:09 +0800 +Subject: [PATCH] optimize recv exit process for FIN and unsupport SO_RCVBUF + +--- + src/lstack/api/lstack_wrap.c | 1 + + src/lstack/core/lstack_lwip.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 3db62c7..372e102 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -372,6 +372,7 @@ static bool unsupport_optname(int32_t optname) + optname == SO_SNDTIMEO || + optname == SO_RCVTIMEO || + optname == SO_SNDBUF || ++ optname == SO_RCVBUF || + optname == TCP_INFO || + optname == TCP_MAXSEG || + optname == TCP_CONGESTION) { +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index 6ebe589..ce218f5 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -1016,7 +1016,7 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags + } else { + while (gazelle_ring_read(sock->recv_ring, (void **)&pbuf, 1) != 1 && recvd == 0) { + /* if the connection is disconnected, recv return 0 */ +- if ((sock->errevent > 0 || (sock->conn->pcb.tcp->flags & TF_FIN)) && !NETCONN_IS_DATAIN(sock)) { ++ if (sock->errevent > 0 && !NETCONN_IS_DATAIN(sock)) { + return 0; + } + +-- +2.33.0 + diff --git a/0123-remove-expand_send_ring.patch b/0123-remove-expand_send_ring.patch new file mode 100644 index 0000000..260061f --- /dev/null +++ b/0123-remove-expand_send_ring.patch @@ -0,0 +1,371 @@ +From 744be87c712b7166eb921b2e7d537bea71005966 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Mon, 22 Jan 2024 17:08:42 +0800 +Subject: [PATCH] remove expand_send_ring + +--- + src/lstack/core/lstack_cfg.c | 9 -- + src/lstack/core/lstack_lwip.c | 191 ++----------------------------- + src/lstack/include/lstack_cfg.h | 1 - + src/lstack/include/lstack_lwip.h | 2 +- + src/lstack/lstack.conf | 4 - + 5 files changed, 12 insertions(+), 195 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 5e30e89..028ea26 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -66,7 +66,6 @@ static int32_t parse_nic_read_number(void); + static int32_t parse_tcp_conn_count(void); + static int32_t parse_mbuf_count_per_conn(void); + static int32_t parse_send_ring_size(void); +-static int32_t parse_expand_send_ring(void); + static int32_t parse_num_process(void); + static int32_t parse_process_numa(void); + static int32_t parse_process_index(void); +@@ -130,7 +129,6 @@ static struct config_vector_t g_config_tbl[] = { + { "rpc_number", parse_rpc_number }, + { "nic_read_number", parse_nic_read_number }, + { "send_ring_size", parse_send_ring_size }, +- { "expand_send_ring", parse_expand_send_ring }, + { "num_process", parse_num_process }, + { "process_numa", parse_process_numa }, + { "process_idx", parse_process_index }, +@@ -888,13 +886,6 @@ static int32_t parse_send_ring_size(void) + return ret; + } + +-static int32_t parse_expand_send_ring(void) +-{ +- int32_t ret; +- PARSE_ARG(g_config_params.expand_send_ring, "expand_send_ring", 0, 0, 1, ret); +- return ret; +-} +- + static int32_t parse_mbuf_count_per_conn(void) + { + int32_t ret; +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index 6ebe589..33b6abd 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -56,17 +56,6 @@ static void free_ring_pbuf(struct rte_ring *ring) + } while (gazelle_ring_readover_count(ring)); + } + +-static void free_list_pbuf(struct pbuf *pbuf) +-{ +- while (pbuf) { +- struct pbuf *del_pbuf = pbuf; +- pbuf = pbuf->next; +- +- del_pbuf->next = NULL; +- pbuf_free(del_pbuf); +- } +-} +- + static void reset_sock_data(struct lwip_sock *sock) + { + /* check null pointer in ring_free func */ +@@ -82,11 +71,6 @@ static void reset_sock_data(struct lwip_sock *sock) + sock->send_ring = NULL; + } + +- if (sock->send_lastdata) { +- free_list_pbuf(sock->send_lastdata); +- sock->send_lastdata = NULL; +- } +- + if (sock->send_pre_del) { + pbuf_free(sock->send_pre_del); + sock->send_pre_del = NULL; +@@ -160,9 +144,7 @@ static bool replenish_send_idlembuf(struct protocol_stack *stack, struct lwip_so + pbuf_free(pbuf[i]); + } + +- if (!get_global_cfg_params()->expand_send_ring) { +- sem_post(&sock->snd_ring_sem); +- } ++ sem_post(&sock->snd_ring_sem); + + return false; + } +@@ -260,22 +242,6 @@ struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_s + } + pthread_spin_unlock(&pbuf->pbuf_lock); + +- if (pbuf->next) { +- sock->send_lastdata = pbuf->next; +- pbuf->next = NULL; +- } +- return pbuf; +- } +- +- if (sock->send_lastdata) { +- pbuf = sock->send_lastdata; +- if (pbuf->tot_len > remain_size) { +- *apiflags &= ~TCP_WRITE_FLAG_MORE; +- return NULL; +- } +- sock->send_pre_del = pbuf; +- sock->send_lastdata = pbuf->next; +- pbuf->next = NULL; + return pbuf; + } + +@@ -305,8 +271,6 @@ struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_s + } + } + +- sock->send_lastdata = pbuf->next; +- pbuf->next = NULL; + return pbuf; + } + +@@ -320,112 +284,25 @@ static ssize_t do_app_write(struct pbuf *pbufs[], void *buf, size_t len, uint32_ + { + ssize_t send_len = 0; + uint32_t i = 0; +- uint32_t expand_send_ring = get_global_cfg_params()->expand_send_ring; + + for (i = 0; i < write_num - 1; i++) { + rte_prefetch0(pbufs[i + 1]); + rte_prefetch0(pbufs[i + 1]->payload); + rte_prefetch0((char *)buf + send_len + MBUF_MAX_DATA_LEN); +- if (expand_send_ring) { +- pbuf_take(pbufs[i], (char *)buf + send_len, MBUF_MAX_DATA_LEN); +- } else { +- rte_memcpy((char *)pbufs[i]->payload, (char *)buf + send_len, MBUF_MAX_DATA_LEN); +- } ++ rte_memcpy((char *)pbufs[i]->payload, (char *)buf + send_len, MBUF_MAX_DATA_LEN); + pbufs[i]->tot_len = pbufs[i]->len = MBUF_MAX_DATA_LEN; + send_len += MBUF_MAX_DATA_LEN; + } + + /* reduce the branch in loop */ + uint16_t copy_len = len - send_len; +- if (expand_send_ring) { +- pbuf_take(pbufs[i], (char *)buf + send_len, copy_len); +- } else { +- rte_memcpy((char *)pbufs[i]->payload, (char *)buf + send_len, copy_len); +- } ++ rte_memcpy((char *)pbufs[i]->payload, (char *)buf + send_len, copy_len); + pbufs[i]->tot_len = pbufs[i]->len = copy_len; + send_len += copy_len; + + return send_len; + } + +-static inline ssize_t app_direct_write(struct protocol_stack *stack, struct lwip_sock *sock, void *buf, +- size_t len, uint32_t write_num) +-{ +- if (write_num == 0) { +- return 0; +- } +- struct pbuf **pbufs = (struct pbuf **)malloc(write_num * sizeof(struct pbuf *)); +- if (pbufs == NULL) { +- return 0; +- } +- +- /* first pbuf get from send_ring. and malloc pbufs attach to first pbuf */ +- if (dpdk_alloc_pktmbuf(stack->rxtx_mbuf_pool, (struct rte_mbuf **)&pbufs[1], write_num - 1) != 0) { +- stack->stats.tx_allocmbuf_fail++; +- free(pbufs); +- return 0; +- } +- +- (void)gazelle_ring_read(sock->send_ring, (void **)&pbufs[0], 1); +- +- uint32_t i = 1; +- for (; i < write_num - 1; i++) { +- rte_prefetch0(mbuf_to_pbuf((void *)pbufs[i + 1])); +- pbufs[i] = init_mbuf_to_pbuf((struct rte_mbuf *)pbufs[i], PBUF_TRANSPORT, MBUF_MAX_DATA_LEN, PBUF_RAM); +- pbufs[i - 1]->next = pbufs[i]; +- } +- pbufs[i] = init_mbuf_to_pbuf((struct rte_mbuf *)pbufs[i], PBUF_TRANSPORT, MBUF_MAX_DATA_LEN, PBUF_RAM); +- pbufs[i - 1]->next = pbufs[i]; +- +- ssize_t send_len = do_app_write(pbufs, buf, len, write_num); +- +- gazelle_ring_read_over(sock->send_ring); +- +- pbufs[0]->last = pbufs[write_num - 1]; +- sock->remain_len = 0; +- free(pbufs); +- return send_len; +-} +- +-static inline ssize_t app_direct_attach(struct protocol_stack *stack, struct pbuf *attach_pbuf, void *buf, +- size_t len, uint32_t write_num) +-{ +- if (write_num == 0) { +- return 0; +- } +- struct pbuf **pbufs = (struct pbuf **)malloc(write_num * sizeof(struct pbuf *)); +- if (pbufs == NULL) { +- return 0; +- } +- +- /* first pbuf get from send_ring. and malloc pbufs attach to first pbuf */ +- if (dpdk_alloc_pktmbuf(stack->rxtx_mbuf_pool, (struct rte_mbuf **)pbufs, write_num) != 0) { +- stack->stats.tx_allocmbuf_fail++; +- free(pbufs); +- return 0; +- } +- +- pbufs[0] = init_mbuf_to_pbuf((struct rte_mbuf *)pbufs[0], PBUF_TRANSPORT, MBUF_MAX_DATA_LEN, PBUF_RAM); +- uint32_t i = 1; +- for (; i < write_num - 1; i++) { +- rte_prefetch0(mbuf_to_pbuf((void *)pbufs[i + 1])); +- pbufs[i] = init_mbuf_to_pbuf((struct rte_mbuf *)pbufs[i], PBUF_TRANSPORT, MBUF_MAX_DATA_LEN, PBUF_RAM); +- pbufs[i - 1]->next = pbufs[i]; +- } +- if (write_num > 1) { +- pbufs[i] = init_mbuf_to_pbuf((struct rte_mbuf *)pbufs[i], PBUF_TRANSPORT, MBUF_MAX_DATA_LEN, PBUF_RAM); +- pbufs[i - 1]->next = pbufs[i]; +- } +- +- ssize_t send_len = do_app_write(pbufs, buf, len, write_num); +- +- attach_pbuf->last->next = pbufs[0]; +- attach_pbuf->last = pbufs[write_num - 1]; +- +- free(pbufs); +- return send_len; +-} +- + static inline ssize_t app_buff_write(struct lwip_sock *sock, void *buf, size_t len, uint32_t write_num, + const struct sockaddr *addr, socklen_t addrlen) + { +@@ -496,12 +373,6 @@ static inline size_t merge_data_lastpbuf(struct lwip_sock *sock, void *buf, size + return 0; + } + +- if (last_pbuf->next || last_pbuf->len >= MBUF_MAX_DATA_LEN) { +- sock->remain_len = 0; +- gazelle_ring_lastover(last_pbuf); +- return 0; +- } +- + size_t send_len = MBUF_MAX_DATA_LEN - last_pbuf->len; + if (send_len >= len) { + sock->remain_len = send_len - len; +@@ -512,11 +383,7 @@ static inline size_t merge_data_lastpbuf(struct lwip_sock *sock, void *buf, size + + uint16_t offset = last_pbuf->len; + last_pbuf->tot_len = last_pbuf->len = offset + send_len; +- if (get_global_cfg_params()->expand_send_ring) { +- pbuf_take_at(last_pbuf, buf, send_len, offset); +- } else { +- rte_memcpy((char *)last_pbuf->payload + offset, buf, send_len); +- } ++ rte_memcpy((char *)last_pbuf->payload + offset, buf, send_len); + + gazelle_ring_lastover(last_pbuf); + +@@ -570,55 +437,19 @@ static ssize_t do_lwip_fill_sendring(struct lwip_sock *sock, const void *buf, si + + /* send_ring is full, data attach last pbuf */ + if (write_avail == 0) { +- if (!get_global_cfg_params()->expand_send_ring) { +- sem_timedwait_nsecs(&sock->snd_ring_sem); +- if (likely(sock->send_ring != NULL)) { +- write_avail = gazelle_ring_readable_count(sock->send_ring); +- } +- goto END; ++ sem_timedwait_nsecs(&sock->snd_ring_sem); ++ if (likely(sock->send_ring != NULL)) { ++ write_avail = gazelle_ring_readable_count(sock->send_ring); + } +- if (unlikely(sock->send_ring == NULL)) { +- goto END; +- } +- struct pbuf *last_pbuf = gazelle_ring_readlast(sock->send_ring); +- if (last_pbuf) { +- send_len += app_direct_attach(stack, last_pbuf, (char *)buf + send_len, len - send_len, write_num); +- gazelle_ring_lastover(last_pbuf); +- if (wakeup) { +- wakeup->stat.app_write_cnt += write_num; +- } +- if (addr->sa_family == AF_INET) { +- struct sockaddr_in *saddr = (struct sockaddr_in *)addr; +- last_pbuf->addr.u_addr.ip4.addr = saddr->sin_addr.s_addr; +- last_pbuf->port = lwip_ntohs((saddr)->sin_port); +- } else if (addr->sa_family == AF_INET6) { +- struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)addr; +- memcpy_s(last_pbuf->addr.u_addr.ip6.addr, sizeof(last_pbuf->addr.u_addr.ip6.addr), +- saddr->sin6_addr.s6_addr, sizeof(saddr->sin6_addr.s6_addr)); +- last_pbuf->port = lwip_ntohs((saddr)->sin6_port); +- } +- } else { +- (void)rpc_call_replenish(stack, sock); +- if (wakeup) { +- wakeup->stat.app_write_rpc++; +- } +- } +- sock->remain_len = 0; + goto END; + } + + /* send_ring have idle */ +- if (get_global_cfg_params()->expand_send_ring) { +- send_len += (write_num <= write_avail) ? +- app_buff_write(sock, (char *)buf + send_len, len - send_len, write_num, addr, addrlen) : +- app_direct_write(stack, sock, (char *)buf + send_len, len - send_len, write_num); +- } else { +- if (write_num > write_avail) { +- write_num = write_avail; +- len = write_num * MBUF_MAX_DATA_LEN; +- } +- send_len += app_buff_write(sock, (char *)buf + send_len, len - send_len, write_num, addr, addrlen); ++ if (write_num > write_avail) { ++ write_num = write_avail; ++ len = write_num * MBUF_MAX_DATA_LEN; + } ++ send_len += app_buff_write(sock, (char *)buf + send_len, len - send_len, write_num, addr, addrlen); + + if (wakeup) { + wakeup->stat.app_write_cnt += write_num; +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index c1074f8..01d70fb 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -110,7 +110,6 @@ struct cfg_params { + struct secondary_attach_arg sec_attach_arg; + char unix_socket_filename[NAME_MAX]; + uint16_t send_ring_size; +- bool expand_send_ring; + bool tuple_filter; + int8_t bond_mode; + struct rte_ether_addr bond_slave_mac_addr[GAZELLE_MAX_BOND_NUM]; +diff --git a/src/lstack/include/lstack_lwip.h b/src/lstack/include/lstack_lwip.h +index 0a82781..fa10e3f 100644 +--- a/src/lstack/include/lstack_lwip.h ++++ b/src/lstack/include/lstack_lwip.h +@@ -18,7 +18,7 @@ + + #define NETCONN_IS_ACCEPTIN(sock) (((sock)->conn->acceptmbox != NULL) && !sys_mbox_empty((sock)->conn->acceptmbox)) + #define NETCONN_IS_DATAIN(sock) ((gazelle_ring_readable_count((sock)->recv_ring) || (sock)->recv_lastdata) || (sock->same_node_rx_ring != NULL && same_node_ring_count(sock))) +-#define NETCONN_IS_DATAOUT(sock) (gazelle_ring_readover_count((sock)->send_ring) || (sock)->send_lastdata || (sock)->send_pre_del) ++#define NETCONN_IS_DATAOUT(sock) (gazelle_ring_readover_count((sock)->send_ring) || (sock)->send_pre_del) + #define NETCONN_IS_OUTIDLE(sock) gazelle_ring_readable_count((sock)->send_ring) + #define NETCONN_IS_UDP(sock) (NETCONNTYPE_GROUP(netconn_type((sock)->conn)) == NETCONN_UDP) + +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index 3eb4685..7baa38d 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -24,10 +24,6 @@ mbuf_count_per_conn = 170 + # send ring size, default is 32, max is 2048 + send_ring_size = 32 + +-# 0: when send ring full, send return +-# 1: when send ring full, alloc mbuf from mempool to send data +-expand_send_ring = 0 +- + #protocol stack thread per loop params + #read data form protocol stack into recv_ring + read_connect_number = 4 +-- +2.33.0 + diff --git a/0124-set-ltran.patch b/0124-set-ltran.patch new file mode 100644 index 0000000..c477d35 --- /dev/null +++ b/0124-set-ltran.patch @@ -0,0 +1,25 @@ +From c565ac1ced3eba745f22cdca849c3d38aaf386f1 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Sat, 27 Jan 2024 02:22:11 +0000 +Subject: [PATCH] set ltran + +--- + src/lstack/lstack.conf | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index fc49944..60f3ee5 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -12,7 +12,7 @@ dpdk_args=["--socket-mem", "2048,0,0,0", "--huge-dir", "/mnt/hugepages-lstack", + + stack_thread_mode="run-to-wakeup" + +-use_ltran=1 ++use_ltran=0 + kni_switch=0 + + low_power_mode=0 +-- +2.33.0 + diff --git a/0125-add-bond-doc.patch b/0125-add-bond-doc.patch new file mode 100644 index 0000000..6f71327 --- /dev/null +++ b/0125-add-bond-doc.patch @@ -0,0 +1,25 @@ +From 44f8b983df75103b1bd3befbabeebe3ef406dbb1 Mon Sep 17 00:00:00 2001 +From: compile_success <980965867@qq.com> +Date: Sat, 27 Jan 2024 09:16:46 +0000 +Subject: [PATCH] add bond doc + +--- + src/lstack/lstack.conf | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/lstack/lstack.conf b/src/lstack/lstack.conf +index 60f3ee5..a7f4e75 100644 +--- a/src/lstack/lstack.conf ++++ b/src/lstack/lstack.conf +@@ -62,3 +62,8 @@ listen_shadow=0 + + #vlan mode; only support -1~4094, -1 is disabled + nic_vlan_mode=-1 ++ ++#bond mode; only support bond 4 or 6 mode ,-1 is disabled ++bond_mode=-1 ++#bond slave mac, separated by ; , only support 2 slave mac ++#bond_slave_mac="aa:bb:cc:dd:ee:ff;gg:hh:ii:jj:kk:ll" +-- +2.33.0 + diff --git a/0126-cfg-host_addr-is-not-mandatory.patch b/0126-cfg-host_addr-is-not-mandatory.patch new file mode 100644 index 0000000..27a2f71 --- /dev/null +++ b/0126-cfg-host_addr-is-not-mandatory.patch @@ -0,0 +1,61 @@ +From 1ad9802429cc2d2cf8eb90ec84cfed7d3c3d4feb Mon Sep 17 00:00:00 2001 +From: zhengjiebing +Date: Mon, 29 Jan 2024 15:01:05 +0800 +Subject: [PATCH] cfg: host_addr is not mandatory + +--- + src/lstack/core/lstack_cfg.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 028ea26..7e4482f 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -185,6 +185,10 @@ static int32_t parse_gateway_addr(void) + char *value; + bool ok; + ++ if (ip4_addr_isany_val(g_config_params.host_addr)) { ++ return 0; ++ } ++ + ok = config_lookup_string(&g_config, "gateway_addr", (const char **)&value); + if (!ok) { + return -EINVAL; +@@ -202,6 +206,10 @@ static int32_t parse_mask_addr(void) + uint32_t mask; + bool ok; + ++ if (ip4_addr_isany_val(g_config_params.host_addr)) { ++ return 0; ++ } ++ + ok = config_lookup_string(&g_config, "mask_addr", (const char **)&value); + if (!ok) { + return -EINVAL; +@@ -225,7 +233,7 @@ static int32_t parse_host_addr(void) + + ok = config_lookup_string(&g_config, "host_addr", (const char **)&value); + if (!ok) { +- return -EINVAL; ++ return 0; + } + + g_config_params.host_addr.addr = inet_addr(value); +@@ -242,7 +250,12 @@ static int32_t parse_host_addr6(void) + + ok = config_lookup_string(&g_config, "host_addr6", (const char **)&value); + if (!ok) { +- return 0; ++ if (ip4_addr_isany_val(g_config_params.host_addr)) { ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: host_addr and host_addr6 must have a valid one."); ++ return -EINVAL; ++ } else { ++ return 0; ++ } + } + + if (ip6addr_aton(value, &g_config_params.host_addr6) == 0) { +-- +2.33.0 + diff --git a/0127-add-bond1-support.patch b/0127-add-bond1-support.patch new file mode 100644 index 0000000..e609d70 --- /dev/null +++ b/0127-add-bond1-support.patch @@ -0,0 +1,139 @@ +From cfe5641d29e425c9da54b270b7945d17ab5d594b Mon Sep 17 00:00:00 2001 +From: zhangmengxuan +Date: Mon, 22 Jan 2024 13:52:50 +0800 +Subject: [PATCH] add bond1 support + +--- + src/lstack/core/lstack_cfg.c | 28 ++++++++++++++++++++++++---- + src/lstack/core/lstack_dpdk.c | 24 ++++++++++++++++++++++++ + src/lstack/include/lstack_cfg.h | 1 + + 3 files changed, 49 insertions(+), 4 deletions(-) + +diff --git a/src/lstack/core/lstack_cfg.c b/src/lstack/core/lstack_cfg.c +index 7e4482f..b533a33 100644 +--- a/src/lstack/core/lstack_cfg.c ++++ b/src/lstack/core/lstack_cfg.c +@@ -40,6 +40,8 @@ + #define NUMA_CPULIST_PATH "/sys/devices/system/node/node%u/cpulist" + #define DEV_MAC_LEN 17 + #define CPUS_MAX_NUM 256 ++#define BOND_MIIMON_MIN 1 ++#define BOND_MIIMON_MAX INT_MAX + + static struct cfg_params g_config_params; + +@@ -72,6 +74,7 @@ static int32_t parse_process_index(void); + static int32_t parse_seperate_sendrecv_args(void); + static int32_t parse_tuple_filter(void); + static int32_t parse_bond_mode(void); ++static int32_t parse_bond_miimon(void); + static int32_t parse_bond_slave_mac(void); + static int32_t parse_use_sockmap(void); + static int32_t parse_udp_enable(void); +@@ -134,6 +137,7 @@ static struct config_vector_t g_config_tbl[] = { + { "process_idx", parse_process_index }, + { "tuple_filter", parse_tuple_filter }, + { "bond_mode", parse_bond_mode }, ++ { "bond_miimon", parse_bond_miimon}, + { "bond_slave_mac", parse_bond_slave_mac }, + { "use_sockmap", parse_use_sockmap }, + { "udp_enable", parse_udp_enable }, +@@ -1181,14 +1185,30 @@ static int32_t parse_bond_mode(void) + if (g_config_params.bond_mode == -1) { + return 0; + } +- if (g_config_params.bond_mode != BONDING_MODE_8023AD && g_config_params.bond_mode != BONDING_MODE_ALB) { +- LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid bond mode = %d. only supports bond mode = 4,6.\n", +- g_config_params.bond_mode); +- return -EINVAL; ++ ++ switch (g_config_params.bond_mode) { ++ case BONDING_MODE_ACTIVE_BACKUP: ++ case BONDING_MODE_8023AD: ++ case BONDING_MODE_ALB: ++ break; ++ default: ++ LSTACK_PRE_LOG(LSTACK_ERR, "cfg: invalid bond mode = %d. only supports bond mode = 1,4,6.\n", ++ g_config_params.bond_mode); ++ return -EINVAL; // Invalid bond mode + } + return 0; + } + ++static int32_t parse_bond_miimon(void) ++{ ++ int32_t ret; ++ if (g_config_params.bond_mode == -1) { ++ return 0; ++ } ++ PARSE_ARG(g_config_params.bond_miimon, "bond_miimon", 10, BOND_MIIMON_MIN, BOND_MIIMON_MAX, ret); ++ return ret; ++} ++ + static int32_t parse_bond_slave_mac(void) + { + if (g_config_params.bond_mode == -1) { +diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c +index 7f1ceb8..e352850 100644 +--- a/src/lstack/core/lstack_dpdk.c ++++ b/src/lstack/core/lstack_dpdk.c +@@ -462,6 +462,20 @@ static void rss_setup(const int port_id, const uint16_t nb_queues) + free(reta_conf); + } + ++int32_t dpdk_bond_primary_set(int port_id, int slave_port_id) ++{ ++ int32_t primary_port_id = ethdev_port_id(get_global_cfg_params()->mac_addr); ++ if (slave_port_id == primary_port_id) { ++ int32_t ret = rte_eth_bond_primary_set(port_id, primary_port_id); ++ if (ret != 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk set bond primary port failed ret = %d\n", ret); ++ return -1; ++ } ++ return ret; ++ } ++ return 0; ++} ++ + int32_t dpdk_ethdev_init(int port_id, bool bond_port) + { + uint16_t nb_queues = get_global_cfg_params()->num_cpu; +@@ -533,6 +547,10 @@ int32_t dpdk_ethdev_init(int port_id, bool bond_port) + LSTACK_LOG(ERR, LSTACK, "dpdk add slave port failed ret = %d\n", ret); + return -1; + } ++ ++ if (get_global_cfg_params()->bond_mode == BONDING_MODE_ACTIVE_BACKUP) { ++ dpdk_bond_primary_set(port_id, slave_port_id[i]); ++ } + + ret = rte_eth_dev_start(slave_port_id[i]); + if (ret != 0) { +@@ -736,6 +754,12 @@ int32_t init_dpdk_ethdev(void) + } + } + ++ ret = rte_eth_bond_link_monitoring_set(bond_port_id, get_global_cfg_params()->bond_miimon); ++ if (ret < 0) { ++ LSTACK_LOG(ERR, LSTACK, "dpdk set bond link monitoring failed ret = %d\n", ret); ++ return -1; ++ } ++ + ret = rte_eth_promiscuous_enable(bond_port_id); + if (ret < 0) { + LSTACK_LOG(ERR, LSTACK, "dpdk enable promiscuous failed ret = %d\n", ret); +diff --git a/src/lstack/include/lstack_cfg.h b/src/lstack/include/lstack_cfg.h +index 01d70fb..a00e47a 100644 +--- a/src/lstack/include/lstack_cfg.h ++++ b/src/lstack/include/lstack_cfg.h +@@ -112,6 +112,7 @@ struct cfg_params { + uint16_t send_ring_size; + bool tuple_filter; + int8_t bond_mode; ++ int32_t bond_miimon; + struct rte_ether_addr bond_slave_mac_addr[GAZELLE_MAX_BOND_NUM]; + bool use_sockmap; + bool udp_enable; +-- +2.33.0 + diff --git a/0128-fix-t_params-double-free.patch b/0128-fix-t_params-double-free.patch new file mode 100644 index 0000000..6335292 --- /dev/null +++ b/0128-fix-t_params-double-free.patch @@ -0,0 +1,77 @@ +From 8905d508d754a6d75516bbf26839848f4dfef282 Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Mon, 29 Jan 2024 19:11:45 +0800 +Subject: [PATCH] fix t_params double free + +--- + src/lstack/core/lstack_protocol_stack.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c +index 800872b..bb7ec17 100644 +--- a/src/lstack/core/lstack_protocol_stack.c ++++ b/src/lstack/core/lstack_protocol_stack.c +@@ -660,7 +660,7 @@ int32_t stack_setup_thread(void) + for (uint32_t i = 0; i < queue_num; ++i) { + t_params[i] = malloc(sizeof(struct thread_params)); + if (t_params[i] == NULL) { +- goto OUT; ++ goto OUT1; + } + } + +@@ -669,18 +669,18 @@ int32_t stack_setup_thread(void) + if (i % 2 == 0) { + ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_RECV_THREAD_NAME, process_index, i / 2); + if (ret < 0) { +- goto OUT; ++ goto OUT1; + } + } else { + ret = sprintf_s(name, sizeof(name), "%s_%d_%d", LSTACK_SEND_THREAD_NAME, process_index, i / 2); + if (ret < 0) { +- goto OUT; ++ goto OUT1; + } + } + } else { + ret = sprintf_s(name, sizeof(name), "%s", LSTACK_THREAD_NAME); + if (ret < 0) { +- goto OUT; ++ goto OUT1; + } + } + +@@ -689,24 +689,26 @@ int32_t stack_setup_thread(void) + + ret = create_thread((void *)t_params[i], name, gazelle_stack_thread); + if (ret != 0) { +- goto OUT; ++ goto OUT1; + } + } + + /* 2: wait stack thread and kernel_event thread init finish */ + wait_sem_value(&g_stack_group.sem_stack_setup, queue_num * 2); + if (g_stack_group.stack_setup_fail) { +- goto OUT; ++ /* t_params free by stack thread */ ++ goto OUT2; + } + g_stack_group.stack_num = queue_num; + + return 0; +-OUT: ++OUT1: + for (int32_t i = 0; i < queue_num; ++i) { + if (t_params[i] != NULL) { + free(t_params[i]); + } + } ++OUT2: + return -1; + } + +-- +2.33.0 + diff --git a/0129-fix-receive-fin-packet-process-error.patch b/0129-fix-receive-fin-packet-process-error.patch new file mode 100644 index 0000000..4c8ec0e --- /dev/null +++ b/0129-fix-receive-fin-packet-process-error.patch @@ -0,0 +1,155 @@ +From 517d32ae3467596ca8173ff5f9300aa7d84d2b7f Mon Sep 17 00:00:00 2001 +From: jiangheng +Date: Mon, 22 Jan 2024 17:30:30 +0800 +Subject: [PATCH] fix receive fin packet process error + +--- + src/lstack/core/lstack_lwip.c | 67 +++++++++++++++++++++++------------ + 1 file changed, 45 insertions(+), 22 deletions(-) + +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index fe30edf..a7201aa 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -38,6 +38,8 @@ + #include "lstack_cfg.h" + #include "lstack_lwip.h" + ++static const uint8_t fin_packet = 0; ++ + static void free_ring_pbuf(struct rte_ring *ring) + { + void *pbufs[SOCK_RECV_RING_SIZE]; +@@ -509,13 +511,15 @@ static inline struct pbuf *pbuf_last(struct pbuf *pbuf) + ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apiflags) + { + if (sock->conn->recvmbox == NULL) { +- return 0; ++ sock->conn->pending_err = ERR_CONN; ++ GAZELLE_RETURN(ENOTCONN); + } + + free_recv_ring_readover(sock->recv_ring); + + uint32_t free_count = gazelle_ring_free_count(sock->recv_ring); + if (free_count == 0) { ++ sock->conn->pending_err = ERR_WOULDBLOCK; + GAZELLE_RETURN(EAGAIN); + } + +@@ -534,12 +538,19 @@ ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apifl + err = netconn_recv_tcp_pbuf_flags(sock->conn, &pbufs[i], apiflags); + } + if (err != ERR_OK) { +- if (recv_len > 0) { +- /* already received data, return that (this trusts in getting the same error from +- netconn layer again next time netconn_recv is called) */ ++ /* fin has been read from recvmbox, put it to recv_ring */ ++ if (!NETCONN_IS_UDP(sock) && ++ (netconn_is_flag_set(sock->conn, NETCONN_FIN_RX_PENDING) || err == ERR_CLSD)) { ++ /* fin has been read, lwip don't need to process fin packet */ ++ netconn_clear_flags(sock->conn, NETCONN_FIN_RX_PENDING); ++ pbufs[i] = NULL; ++ read_count++; + break; + } +- return (err == ERR_CLSD) ? 0 : -1; ++ ++ /* store err to pending_err again, clear it after app read */ ++ sock->conn->pending_err = err; ++ GAZELLE_RETURN(err_to_errno(err)); + } + + recv_len += pbufs[i]->tot_len; +@@ -551,25 +562,17 @@ ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apifl + } + + uint32_t enqueue_num = gazelle_ring_sp_enqueue(sock->recv_ring, (void **)pbufs, read_count); +- for (uint32_t i = enqueue_num; i < read_count; i++) { +- if (NETCONN_IS_UDP(sock)) { +- pbuf_free(pbufs[i]); +- } else { +- /* update receive window */ +- tcp_recved(sock->conn->pcb.tcp, pbufs[i]->tot_len); +- pbuf_free(pbufs[i]); +- } +- sock->stack->stats.read_lwip_drop++; ++ if (enqueue_num != read_count) { ++ LSTACK_LOG(ERR, LSTACK, "Code shouldn't get here!\n"); + } + + for (uint32_t i = 0; get_protocol_stack_group()->latency_start && i < read_count; i++) { +- calculate_lstack_latency(&sock->stack->latency, pbufs[i], GAZELLE_LATENCY_LWIP); ++ if (pbufs[i] != NULL) { ++ calculate_lstack_latency(&sock->stack->latency, pbufs[i], GAZELLE_LATENCY_LWIP); ++ } + } + + sock->stack->stats.read_lwip_cnt += read_count; +- if (recv_len == 0) { +- GAZELLE_RETURN(EAGAIN); +- } + return recv_len; + } + +@@ -817,7 +820,8 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags + bool latency_enable = get_protocol_stack_group()->latency_start; + + if (sock->errevent > 0 && !NETCONN_IS_DATAIN(sock)) { +- return 0; ++ errno = err_to_errno(netconn_err(sock->conn)); ++ return -1; + } + + thread_bind_stack(sock); +@@ -839,7 +843,8 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags + while (gazelle_ring_read(sock->recv_ring, (void **)&pbuf, 1) != 1 && recvd == 0) { + /* if the connection is disconnected, recv return 0 */ + if (sock->errevent > 0 && !NETCONN_IS_DATAIN(sock)) { +- return 0; ++ errno = err_to_errno(netconn_err(sock->conn)); ++ return -1; + } + + lstack_block_wait(sock->wakeup); +@@ -847,6 +852,23 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags + } + } + ++ /* fin */ ++ if (unlikely(pbuf == NULL)) { ++ if (recvd > 0) { ++ /* read data first, then read fin */ ++ sock->recv_lastdata = (void *)&fin_packet; ++ gazelle_ring_read_over(sock->recv_ring); ++ break; ++ } ++ gazelle_ring_read_over(sock->recv_ring); ++ return 0; ++ } ++ ++ /* pending fin */ ++ if (unlikely(pbuf == (void *)&fin_packet)) { ++ return 0; ++ } ++ + copy_len = (recv_left > pbuf->tot_len) ? pbuf->tot_len : recv_left; + if (copy_len > UINT16_MAX) { + copy_len = UINT16_MAX; +@@ -946,10 +968,11 @@ void do_lwip_read_recvlist(struct protocol_stack *stack, uint32_t max_num) + } else { + len = lwip_recv(sock->conn->socket, NULL, 0, 0); + } +- if (len == 0) { ++ if (len < 0 && errno != EAGAIN) { + sock->errevent = 1; + add_sock_event(sock, EPOLLERR); +- } else if (len > 0) { ++ /* = 0: fin */ ++ } else if (len >= 0) { + add_sock_event(sock, EPOLLIN); + } + } +-- +2.33.0 + diff --git a/0130-support-netperf-UDP_STREAM-and-UDP_RR.patch b/0130-support-netperf-UDP_STREAM-and-UDP_RR.patch new file mode 100644 index 0000000..0d75020 --- /dev/null +++ b/0130-support-netperf-UDP_STREAM-and-UDP_RR.patch @@ -0,0 +1,129 @@ +From abbd69fdbc7b43229093a1ec57ea6d0dd952db8d Mon Sep 17 00:00:00 2001 +From: yangchen +Date: Fri, 26 Jan 2024 17:21:38 +0800 +Subject: [PATCH] support netperf UDP_STREAM and UDP_RR + +--- + src/lstack/api/lstack_rtw_api.c | 7 +++---- + src/lstack/api/lstack_wrap.c | 1 + + src/lstack/core/lstack_lwip.c | 21 +++++++++++++++------ + 3 files changed, 19 insertions(+), 10 deletions(-) + +diff --git a/src/lstack/api/lstack_rtw_api.c b/src/lstack/api/lstack_rtw_api.c +index 04944d5..839d320 100644 +--- a/src/lstack/api/lstack_rtw_api.c ++++ b/src/lstack/api/lstack_rtw_api.c +@@ -160,10 +160,10 @@ static ssize_t rtw_udp_recvfrom(int sockfd, void *buf, size_t len, int flags, + + while (1) { + ret = do_lwip_read_from_stack(sockfd, buf, len, flags, addr, addrlen); +- if (ret > 0) { ++ if (ret >= 0) { + return ret; + } +- if (ret <= 0 && errno != EAGAIN) { ++ if (ret < 0 && errno != EAGAIN) { + return -1; + } + sock = sock->listen_next; +@@ -205,7 +205,6 @@ ssize_t rtw_sendto(int sockfd, const void *buf, size_t len, int flags, + return do_lwip_send_to_stack(sockfd, buf, len, flags, addr, addrlen); + } + +- + int rtw_epoll_wait(int epfd, struct epoll_event* events, int maxevents, int timeout) + { + return lstack_rtw_epoll_wait(epfd, events, maxevents, timeout); +@@ -234,7 +233,7 @@ int rtw_shutdown(int fd, int how) + { + struct lwip_sock *sock = get_socket_by_fd(fd); + if (sock && sock->wakeup && sock->wakeup->epollfd == fd) { +- GAZELLE_RETURN(ENOTSOCK); ++ GAZELLE_RETURN(ENOTSOCK); + } + + return stack_broadcast_shutdown(fd, how); +diff --git a/src/lstack/api/lstack_wrap.c b/src/lstack/api/lstack_wrap.c +index 372e102..8992e39 100644 +--- a/src/lstack/api/lstack_wrap.c ++++ b/src/lstack/api/lstack_wrap.c +@@ -375,6 +375,7 @@ static bool unsupport_optname(int32_t optname) + optname == SO_RCVBUF || + optname == TCP_INFO || + optname == TCP_MAXSEG || ++ optname == SO_DONTROUTE || + optname == TCP_CONGESTION) { + return true; + } +diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c +index a7201aa..22605dd 100644 +--- a/src/lstack/core/lstack_lwip.c ++++ b/src/lstack/core/lstack_lwip.c +@@ -402,7 +402,7 @@ static ssize_t do_lwip_fill_sendring(struct lwip_sock *sock, const void *buf, si + } + + struct protocol_stack *stack = sock->stack; +- if (!stack || len == 0) { ++ if (!stack) { + return 0; + } + +@@ -421,6 +421,11 @@ static ssize_t do_lwip_fill_sendring(struct lwip_sock *sock, const void *buf, si + uint32_t write_avail = gazelle_ring_readable_count(sock->send_ring); + struct wakeup_poll *wakeup = sock->wakeup; + ++ /* if udp send 0 packet, set write_num to at least 1 */ ++ if (NETCONN_IS_UDP(sock) && write_num == 0) { ++ write_num = 1; ++ } ++ + while (!netconn_is_nonblocking(sock->conn) && (write_avail < write_num)) { + if (sock->errevent > 0) { + GAZELLE_RETURN(ENOTCONN); +@@ -454,7 +459,7 @@ static ssize_t do_lwip_fill_sendring(struct lwip_sock *sock, const void *buf, si + } + + END: +- if (send_len == 0) { ++ if (send_len == 0 && !NETCONN_IS_UDP(sock)) { + errno = EAGAIN; + return -1; + } +@@ -735,19 +740,18 @@ ssize_t do_lwip_send_to_stack(int32_t fd, const void *buf, size_t len, int32_t f + GAZELLE_RETURN(EINVAL); + } + +- if (len == 0) { ++ struct lwip_sock *sock = get_socket_by_fd(fd); ++ if (len == 0 && !NETCONN_IS_UDP(sock)) { + return 0; + } + +- struct lwip_sock *sock = get_socket_by_fd(fd); +- + thread_bind_stack(sock); + + if (sock->same_node_tx_ring != NULL) { + return gazelle_same_node_ring_send(sock, buf, len, flags); + } + ssize_t send = do_lwip_fill_sendring(sock, buf, len, addr, addrlen); +- if (send <= 0) { ++ if (send < 0 || (send == 0 && !NETCONN_IS_UDP(sock))) { + return send; + } + +@@ -852,6 +856,11 @@ ssize_t do_lwip_read_from_stack(int32_t fd, void *buf, size_t len, int32_t flags + } + } + ++ /* if udp recv a packet whose len is 0, return 0 */ ++ if (NETCONN_IS_UDP(sock) && pbuf->tot_len == 0) { ++ return 0; ++ } ++ + /* fin */ + if (unlikely(pbuf == NULL)) { + if (recvd > 0) { +-- +2.33.0 + diff --git a/gazelle.spec b/gazelle.spec index 22b87a8..f42855c 100644 --- a/gazelle.spec +++ b/gazelle.spec @@ -2,7 +2,7 @@ Name: gazelle Version: 1.0.2 -Release: 25 +Release: 26 Summary: gazelle is a high performance user-mode stack License: MulanPSL-2.0 URL: https://gitee.com/openeuler/gazelle @@ -133,6 +133,17 @@ Patch9116: 0116-diff-lstack-and-ltran-dfx-sock.patch Patch9117: 0117-fix-host_addr6-can-be-assigned-a-multicast-address.patch Patch9118: 0118-udp-do-not-merge-data-into-last-pbuf.patch Patch9119: 0119-adpat-dpdk-23.11.patch +Patch9120: 0120-modify-conf-vlan-default-vlaue.patch +Patch9121: 0121-remove-unused-variables-in-pbuf-and-reduce-mbuf-size.patch +Patch9122: 0122-optimize-recv-exit-process-for-FIN-and-unsupport-SO_.patch +Patch9123: 0123-remove-expand_send_ring.patch +Patch9124: 0124-set-ltran.patch +Patch9125: 0125-add-bond-doc.patch +Patch9126: 0126-cfg-host_addr-is-not-mandatory.patch +Patch9127: 0127-add-bond1-support.patch +Patch9128: 0128-fix-t_params-double-free.patch +Patch9129: 0129-fix-receive-fin-packet-process-error.patch +Patch9130: 0130-support-netperf-UDP_STREAM-and-UDP_RR.patch %description %{name} is a high performance user-mode stack. @@ -174,6 +185,19 @@ install -Dpm 0640 %{_builddir}/%{name}-%{version}/src/ltran/ltran.conf %{b %config(noreplace) %{conf_path}/ltran.conf %changelog +* Sun Feb 4 CST yinbin6 - 1.0.2-26 +- support netperf UDP_STREAM and UDP_RR +- fix receive fin packet process error +- fix t_params double free +- add bond1 support +- cfg: host_addr is not mandatory +- add bond doc +- set ltran +- remove expand_send_ring +- optimize recv exit process for FIN and unsupport SO_RCVBUF +- remove unused variables in pbuf and reduce mbuf size +- modify conf vlan default vlaue + * Sat Jan 20 CST yinbin6 - 1.0.2-25 - adpat dpdk 23.11 - udp: do not merge data into last pbuf