From e4e90c6f4d1c9bdca7d3eb2d541617db99ce22dd Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 8 Jan 2024 12:02:25 +0100 Subject: [PATCH] Channel: Replacing refeed status trie by bitmap This fixes a bug with reloading non-IP channels. --- nest/proto.c | 9 +++------ nest/protocol.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nest/proto.c b/nest/proto.c index 70cfad521..72d94a282 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -705,6 +705,7 @@ channel_start_export(struct channel *c) bmap_init(&c->export_map, p, 16); bmap_init(&c->export_reject_map, p, 16); + bmap_init(&c->refeed_map, p, 16); channel_reset_limit(c, &c->out_limit, PLD_OUT); @@ -791,6 +792,7 @@ channel_export_stopped(struct rt_export_request *req) bmap_reset(&c->export_map, 16); bmap_reset(&c->export_reject_map, 16); + bmap_reset(&c->refeed_map, 16); rt_request_export(c->table, req); return; @@ -833,7 +835,7 @@ channel_init_feeding(struct channel *c) /* No direct feeding, running auxiliary refeed. */ c->refeeding = c->refeed_pending; c->refeed_pending = NULL; - c->refeed_trie = f_new_trie(lp_new(c->proto->pool), 0); + bmap_reset(&c->refeed_map, 16); if (no_trie) { @@ -924,11 +926,6 @@ channel_feed_end(struct channel *c) /* Drop the refeed batch */ c->refeeding = NULL; - if (c->refeed_trie) - { - rfree(c->refeed_trie->lp); - c->refeed_trie = NULL; - } /* Run the pending batch */ if (c->refeed_pending) diff --git a/nest/protocol.h b/nest/protocol.h index a63305acb..9b8b837d1 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -583,7 +583,7 @@ struct channel { struct rt_export_request out_req; /* Table export connection */ struct rt_export_request refeed_req; /* Auxiliary refeed request */ - struct f_trie *refeed_trie; /* Auxiliary refeed trie */ + struct bmap refeed_map; /* Auxiliary refeed netindex bitmap */ struct channel_feeding_request *refeeding; /* Refeeding the channel */ struct channel_feeding_request *refeed_pending; /* Scheduled refeeds */ struct channel_import_request *importing; /* Importing the channel */ @@ -718,11 +718,12 @@ void channel_request_feeding_dynamic(struct channel *c, enum channel_feeding_req static inline int channel_net_is_refeeding(struct channel *c, const net_addr *n) { /* Not refeeding if not refeeding at all */ - if (!c->refeeding || !c->refeed_trie) + if (!c->refeeding) return 0; /* Not refeeding if already refed */ - if (trie_match_net(c->refeed_trie, n)) + struct netindex *ni = NET_TO_INDEX(n); + if (bmap_test(&c->refeed_map, ni->index)) return 0; /* Refeeding if matching any request */ @@ -735,8 +736,10 @@ static inline int channel_net_is_refeeding(struct channel *c, const net_addr *n) } static inline void channel_net_mark_refed(struct channel *c, const net_addr *n) { - ASSERT_DIE(c->refeeding && c->refeed_trie); - trie_add_prefix(c->refeed_trie, n, n->pxlen, n->pxlen); + ASSERT_DIE(c->refeeding); + + struct netindex *ni = NET_TO_INDEX(n); + bmap_set(&c->refeed_map, ni->index); } void channel_request_reload(struct channel *c); -- 2.47.2