From 87557a38778f4d87c44b476efb896337dd8241e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Ganne?= Date: Wed, 25 Jun 2025 16:39:54 +0200 Subject: [PATCH] dns: fix recursive locking MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/dns/dns.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; -- 2.16.6