summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-11-25 15:32:09 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-11-25 15:32:09 +0000
commitf7a08eb995954e1589ac898355fdd7c49742f0a8 (patch)
treed44ae27476029ee8d3d991f37c34322339a97014 /sys/netinet/tcp_subr.c
parent7c9e4c2086c4479dbec08dd4d1e199a9864ee907 (diff)
fix for race between invocation for timer and network input
1) add a reaper for TCP and SYN cache states (cf. netbsd pr 20390) 2) additional check for TCP_TIMER_ISARMED(TCPT_REXMT) in tcp_timer_persist() with mickey@; ok deraadt@
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 0070c1824e0..5a9945f3fb7 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.84 2004/10/28 19:22:52 mcbride Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.85 2004/11/25 15:32:08 markus Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -495,6 +495,7 @@ tcp_newtcpcb(struct inpcb *inp)
TCP_INIT_DELACK(tp);
for (i = 0; i < TCPT_NTIMERS; i++)
TCP_TIMER_INIT(tp, i);
+ timeout_set(&tp->t_reap_to, tcp_reaper, tp);
#ifdef TCP_SACK
tp->sack_enable = tcp_do_sack;
@@ -593,14 +594,28 @@ tcp_close(struct tcpcb *tp)
#endif
if (tp->t_template)
(void) m_free(tp->t_template);
- pool_put(&tcpcb_pool, tp);
+
+ tp->t_flags |= TF_DEAD;
+ timeout_add(&tp->t_reap_to, 0);
+
inp->inp_ppcb = 0;
soisdisconnected(so);
in_pcbdetach(inp);
- tcpstat.tcps_closed++;
return ((struct tcpcb *)0);
}
+void
+tcp_reaper(void *arg)
+{
+ struct tcpcb *tp = arg;
+ int s;
+
+ s = splsoftnet();
+ pool_put(&tcpcb_pool, tp);
+ splx(s);
+ tcpstat.tcps_closed++;
+}
+
int
tcp_freeq(struct tcpcb *tp)
{