diff options
author | Maria Matejka <mq@ucw.cz> | 2022-09-14 09:59:45 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-09-14 09:59:45 +0200 |
commit | 1518970c128e6ab68884a7f49e09e2dc2a5d9fe3 (patch) | |
tree | 37abff70b2edc5fcc34b6f93f75abcbd7bfa335f /proto | |
parent | 878eeec12bf020c9e7460040d225a929bbbd2bd2 (diff) |
Revert "Routing tables now have their own loops."
This reverts commit 878eeec12bf020c9e7460040d225a929bbbd2bd2.
These changes have been done in a different way in the other branch of
the future merge.
Diffstat (limited to 'proto')
-rw-r--r-- | proto/bgp/attrs.c | 2 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 12 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 2 | ||||
-rw-r--r-- | proto/mrt/mrt.c | 59 | ||||
-rw-r--r-- | proto/mrt/mrt.h | 6 | ||||
-rw-r--r-- | proto/perf/perf.c | 4 | ||||
-rw-r--r-- | proto/radv/radv.c | 5 | ||||
-rw-r--r-- | proto/static/static.c | 12 |
8 files changed, 27 insertions, 75 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 1080db77..9b9013f9 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -2140,7 +2140,7 @@ use_deterministic_med(struct rte_storage *r) } int -bgp_rte_recalculate(rtable_private *table, net *net, rte *new, rte *old, rte *old_best) +bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best) { rte *key = new ? new : old; u32 lpref = key->attrs->pref; diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index aac1f45c..dc845550 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -1800,12 +1800,10 @@ bgp_channel_start(struct channel *C) ip_addr src = p->local_ip; if (c->igp_table_ip4) - RT_LOCKED(c->igp_table_ip4, t) - rt_lock_table(t); + rt_lock_table(c->igp_table_ip4); if (c->igp_table_ip6) - RT_LOCKED(c->igp_table_ip6, t) - rt_lock_table(t); + rt_lock_table(c->igp_table_ip6); c->pool = p->p.pool; // XXXX bgp_init_bucket_table(c); @@ -1886,12 +1884,10 @@ bgp_channel_cleanup(struct channel *C) struct bgp_channel *c = (void *) C; if (c->igp_table_ip4) - RT_LOCKED(c->igp_table_ip4, t) - rt_unlock_table(t); + rt_unlock_table(c->igp_table_ip4); if (c->igp_table_ip6) - RT_LOCKED(c->igp_table_ip6, t) - rt_unlock_table(t); + rt_unlock_table(c->igp_table_ip6); c->index = 0; diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index 60f93bce..7cb4df1f 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -586,7 +586,7 @@ void bgp_free_prefix(struct bgp_channel *c, struct bgp_prefix *bp); int bgp_rte_better(struct rte *, struct rte *); int bgp_rte_mergable(rte *pri, rte *sec); -int bgp_rte_recalculate(rtable_private *table, net *net, rte *new, rte *old, rte *old_best); +int bgp_rte_recalculate(rtable *table, net *net, rte *new, rte *old, rte *old_best); void bgp_rte_modify_stale(struct rt_export_request *, const net_addr *, struct rt_pending_export *, rte **, uint); u32 bgp_rte_igp_metric(struct rte *); void bgp_rt_notify(struct proto *P, struct channel *C, const net_addr *n, rte *new, const rte *old); diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c index b40592d2..9d78438d 100644 --- a/proto/mrt/mrt.c +++ b/proto/mrt/mrt.c @@ -228,7 +228,7 @@ mrt_next_table_(rtable *tab, rtable *tab_ptr, const char *pattern) NODE_VALID(tn); tn = tn->next) { - tab = SKIP_BACK(rtable, n, tn); + tab = SKIP_BACK(struct rtable, n, tn); if (patmatch(pattern, tab->name) && ((tab->addr_type == NET_IP4) || (tab->addr_type == NET_IP6))) return tab; @@ -243,21 +243,13 @@ mrt_next_table(struct mrt_table_dump_state *s) rtable *tab = mrt_next_table_(s->table, s->table_ptr, s->table_expr); if (s->table) - { - RT_LOCK(s->table); - rt_unlock_table(RT_PRIV(s->table)); - RT_UNLOCK(s->table); - } + rt_unlock_table(s->table); s->table = tab; s->ipv4 = tab ? (tab->addr_type == NET_IP4) : 0; if (s->table) - { - RT_LOCK(s->table); - rt_lock_table(RT_PRIV(s->table)); - RT_UNLOCK(s->table); - } + rt_lock_table(s->table); return s->table; } @@ -581,23 +573,14 @@ mrt_table_dump_init(pool *pp) static void mrt_table_dump_free(struct mrt_table_dump_state *s) { - if (s->table) - { - RT_LOCK(s->table); - - if (s->table_open) - FIB_ITERATE_UNLINK(&s->fit, &RT_PRIV(s->table)->fib); + if (s->table_open) + FIB_ITERATE_UNLINK(&s->fit, &s->table->fib); - rt_unlock_table(RT_PRIV(s->table)); - RT_UNLOCK(s->table); - } + if (s->table) + rt_unlock_table(s->table); if (s->table_ptr) - { - RT_LOCK(s->table_ptr); - rt_unlock_table(RT_PRIV(s->table_ptr)); - RT_UNLOCK(s->table_ptr); - } + rt_unlock_table(s->table_ptr); config_del_obstacle(s->config); @@ -613,14 +596,8 @@ mrt_table_dump_step(struct mrt_table_dump_state *s) s->max = 2048; s->bws = &bws; - rtable_private *tab; - if (s->table_open) - { - RT_LOCK(s->table); - tab = RT_PRIV(s->table); goto step; - } while (mrt_next_table(s)) { @@ -629,18 +606,15 @@ mrt_table_dump_step(struct mrt_table_dump_state *s) mrt_peer_table_dump(s); - RT_LOCK(s->table); - tab = RT_PRIV(s->table); - FIB_ITERATE_INIT(&s->fit, &tab->fib); + FIB_ITERATE_INIT(&s->fit, &s->table->fib); s->table_open = 1; step: - FIB_ITERATE_START(&tab->fib, &s->fit, net, n) + FIB_ITERATE_START(&s->table->fib, &s->fit, net, n) { if (s->max < 0) { FIB_ITERATE_PUT(&s->fit); - RT_UNLOCK(s->table); return 0; } @@ -660,7 +634,6 @@ mrt_table_dump_step(struct mrt_table_dump_state *s) mrt_peer_table_flush(s); } - RT_UNLOCK(s->table); return 1; } @@ -688,11 +661,7 @@ mrt_timer(timer *t) s->always_add_path = cf->always_add_path; if (s->table_ptr) - { - RT_LOCK(s->table_ptr); - rt_lock_table(RT_PRIV(s->table_ptr)); - RT_UNLOCK(s->table_ptr); - } + rt_lock_table(s->table_ptr); p->table_dump = s; ev_schedule(p->event); @@ -765,11 +734,7 @@ mrt_dump_cmd(struct mrt_dump_data *d) s->filename = d->filename; if (s->table_ptr) - { - RT_LOCK(s->table_ptr); - rt_lock_table(RT_PRIV(s->table_ptr)); - RT_UNLOCK(s->table_ptr); - } + rt_lock_table(s->table_ptr); this_cli->cont = mrt_dump_cont; this_cli->cleanup = mrt_dump_cleanup; diff --git a/proto/mrt/mrt.h b/proto/mrt/mrt.h index 04865089..4ff94c12 100644 --- a/proto/mrt/mrt.h +++ b/proto/mrt/mrt.h @@ -40,7 +40,7 @@ struct mrt_proto { struct mrt_dump_data { const char *table_expr; - rtable *table_ptr; + struct rtable *table_ptr; const struct filter *filter; const char *filename; }; @@ -60,7 +60,7 @@ struct mrt_table_dump_state { /* Configuration information */ const char *table_expr; /* Wildcard for table name (or NULL) */ - rtable *table_ptr; /* Explicit table (or NULL) */ + struct rtable *table_ptr; /* Explicit table (or NULL) */ const struct filter *filter; /* Optional filter */ const char *filename; /* Filename pattern */ int always_add_path; /* Always use *_ADDPATH message subtypes */ @@ -73,7 +73,7 @@ struct mrt_table_dump_state { HASH(struct mrt_peer_entry) peer_hash; /* Hash for peers to find the index */ - rtable *table; /* Processed table, NULL initially */ + struct rtable *table; /* Processed table, NULL initially */ struct fib_iterator fit; /* Iterator in processed table */ int table_open; /* Whether iterator is linked */ diff --git a/proto/perf/perf.c b/proto/perf/perf.c index aa688d88..8b2cb69f 100644 --- a/proto/perf/perf.c +++ b/proto/perf/perf.c @@ -198,9 +198,7 @@ perf_loop(void *data) p->exp++; } - RT_LOCK(P->main_channel->table); - rt_schedule_prune(RT_PRIV(P->main_channel->table)); - RT_UNLOCK(P->main_channel->table); + rt_schedule_prune(P->main_channel->table); ev_schedule(p->loop); } diff --git a/proto/radv/radv.c b/proto/radv/radv.c index d572c1b7..fa228c69 100644 --- a/proto/radv/radv.c +++ b/proto/radv/radv.c @@ -555,10 +555,7 @@ radv_check_active(struct radv_proto *p) return 1; struct channel *c = p->p.main_channel; - RT_LOCK(c->table); - int active = rt_examine(RT_PRIV(c->table), &cf->trigger, c, c->out_filter); - RT_UNLOCK(c->table); - return active; + return rt_examine(c->table, &cf->trigger, c, c->out_filter); } static void diff --git a/proto/static/static.c b/proto/static/static.c index bd7f3f5b..45791e8e 100644 --- a/proto/static/static.c +++ b/proto/static/static.c @@ -491,12 +491,10 @@ static_start(struct proto *P) static_lp = lp_new(&root_pool, LP_GOOD_SIZE(1024)); if (p->igp_table_ip4) - RT_LOCKED(p->igp_table_ip4, t) - rt_lock_table(t); + rt_lock_table(p->igp_table_ip4); if (p->igp_table_ip6) - RT_LOCKED(p->igp_table_ip6, t) - rt_lock_table(t); + rt_lock_table(p->igp_table_ip6); p->event = ev_new_init(p->p.pool, static_announce_marked, p); @@ -523,12 +521,10 @@ static_shutdown(struct proto *P) static_reset_rte(p, r); if (p->igp_table_ip4) - RT_LOCKED(p->igp_table_ip4, t) - rt_unlock_table(t); + rt_unlock_table(p->igp_table_ip4); if (p->igp_table_ip6) - RT_LOCKED(p->igp_table_ip6, t) - rt_unlock_table(t); + rt_unlock_table(p->igp_table_ip6); return PS_DOWN; } |