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 Pullup rev 1.173 (requested by he in ticket...



details:   https://anonhg.NetBSD.org/src/rev/7455748bdec3
branches:  netbsd-1-6
changeset: 530950:7455748bdec3
user:      jmc <jmc%NetBSD.org@localhost>
date:      Wed Oct 22 06:05:47 2003 +0000

description:
Pullup rev 1.173 (requested by he in ticket #1530)


        Introduce a new INVOKING status for callouts, and use it to close
        a race condition in the TCP code.  Fixes PR#20390.

diffstat:

 sys/netinet/tcp_input.c |  17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 092c7d98389e -r 7455748bdec3 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Wed Oct 22 04:40:14 2003 +0000
+++ b/sys/netinet/tcp_input.c   Wed Oct 22 06:05:47 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.141.4.6 2003/06/17 09:48:25 msaitoh Exp $      */
+/*     $NetBSD: tcp_input.c,v 1.141.4.7 2003/10/22 06:05:47 jmc 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.6 2003/06/17 09:48:25 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.141.4.7 2003/10/22 06:05:47 jmc Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -2790,7 +2790,10 @@
                (void) m_free((sc)->sc_ipopts);                         \
        if ((sc)->sc_route4.ro_rt != NULL)                              \
                RTFREE((sc)->sc_route4.ro_rt);                          \
-       pool_put(&syn_cache_pool, (sc));                                \
+       if (callout_invoking(&(sc)->sc_timer))                          \
+               (sc)->sc_flags |= SCF_DEAD;                             \
+       else                                                            \
+               pool_put(&syn_cache_pool, (sc));                        \
 } while (/*CONSTCOND*/0)
 
 struct pool syn_cache_pool;
@@ -2937,6 +2940,14 @@
        int s;
 
        s = splsoftnet();
+       callout_ack(&sc->sc_timer);
+
+       if (__predict_false(sc->sc_flags & SCF_DEAD)) {
+               tcpstat.tcps_sc_delayed_free++;
+               pool_put(&syn_cache_pool, sc);
+               splx(s);
+               return;
+       }
 
        if (__predict_false(sc->sc_rxtshift == TCP_MAXRXTSHIFT)) {
                /* Drop it -- too many retransmissions. */



Home | Main Index | Thread Index | Old Index