• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From f1692b0c380241699f70adbf7796cb2c7b3a5c94 Mon Sep 17 00:00:00 2001
2From: jiangheng12 <jiangheng14@huawei.com>
3Date: Sat, 1 Apr 2023 16:59:28 +0800
4Subject: [PATCH] fix last_unsent/last_unacked
5
6---
7 src/core/tcp_in.c  | 25 +++++++++++++------------
8 src/core/tcp_out.c | 18 +++++++++++++-----
9 2 files changed, 26 insertions(+), 17 deletions(-)
10
11diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
12index 719cf04..7e7d70a 100644
13--- a/src/core/tcp_in.c
14+++ b/src/core/tcp_in.c
15@@ -1375,18 +1375,19 @@ tcp_receive(struct tcp_pcb *pcb)
16             }
17           }
18         }
19-      }
20-      /* fast rexmit when receive too many acks with data */
21-      if (TCP_SEQ_LT(ackno + 1, pcb->snd_nxt)) {
22-        if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge) {
23-          if (pcb->rtime >= 0) {
24-            if (pcb->lastack == ackno) {
25-              found_dataack = 1;
26-              ++pcb->dataacks;
27-              if (pcb->dataacks > GAZELLE_TCP_MAX_DATA_ACK_NUM) {
28-                if (tcp_rexmit(pcb) == ERR_OK) {
29-                  pcb->rtime = 0;
30-                  pcb->dataacks = 0;
31+      } else {
32+        /* fast rexmit when receive too many acks with data */
33+        if (TCP_SEQ_LT(ackno + 1, pcb->snd_nxt)) {
34+          if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge) {
35+            if (pcb->rtime >= 0) {
36+              if (pcb->lastack == ackno) {
37+                found_dataack = 1;
38+                ++pcb->dataacks;
39+                if ((pcb->dataacks > GAZELLE_TCP_MAX_DATA_ACK_NUM) && (pcb->nrtx < (TCP_MAXRTX / 2))) {
40+                  if (tcp_rexmit(pcb) == ERR_OK) {
41+                    pcb->rtime = 0;
42+                    pcb->dataacks = 0;
43+                  }
44                 }
45               }
46             }
47diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
48index b1c317d..6250e6b 100644
49--- a/src/core/tcp_out.c
50+++ b/src/core/tcp_out.c
51@@ -1444,10 +1444,7 @@ tcp_output(struct tcp_pcb *pcb)
52   pcb->persist_backoff = 0;
53
54   /* useg should point to last segment on unacked queue */
55-  useg = pcb->unacked;
56-  if (useg != NULL) {
57-    for (; useg->next != NULL; useg = useg->next);
58-  }
59+  useg = pcb->last_unacked;
60
61   /* data available and window allows it to be sent? */
62 #if GAZELLE_ENABLE
63@@ -1515,7 +1512,11 @@ tcp_output(struct tcp_pcb *pcb)
64             return err;
65         }
66
67+        if (pcb->last_unsent == pcb->unsent) {
68+            pcb->last_unsent = last_seg->next;
69+        }
70         pcb->unsent = last_seg->next;
71+
72         if (pcb->state != SYN_SENT) {
73             tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW);
74         }
75@@ -1535,6 +1536,7 @@ tcp_output(struct tcp_pcb *pcb)
76             if (TCP_TCPLEN(tmp_seg) > 0) {
77                 tmp_seg->next = NULL;
78                 if (pcb->unacked == NULL) {
79+                    pcb->last_unacked = tmp_seg;
80                     pcb->unacked = tmp_seg;
81                     useg = tmp_seg;
82                 } else {
83@@ -1550,6 +1552,9 @@ tcp_output(struct tcp_pcb *pcb)
84                     } else {
85                         /* add segment to tail of unacked list */
86                         useg->next = tmp_seg;
87+                        if (pcb->last_unacked == useg) {
88+                            pcb->last_unacked = tmp_seg;
89+                        }
90                         useg = useg->next;
91                     }
92                 }
93@@ -1603,6 +1608,9 @@ end_loop:
94 #if TCP_OVERSIZE_DBGCHECK
95     seg->oversize_left = 0;
96 #endif /* TCP_OVERSIZE_DBGCHECK */
97+    if (pcb->last_unsent == pcb->unsent) {
98+      pcb->last_unsent = seg->next;
99+    }
100     pcb->unsent = seg->next;
101     if (pcb->state != SYN_SENT) {
102       tcp_clear_flags(pcb, TF_ACK_DELAY | TF_ACK_NOW);
103@@ -1709,7 +1717,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
104   int seg_chksum_was_swapped = 0;
105 #endif
106
107-#if USE_LIBOS
108+#if GAZELLE_ENABLE
109   lstack_calculate_aggregate(1, seg->len);
110 #endif
111
112--
1132.23.0
114
115