From ec09d2df2ae565c8cb2aeb10a366dd1efa9e0753 Mon Sep 17 00:00:00 2001 From: thorpej Date: Wed, 28 Aug 2002 02:23:57 +0000 Subject: 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 . --- sys/netinet/tcp_input.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'sys') 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 -__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 @@ -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; } /* -- cgit