net: tcp: Don't increment snd.nxt
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Nov 2017 15:32:59 +0000 (10:32 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Thu, 16 Nov 2017 15:46:54 +0000 (10:46 -0500)
Ever since commit 682b414ddb84 ("net: tcp: Support SACK"), we weren't
sending FINs when our connections were shutdown or closed.

For the sackless, normal case, that commit changed the from_seq from
snd.rtx to snd.nxt.  Those are supposed to be in sync for normal operation.
However, the old Plan 9 stack was incrementing snd.nxt whenever it wanted
to send a FIN.  It should *only* increment flgcnt, which is the weird
signal that means to send a FIN, since we end up trying to send one more
byte than we have bytes in the qio.  (And the extra byte is interpreted as
a FIN at some point).

Anyway, the old code, before the SACK overhaul, got away with it since it
was sending with from_seq being snd.rtx (the retrans point).  That's a
little messed up, but no one ever noticed since the old snd.rtx usually had
the value that snd.nxt *should* have had.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/src/net/tcp.c

index 81d296b..45d7217 100644 (file)
@@ -566,7 +566,6 @@ static void tcpshutdown(struct conv *c, int how)
        switch (tcb->state) {
        case Established:
                tcb->flgcnt++;
-               tcb->snd.nxt++;
                tcpsetstate(c, Finwait1);
                tcpoutput(c);
                break;
@@ -602,13 +601,11 @@ static void tcpclose(struct conv *c)
                        break;
                case Established:
                        tcb->flgcnt++;
-                       tcb->snd.nxt++;
                        tcpsetstate(c, Finwait1);
                        tcpoutput(c);
                        break;
                case Close_wait:
                        tcb->flgcnt++;
-                       tcb->snd.nxt++;
                        tcpsetstate(c, Last_ack);
                        tcpoutput(c);
                        break;