summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_input.c
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2002-08-28 02:23:57 +0000
committerthorpej <thorpej@NetBSD.org>2002-08-28 02:23:57 +0000
commitec09d2df2ae565c8cb2aeb10a366dd1efa9e0753 (patch)
treeb77ab67ed506d28ad650d78113a8612853c3824f /sys/netinet/tcp_input.c
parent993a94e6bcc45e17f3d1868a50ccf1329ff2f00d (diff)
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>.
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r--sys/netinet/tcp_input.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 9802ebcd6ad..50eaaa85430 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.152 2002/08/19 02:17:54 itojun Exp $ */
+/* $NetBSD: tcp_input.c,v 1.153 2002/08/28 02:23:57 thorpej 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.152 2002/08/19 02:17:54 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.153 2002/08/28 02:23:57 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -276,6 +276,17 @@ do { \
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>
@@ -1828,12 +1839,20 @@ after_listen:
* 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;
}
/*