From 45024be06fc14a0461e4ece72566f05166be8b17 Mon Sep 17 00:00:00 2001 From: Andre Oppermann Date: Thu, 7 Jun 2007 21:41:50 +0000 Subject: [PATCH] In tcp_hc_insert() we may have the case where we have hit the global cache size limit but this bucket row is empty. Normally we want to recycle the oldest entry in the bucket row. If there isn't any the TAILQ_REMOVE leads to a panic by trying to remove a non-existing element. Fix this by just returning NULL and failing the insert. This is not a problem as the TCP hostache is only advisory. Submitted by: jhb --- sys/netinet/tcp_hostcache.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index 77072379817..e3350009abb 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -351,7 +351,13 @@ tcp_hc_insert(struct in_conninfo *inc) * efficient. Instead just reuse the least used element. * We may drop something that is still "in-use" but we can be * "lossy". + * Just give up if this bucket row is empty and we don't have + * anything to replace. */ + if (hc_entry == NULL) { + THC_UNLOCK(&hc_head->hch_mtx); + return NULL; + } TAILQ_REMOVE(&hc_head->hch_bucket, hc_entry, rmx_q); tcp_hostcache.hashbase[hash].hch_length--; tcp_hostcache.cache_count--;