summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2010-02-20 21:45:04 +0000
committerbz <bz@FreeBSD.org>2010-02-20 21:45:04 +0000
commitb8a1e8dec8db5b39c15a1c70fd6f0164adb126e6 (patch)
tree74bbd9c7dc35911ff55058c173993d42e5e7bfdf /sys/netinet
parent77e8f746fc7836ec49e92916ef771aefe1abc569 (diff)
downloadFreeBSD-src-b8a1e8dec8db5b39c15a1c70fd6f0164adb126e6.zip
FreeBSD-src-b8a1e8dec8db5b39c15a1c70fd6f0164adb126e6.tar.gz
Upon virtual network stack teardown properly release the TCP syncache
resources. Sponsored by: ISPsystem Reviewed by: rwatson MFC After: 5 days
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/tcp_syncache.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 16c4f67..4d9d487 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -278,11 +278,33 @@ syncache_init(void)
void
syncache_destroy(void)
{
+ struct syncache_head *sch;
+ struct syncache *sc, *nsc;
+ int i;
+
+ /* Cleanup hash buckets: stop timers, free entries, destroy locks. */
+ for (i = 0; i < V_tcp_syncache.hashsize; i++) {
+
+ sch = &V_tcp_syncache.hashbase[i];
+ callout_drain(&sch->sch_timer);
+
+ SCH_LOCK(sch);
+ TAILQ_FOREACH_SAFE(sc, &sch->sch_bucket, sc_hash, nsc)
+ syncache_drop(sc, sch);
+ SCH_UNLOCK(sch);
+ KASSERT(TAILQ_EMPTY(&sch->sch_bucket),
+ ("%s: sch->sch_bucket not empty", __func__));
+ KASSERT(sch->sch_length == 0, ("%s: sch->sch_length %d not 0",
+ __func__, sch->sch_length));
+ mtx_destroy(&sch->sch_mtx);
+ }
- /* XXX walk the cache, free remaining objects, stop timers */
+ KASSERT(V_tcp_syncache.cache_count == 0, ("%s: cache_count %d not 0",
+ __func__, V_tcp_syncache.cache_count));
+ /* Free the allocated global resources. */
uma_zdestroy(V_tcp_syncache.zone);
- FREE(V_tcp_syncache.hashbase, M_SYNCACHE);
+ free(V_tcp_syncache.hashbase, M_SYNCACHE);
}
#endif
OpenPOWER on IntegriCloud