Skip to content

Commit dadd764

Browse files
jschlumppmichpappas
authored andcommitted
Patch LWIP to allow RST for TIMEWAIT ports
Implementing only the protocol bug fix from RFC1337 causes issues when the stack interacts with linux. Linux tries to use timestamps to reuse a port combination, which LWIP does not implement. As a fallback they use a RST packet but this doesn't work because of the RFC1337 implementation. Therefore, remove the RFC1337 behavior and restore the original TCP RFC behavior. Signed-off-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> GitHub-Closes: #76
1 parent 995f09a commit dadd764

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Don't use the naive RFC1337 mechanism
2+
3+
Other than sending RST frames there is no other way to reuse port
4+
numbers in LWIP. Therefore, allow RST frames when they have the
5+
correct sequence number.
6+
7+
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
8+
--- a/src/core/tcp_in.c 2024-01-23 17:57:59.453522491 +0100
9+
+++ b/src/core/tcp_in.c 2024-01-23 17:58:03.496864164 +0100
10+
@@ -744,6 +744,27 @@
11+
* acceptable since we only send ACKs)
12+
* - second check the RST bit (... return) */
13+
if (flags & TCP_RST) {
14+
+ if (seqno == pcb->rcv_nxt) {
15+
+ /* Go to closed state */
16+
+ tcp_pcb_purge(pcb);
17+
+ /* Remove it from the list */
18+
+ struct tcp_pcb *prev = NULL;
19+
+ struct tcp_pcb *pcbi = tcp_tw_pcbs;
20+
+ while (pcbi != NULL) {
21+
+ if (pcbi == pcb) {
22+
+ if (prev != NULL) {
23+
+ prev->next = pcb->next;
24+
+ } else {
25+
+ tcp_tw_pcbs = pcb->next;
26+
+ }
27+
+ pcbi = pcbi->next;
28+
+ tcp_free(pcb);
29+
+ } else {
30+
+ prev = pcbi;
31+
+ pcbi = pcbi->next;
32+
+ }
33+
+ }
34+
+ }
35+
return;
36+
}
37+

0 commit comments

Comments
 (0)