From 5ad5540472bfda2c926fdbc41fca77bcd79e01b6 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Thu, 9 Oct 2025 16:08:47 +0200 Subject: [PATCH] Move the interfaces locking domain from attrs to rtable The interface table domain level has been "attrs" due to limitations imposed in the early stages of development when all operations on routing tables, most notably next hop resolution, were done with the table locked. Another possible problem was accessing the BGP listen socket structures which are on the "rtable" level. Yet, with the introduction of the "service" level and stabilization of other structures, the interface table domain level does not need to be at "attrs" anymore, and therefore we may simply move it to "rtable" as it is actually the right place for that. This collision also caused problems with external resource locks which are at the "attrs" level, causing a crash in interface reconfiguration of RIP, Babel and OSPF, when the routines tried to acquire a resource lock with the interface table being locked. Due to a lack of autotests for interface reconfiguration, we missed this problem in BIRD 3. This fixes #305. --- nest/iface.c | 12 ++++++------ nest/neighbor.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nest/iface.c b/nest/iface.c index 4782b3efa..06606d134 100644 --- a/nest/iface.c +++ b/nest/iface.c @@ -35,11 +35,11 @@ #include "conf/conf.h" #include "sysdep/unix/krt.h" -DOMAIN(attrs) iface_domain; +DOMAIN(rtable) iface_domain; -#define IFACE_LOCK LOCK_DOMAIN(attrs, iface_domain) -#define IFACE_UNLOCK UNLOCK_DOMAIN(attrs, iface_domain) -#define IFACE_ASSERT_LOCKED ASSERT_DIE(DOMAIN_IS_LOCKED(attrs, iface_domain)) +#define IFACE_LOCK LOCK_DOMAIN(rtable, iface_domain) +#define IFACE_UNLOCK UNLOCK_DOMAIN(rtable, iface_domain) +#define IFACE_ASSERT_LOCKED ASSERT_DIE(DOMAIN_IS_LOCKED(rtable, iface_domain)) static TLIST_LIST(ifsub) iface_sub_list; static slab *iface_sub_slab; @@ -1030,10 +1030,10 @@ if_choose_router_id(struct iface_patt *mask, u32 old_id) void if_init(void) { - iface_domain = DOMAIN_NEW(attrs); + iface_domain = DOMAIN_NEW(rtable); IFACE_LOCK; - if_pool = rp_new(&root_pool, iface_domain.attrs, "Interfaces"); + if_pool = rp_new(&root_pool, iface_domain.rtable, "Interfaces"); init_list(&global_iface_list); iface_sub_slab = sl_new(if_pool, sizeof(struct iface_notification)); strcpy(default_vrf.name, "default"); diff --git a/nest/neighbor.c b/nest/neighbor.c index 6a8c9e253..fbc211327 100644 --- a/nest/neighbor.c +++ b/nest/neighbor.c @@ -67,11 +67,11 @@ void ifa_unlink(struct ifa *); extern list global_iface_list; -extern DOMAIN(attrs) iface_domain; +extern DOMAIN(rtable) iface_domain; -#define IFACE_LOCK LOCK_DOMAIN(attrs, iface_domain) -#define IFACE_UNLOCK UNLOCK_DOMAIN(attrs, iface_domain) -#define IFACE_ASSERT_LOCKED ASSERT_DIE(DOMAIN_IS_LOCKED(attrs, iface_domain)) +#define IFACE_LOCK LOCK_DOMAIN(rtable, iface_domain) +#define IFACE_UNLOCK UNLOCK_DOMAIN(rtable, iface_domain) +#define IFACE_ASSERT_LOCKED ASSERT_DIE(DOMAIN_IS_LOCKED(rtable, iface_domain)) static inline uint neigh_hash(struct proto *p, ip_addr a, struct iface *i) -- 2.47.3