From: Benoît Ganne Date: Wed, 25 Jun 2025 14:39:54 +0000 (+0200) Subject: dns: fix recursive locking X-Git-Tag: v26.02-rc0~209 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=87557a38778f4d87c44b476efb896337dd8241e7;p=vpp.git dns: fix recursive locking All callers to delete_random_entry() are already holding the lock to the DNS cache. Thanks to Rain for the report. Type: fix Change-Id: Id051427016f9b7444b812019ccc0f5085fd3e469 Signed-off-by: Benoît Ganne --- diff --git a/src/plugins/dns/dns.c b/src/plugins/dns/dns.c index de01474703b..b73d18a7416 100644 --- a/src/plugins/dns/dns.c +++ b/src/plugins/dns/dns.c @@ -654,7 +654,8 @@ delete_random_entry (dns_main_t * dm) return VNET_API_ERROR_UNSPECIFIED; #endif - dns_cache_lock (dm, 3); + CLIB_SPINLOCK_ASSERT_LOCKED (&dm->cache_lock); + limit = pool_elts (dm->entries); start_index = random_u32 (&dm->random_seed) % limit; @@ -670,12 +671,10 @@ delete_random_entry (dns_main_t * dm) && ((ep->flags & DNS_CACHE_ENTRY_FLAG_STATIC) == 0)) { rv = vnet_dns_delete_entry_by_index_nolock (dm, victim_index); - dns_cache_unlock (dm); return rv; } } } - dns_cache_unlock (dm); clib_warning ("Couldn't find an entry to delete?"); return VNET_API_ERROR_UNSPECIFIED;