From eae05c13462d5c54d84a361ff6224fcaf22a0da1 Mon Sep 17 00:00:00 2001 From: Katerina Kubecova Date: Tue, 24 Oct 2023 14:39:40 +0200 Subject: [PATCH] fixup! fixup! partial reload for RPKI - not working --- proto/bgp/bgp.c | 1 - proto/ospf/ospf.c | 9 +++++++-- proto/ospf/ospf.h | 3 +-- proto/ospf/rt.c | 4 ++-- proto/rip/rip.c | 13 +++++++++---- proto/rip/rip.h | 3 +-- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index e9ca4038..9bd117d3 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -1565,7 +1565,6 @@ bgp_reload_routes(struct channel *C, struct channel_import_request *cir) { struct bgp_proto *p = (void *) C->proto; struct bgp_channel *c = (void *) C; - log("in bgp"); /* Ignore non-BGP channels */ if (C->class != &channel_bgp) diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 7ec7dcfb..3b1b8314 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -438,10 +438,15 @@ ospf_reload_routes(struct channel *C, struct channel_import_request *cir) struct ospf_proto *p = (struct ospf_proto *) C->proto; if (cir) { - pthread_mutex_lock(&p->mutex); + if (p->lock == NULL) + { + p->lock = DOMAIN_NEW(attrs); + DOMAIN_SETUP(attrs, p->lock, "Partial request lock ospf", NULL); + } + DG_LOCK(p->lock); cir->next = p->cir; p->cir = cir; - pthread_mutex_unlock(&p->mutex); + DG_UNLOCK(p->lock); } if (p->calcrt == 2) return 1; diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index c37c090b..4fffac12 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -11,7 +11,6 @@ #ifndef _BIRD_OSPF_H_ #define _BIRD_OSPF_H_ -#include #include "nest/bird.h" #include "lib/checksum.h" @@ -221,7 +220,7 @@ struct ospf_proto int calcrt; /* Routing table calculation scheduled? 0=no, 1=normal, 2=forced reload */ struct channel_import_request *cir; /* Struct with trie for partial reload */ - pthread_mutex_t mutex; /* Mutex for partial reload */ + DOMAIN(attrs) lock; /*nebo struct domain_generic *? *//* Lock for partial reload */ list iface_list; /* List of OSPF interfaces (struct ospf_iface) */ list area_list; /* List of OSPF areas (struct ospf_area) */ int areano; /* Number of area I belong to */ diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index df71f88d..8eec6e97 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -2019,10 +2019,10 @@ rt_sync(struct ospf_proto *p) OSPF_TRACE(D_EVENTS, "Starting routing table synchronization"); - pthread_mutex_lock(&p->mutex); + DG_LOCK(attr, p->lock); struct channel_import_request *cir = p->cir; p->cir = NULL; - pthread_mutex_unlock(&p->mutex); + DG_UNLOCK(attr, p->lock); DBG("Now syncing my rt table with nest's\n"); FIB_ITERATE_INIT(&fit, fib); diff --git a/proto/rip/rip.c b/proto/rip/rip.c index ffcf3428..66f43f37 100644 --- a/proto/rip/rip.c +++ b/proto/rip/rip.c @@ -968,10 +968,10 @@ rip_timer(timer *t) FIB_ITERATE_INIT(&fit, &p->rtable); - pthread_mutex_lock(&p->mutex); + DG_LOCK(attrs, p->lock); struct channel_import_request *cir = p->cir; p->cir = NULL; - pthread_mutex_unlock(&p->mutex); + DG_UNLOCK(attrs, p->lock); loop: FIB_ITERATE_START(&p->rtable, &fit, struct rip_entry, en) @@ -1163,10 +1163,15 @@ rip_reload_routes(struct channel *C, struct channel_import_request *cir) struct rip_proto *p = (struct rip_proto *) C->proto; if (cir) { - pthread_mutex_lock(&p->mutex); + if (p->lock==NULL) + { + p->lock = DOMAIN_NEW(attrs); + DOMAIN_SETUP(attrs, p->lock, "Partial request lock rip", NULL); + } + DG_LOCK(p->lock); cir->next = p->cir; p->cir = cir; - pthread_mutex_lock(&p->mutex); + DG_UNLOCK(p->lock); } if (p->rt_reload) return 1; diff --git a/proto/rip/rip.h b/proto/rip/rip.h index 54136559..cab5deb8 100644 --- a/proto/rip/rip.h +++ b/proto/rip/rip.h @@ -12,7 +12,6 @@ #ifndef _BIRD_RIP_H_ #define _BIRD_RIP_H_ -#include #include "nest/bird.h" #include "nest/cli.h" #include "nest/iface.h" @@ -105,7 +104,7 @@ struct rip_proto struct tbf log_pkt_tbf; /* TBF for packet messages */ struct tbf log_rte_tbf; /* TBF for RTE messages */ struct channel_import_request *cir; /* Trie for partial reload */ - pthread_mutex_t mutex; /* Mutex for partial reload */ + DOMAIN(attrs) lock; /* Lock for partial reload */ }; struct rip_iface