Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/netinet Pull up revision 1.153 (requested by thorpe...



details:   https://anonhg.NetBSD.org/src/rev/aed66a1cd3b9
branches:  netbsd-1-6
changeset: 529050:aed66a1cd3b9
user:      lukem <lukem%NetBSD.org@localhost>
date:      Wed Aug 28 02:33:36 2002 +0000

description:
Pull up revision 1.153 (requested by thorpej in ticket #738):
Fix a problem introduced in rev 1.103, where we recycle a TIME_WAIT
TCPCB .. the fields need to be converted back to net-order, because
the packet is checksummed after the TCPCB lookup happens.
>From YAMAMOTO Takashi <yamt%mwd.biglobe.ne.jp@localhost>.

diffstat:

 sys/netinet/tcp_input.c |  23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diffs (57 lines):

diff -r 16db776b1d97 -r aed66a1cd3b9 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Tue Aug 27 23:35:14 2002 +0000
+++ b/sys/netinet/tcp_input.c   Wed Aug 28 02:33:36 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.141.4.1 2002/07/21 00:55:11 lukem Exp $        */
+/*     $NetBSD: tcp_input.c,v 1.141.4.2 2002/08/28 02:33:36 lukem Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -152,7 +152,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.141.4.1 2002/07/21 00:55:11 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.141.4.2 2002/08/28 02:33:36 lukem Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -276,6 +276,17 @@
        NTOHS((th)->th_urp);                                            \
 } while (0)
 
+/*
+ * ... and reverse the above.
+ */
+#define        TCP_FIELDS_TO_NET(th)                                           \
+do {                                                                   \
+       HTONL((th)->th_seq);                                            \
+       HTONL((th)->th_ack);                                            \
+       HTONS((th)->th_win);                                            \
+       HTONS((th)->th_urp);                                            \
+} while (0)
+
 #ifdef TCP_CSUM_COUNTERS
 #include <sys/device.h>
 
@@ -1750,12 +1761,20 @@
                         * while in TIME_WAIT, drop the old connection
                         * and start over if the sequence numbers
                         * are above the previous ones.
+                        *
+                        * NOTE: We will checksum the packet again, and
+                        * so we need to put the header fields back into
+                        * network order!
+                        * XXX This kind of sucks, but we don't expect
+                        * XXX this to happen very often, so maybe it
+                        * XXX doesn't matter so much.
                         */
                        if (tiflags & TH_SYN &&
                            tp->t_state == TCPS_TIME_WAIT &&
                            SEQ_GT(th->th_seq, tp->rcv_nxt)) {
                                iss = tcp_new_iss(tp, tp->snd_nxt);
                                tp = tcp_close(tp);
+                               TCP_FIELDS_TO_NET(th);
                                goto findpcb;
                        }
                        /*



Home | Main Index | Thread Index | Old Index