代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/gazelle 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 3939d1baef23269bfd89d616979df4caf02801ca Mon Sep 17 00:00:00 2001
From: kircher <majun65@huawei.com>
Date: Sat, 27 May 2023 20:26:02 +0800
Subject: [PATCH] drop netbuf in read_lwip_data to fix mem overflow
---
src/lstack/core/lstack_lwip.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index 805ac82..f12bfdb 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -743,7 +743,6 @@ ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags)
uint32_t data_count = rte_ring_count(sock->conn->recvmbox->ring);
uint32_t read_num = LWIP_MIN(free_count, data_count);
struct pbuf *pbufs[SOCK_RECV_RING_SIZE];
- struct netbuf *netbufs[SOCK_RECV_RING_SIZE];
uint32_t read_count = 0;
ssize_t recv_len = 0;
@@ -751,10 +750,7 @@ ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags)
err_t err = ERR_OK;
if (NETCONN_IS_UDP(sock)) {
- err = netconn_recv_udp_raw_netbuf_flags(sock->conn, &netbufs[i], apiflags);
- pbufs[i] = netbufs[i]->p;
- pbufs[i]->addr = netbufs[i]->addr;
- pbufs[i]->port = netbufs[i]->port;
+ err = netconn_recv_udp_raw_pbuf_flags(sock->conn, &pbufs[i], apiflags);
} else {
err = netconn_recv_tcp_pbuf_flags(sock->conn, &pbufs[i], apiflags);
}
@@ -776,14 +772,9 @@ ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags)
}
uint32_t enqueue_num = gazelle_ring_sp_enqueue(sock->recv_ring, (void **)pbufs, read_count);
- if (NETCONN_IS_UDP(sock)) {
- for (uint32_t i = 0; i < read_count; i++) {
- memp_free(MEMP_NETBUF, netbufs[i]);
- }
- }
for (uint32_t i = enqueue_num; i < read_count; i++) {
if (NETCONN_IS_UDP(sock)) {
- netbuf_delete(netbufs[i]);
+ pbuf_free(pbufs[i]);
} else {
/* update receive window */
tcp_recved(sock->conn->pcb.tcp, pbufs[i]->tot_len);
@@ -1104,7 +1095,7 @@ ssize_t read_stack_data(int32_t fd, void *buf, size_t len, int32_t flags, struct
del_data_in_event(sock);
}
- if (addr && addrlen) {
+ if (pbuf && addr && addrlen) {
lwip_sock_make_addr(sock->conn, &(pbuf->addr), pbuf->port, addr, addrlen);
}
--
2.23.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。