Module Name: src Committed By: riz Date: Fri Jun 11 23:36:08 UTC 2010
Modified Files: src/sys/netinet [netbsd-5]: tcp_input.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1382): sys/netinet/tcp_input.c: revision 1.304 sys/netinet/tcp_input.c: revision 1.305 syn_cache_put(): defer all pool_put() to the callout. Reschedule the callout if needed so frees are not delayed too much. syn_cache_timer(): we can't call syn_cache_put() here any more, so move code deleted from syn_cache_put() here. Avoid KASSERT() in kern_timeout.c because pool_put() is called from ipintr context, as reported in http://mail-index.netbsd.org/tech-kern/2010/03/19/msg007762.html Thanks to Andrew Doran and Mindaugas Rasiukevicius for help and review. Make sure SYN_CACHE_TIMER_ARM() has been run before calling syn_cache_put() as it will reschedule the timer. Fixes PR kern/43318. To generate a diff of this commit: cvs rdiff -u -r1.291.4.4 -r1.291.4.5 src/sys/netinet/tcp_input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/tcp_input.c diff -u src/sys/netinet/tcp_input.c:1.291.4.4 src/sys/netinet/tcp_input.c:1.291.4.5 --- src/sys/netinet/tcp_input.c:1.291.4.4 Thu May 20 05:42:06 2010 +++ src/sys/netinet/tcp_input.c Fri Jun 11 23:36:07 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.291.4.4 2010/05/20 05:42:06 snj Exp $ */ +/* $NetBSD: tcp_input.c,v 1.291.4.5 2010/06/11 23:36:07 riz Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -145,7 +145,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.291.4.4 2010/05/20 05:42:06 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.291.4.5 2010/06/11 23:36:07 riz Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -3343,12 +3343,9 @@ if (sc->sc_ipopts) (void) m_free(sc->sc_ipopts); rtcache_free(&sc->sc_route); - if (callout_invoking(&sc->sc_timer)) - sc->sc_flags |= SCF_DEAD; - else { - callout_destroy(&sc->sc_timer); - pool_put(&syn_cache_pool, sc); - } + sc->sc_flags |= SCF_DEAD; + if (!callout_invoking(&sc->sc_timer)) + callout_schedule(&(sc)->sc_timer, 1); } void @@ -3509,7 +3506,11 @@ dropit: TCP_STATINC(TCP_STAT_SC_TIMED_OUT); syn_cache_rm(sc); - syn_cache_put(sc); /* calls pool_put but see spl above */ + if (sc->sc_ipopts) + (void) m_free(sc->sc_ipopts); + rtcache_free(&sc->sc_route); + callout_destroy(&sc->sc_timer); + pool_put(&syn_cache_pool, sc); KERNEL_UNLOCK_ONE(NULL); mutex_exit(softnet_lock); } @@ -4182,6 +4183,11 @@ syn_cache_insert(sc, tp); } else { s = splsoftnet(); + /* + * syn_cache_put() will try to schedule the timer, so + * we need to initialize it + */ + SYN_CACHE_TIMER_ARM(sc); syn_cache_put(sc); splx(s); TCP_STATINC(TCP_STAT_SC_DROPPED);