代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/lwip 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From d101a2e798f66298c3e3b08ddd1ab4809f54de72 Mon Sep 17 00:00:00 2001
From: compile_success <[email protected]>
Date: Sat, 20 Jan 2024 11:28:45 +0000
Subject: [PATCH] add tcp wnd set option
---
src/core/tcp.c | 21 +++++++++++++++++++--
src/core/tcp_in.c | 6 ++++++
src/core/tcp_out.c | 8 ++++++++
src/include/lwip/tcp.h | 13 +++++++++++++
src/include/lwipsock.h | 1 +
5 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/src/core/tcp.c b/src/core/tcp.c
index 76f0ffd..f03c85f 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -1067,8 +1067,11 @@ tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)
LWIP_ASSERT("tcp_update_rcv_ann_wnd: invalid pcb", pcb != NULL);
new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd;
-
+#if GAZELLE_ENABLE
+ if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((pcb->default_wnd / 2), pcb->mss))) {
+#else
if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) {
+#endif
/* we can advertise more window */
pcb->rcv_ann_wnd = pcb->rcv_wnd;
return new_right_edge - pcb->rcv_ann_right_edge;
@@ -1127,7 +1130,11 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
* watermark is TCP_WND/4), then send an explicit update now.
* Otherwise wait for a packet to be sent in the normal course of
* events (or more window to be available later) */
+#if GAZELLE_ENABLE
+ if (wnd_inflation >= LWIP_MIN((pcb->default_wnd / 4), (TCP_MSS * 4))) {
+#else
if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) {
+#endif
tcp_ack_now(pcb);
tcp_output(pcb);
}
@@ -1312,9 +1319,14 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
pcb->snd_lbb = iss - 1;
/* Start with a window that does not need scaling. When window scaling is
enabled and used, the window is enlarged when both sides agree on scaling. */
+#if GAZELLE_ENABLE
+ pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(pcb->default_wnd);
+ pcb->snd_wnd = pcb->default_wnd;
+#else
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND);
- pcb->rcv_ann_right_edge = pcb->rcv_nxt;
pcb->snd_wnd = TCP_WND;
+#endif
+ pcb->rcv_ann_right_edge = pcb->rcv_nxt;
/* As initial send MSS, we use TCP_MSS but limit it to 536.
The send MSS is updated when an MSS option is received. */
pcb->mss = INITIAL_MSS;
@@ -2108,7 +2120,12 @@ tcp_alloc(u8_t prio)
pcb->snd_buf = TCP_SND_BUF;
/* Start with a window that does not need scaling. When window scaling is
enabled and used, the window is enlarged when both sides agree on scaling. */
+#if GAZELLE_ENABLE
+ pcb->default_wnd = default_wnd_value;
+ pcb->rcv_wnd = pcb->rcv_ann_wnd = default_wnd_value;
+#else
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCPWND_MIN16(TCP_WND);
+#endif
pcb->ttl = TCP_TTL;
/* As initial send MSS, we use TCP_MSS but limit it to 536.
The send MSS is updated when an MSS option is received. */
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
index ec1905f..325be57 100644
--- a/src/core/tcp_in.c
+++ b/src/core/tcp_in.c
@@ -2194,9 +2194,15 @@ tcp_parseopt(struct tcp_pcb *pcb)
pcb->rcv_scale = TCP_RCV_SCALE;
tcp_set_flags(pcb, TF_WND_SCALE);
/* window scaling is enabled, we can use the full receive window */
+#if GAZELLE_ENABLE
+ LWIP_ASSERT("window not at default value", pcb->rcv_wnd == TCPWND_MIN16(pcb->default_wnd));
+ LWIP_ASSERT("window not at default value", pcb->rcv_ann_wnd == TCPWND_MIN16(pcb->default_wnd));
+ pcb->rcv_wnd = pcb->rcv_ann_wnd = pcb->default_wnd;
+#else
LWIP_ASSERT("window not at default value", pcb->rcv_wnd == TCPWND_MIN16(TCP_WND));
LWIP_ASSERT("window not at default value", pcb->rcv_ann_wnd == TCPWND_MIN16(TCP_WND));
pcb->rcv_wnd = pcb->rcv_ann_wnd = TCP_WND;
+#endif /* GAZELLE_ENABLE */
}
break;
#endif /* LWIP_WND_SCALE */
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index bb03aae..137db4c 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -2455,9 +2455,17 @@ tcp_rst(const struct tcp_pcb *pcb, u32_t seqno, u32_t ackno,
optlen = LWIP_TCP_OPT_LENGTH_SEGMENT(0, pcb);
#if LWIP_WND_SCALE
+#if GAZELLE_ENABLE
+ wnd = PP_HTONS(((default_wnd_value >> TCP_RCV_SCALE) & 0xFFFF));
+#else
wnd = PP_HTONS(((TCP_WND >> TCP_RCV_SCALE) & 0xFFFF));
+#endif /* GAZELLE_ENABLE*/
+#else
+#if GAZELLE_ENABLE
+ wnd = PP_HTONS(pcb->default_wnd);
#else
wnd = PP_HTONS(TCP_WND);
+#endif
#endif
p = tcp_output_alloc_header_common(ackno, optlen, 0, lwip_htonl(seqno), local_port,
diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
index 741e58f..7dcb349 100644
--- a/src/include/lwip/tcp.h
+++ b/src/include/lwip/tcp.h
@@ -56,6 +56,10 @@
#include "hlist.h"
#endif
+#if GAZELLE_ENABLE
+#include "lwipsock.h"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -142,13 +146,21 @@ typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err);
#define RCV_WND_SCALE(pcb, wnd) (((wnd) >> (pcb)->rcv_scale))
#define SND_WND_SCALE(pcb, wnd) (((wnd) << (pcb)->snd_scale))
#define TCPWND16(x) ((u16_t)LWIP_MIN((x), 0xFFFF))
+#if GAZELLE_ENABLE
+#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? pcb->default_wnd : TCPWND16(pcb->default_wnd)))
+#else
#define TCP_WND_MAX(pcb) ((tcpwnd_size_t)(((pcb)->flags & TF_WND_SCALE) ? TCP_WND : TCPWND16(TCP_WND)))
+#endif
#else
#define RCV_WND_SCALE(pcb, wnd) (wnd)
#define SND_WND_SCALE(pcb, wnd) (wnd)
#define TCPWND16(x) (x)
+#if GAZELLE_ENABLE
+#define TCP_WND_MAX(pcb) pcb->default_wnd
+#else
#define TCP_WND_MAX(pcb) TCP_WND
#endif
+#endif
/* Increments a tcpwnd_size_t and holds at max value rather than rollover */
#define TCP_WND_INC(wnd, inc) do { \
if ((tcpwnd_size_t)(wnd + inc) >= wnd) { \
@@ -356,6 +368,7 @@ struct tcp_pcb {
tcpwnd_size_t snd_wnd_max; /* the maximum sender window announced by the remote host */
tcpwnd_size_t snd_buf; /* Available buffer space for sending (in bytes). */
+ tcpwnd_size_t default_wnd; /* tcp windows size */
#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3)
u16_t snd_queuelen; /* Number of pbufs currently in the send buffer. */
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
index ccc8c43..d1f12c5 100644
--- a/src/include/lwipsock.h
+++ b/src/include/lwipsock.h
@@ -163,6 +163,7 @@ static inline unsigned same_node_ring_count(struct lwip_sock *sock)
*/
#if GAZELLE_ENABLE
extern uint32_t sockets_num;
+extern uint32_t default_wnd_value;
extern struct lwip_sock *sockets;
extern void do_lwip_init_sock(int32_t fd);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。