加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0004-fix-error-of-deleting-conn-table-in-connect.patch 3.74 KB
一键复制 编辑 原始数据 按行查看 历史
Aurora 提交于 2023-12-07 03:26 . update lwip to 2.1.3-39.oe2203sp1
From ed999b65aac44fcb68fc533e8bd5a23cf2d09e7c Mon Sep 17 00:00:00 2001
From: wuchangsheng <wuchangsheng2@huawei.com>
Date: Wed, 26 May 2021 19:09:41 +0800
Subject: [PATCH] fix-error-of-deleting-conn-table-in-connect
---
src/include/lwip/priv/tcp_priv.h | 42 ++++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
index 192edc4..599289f 100644
--- a/src/include/lwip/priv/tcp_priv.h
+++ b/src/include/lwip/priv/tcp_priv.h
@@ -358,6 +358,28 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
return vdev_reg_xmit(reg_type, &qtuple);
}
+
+/* TCP_RMV pcb whether to call vdev_reg_xmit to reg conn-sock table.
+ fix the error of adding conn table in connect func and deleting conn table
+ when moving pcb from tcp_bound_pcbs to tcp_listen_pcbs */
+static inline int need_vdev_reg(struct tcp_pcb *pcb_list, const struct tcp_pcb *pcb)
+{
+ /* tw_pcbs_list and tcp_listen_pcbs will not change pcb to other list always reg */
+ if ((pcb_list == tcp_tw_pcbs) || (pcb_list == tcp_listen_pcbs.pcbs)) {
+ return 1;
+ }
+
+ /* tcp_active_pcbs in FIN_WAIT_1,FIN_WAIT_2,CLOSING state will change pcb to tw_pcbs_list don't reg.
+ detail info see func tcp_process in tcp_in.c */
+ if (pcb_list == tcp_active_pcbs) {
+ if ((pcb->state != FIN_WAIT_1) && (pcb->state != FIN_WAIT_2) && (pcb->state != CLOSING)) {
+ return 1;
+ }
+ }
+
+ /* tcp_bound_pcbs and others don't reg */
+ return 0;
+}
#endif
/* Axioms about the above lists:
@@ -392,10 +414,12 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
tcp_timer_needed(); \
} while(0)
#define TCP_RMV(pcbs, npcb) do { \
- if (pcb->state == LISTEN) \
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
- else \
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
+ if (need_vdev_reg(*pcbs, npcb)) { \
+ if (npcb->state == LISTEN) \
+ vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
+ else \
+ vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb); \
+ } \
struct tcp_pcb *tcp_tmp_pcb; \
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \
LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \
@@ -488,10 +512,12 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
#define TCP_RMV(pcbs, npcb) \
do { \
- if (pcb->state == LISTEN) \
- vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
- else \
- vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
+ if (need_vdev_reg(*pcbs, npcb)) { \
+ if (npcb->state == LISTEN) \
+ vdev_reg_done(REG_RING_TCP_LISTEN_CLOSE, npcb); \
+ else \
+ vdev_reg_done(REG_RING_TCP_CONNECT_CLOSE, npcb);\
+ } \
if(*(pcbs) == (npcb)) { \
(*(pcbs)) = (*pcbs)->next; \
if (*pcbs) \
--
2.23.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化