lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] PATCH TCP connection restart


From: Paul
Subject: [lwip-users] PATCH TCP connection restart
Date: Tue, 16 Mar 2004 22:16:19 +1030
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

Hi everyone,

Here is patch that fixes the condition where lwip starts a tcp connection with a sequence number that is valid for a previous session. lwip sends a SYN the other end just sends back ACK. With this patch a reset is sent and the sequence number is invalidated. This seqence commonly occurs when debugging lwip or reseting lwip as the starting sequence number is fixed.

Paul
Index: tcp_in.c
===================================================================
RCS file: lwip/src/core/tcp_in.c,v
retrieving revision 1.2
diff -u -r1.2 tcp_in.c
--- tcp_in.c    5 Mar 2004 03:36:30 -0000       1.2
+++ tcp_in.c    16 Mar 2004 06:07:04 -0000
@@ -540,8 +540,16 @@
   case SYN_SENT:
     LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu 
unacked %lu\n", ackno,
      pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno)));
-    if ((flags & TCP_ACK) && (flags & TCP_SYN)
-        && ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) {
+    if (flags & (TCP_ACK | TCP_SYN))
+    {
+        if ( ackno != ntohl(pcb->unacked->tcphdr->seqno) + 1) {
+          tcp_rst( ackno, ackno, &(pcb->local_ip), &(pcb->remote_ip), 
pcb->local_port, pcb->remote_port);
+          return ERR_OK;          
+        }
+    } else
+    {
+        return ERR_OK;
+    }
       pcb->rcv_nxt = seqno + 1;
       pcb->lastack = ackno;
       pcb->snd_wnd = tcphdr->wnd;
@@ -561,7 +569,6 @@
        * connected. */
       TCP_EVENT_CONNECTED(pcb, ERR_OK, err);
       tcp_ack(pcb);
-    }
     break;
   case SYN_RCVD:
     if (flags & TCP_ACK &&

reply via email to

[Prev in Thread] Current Thread [Next in Thread]