From fa34bd251ef2236780d2972cce0246819a32dea1 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Mon, 2 Dec 2024 13:56:09 +0100 Subject: [PATCH] Process incremental updates in rt_notify() --- proto/aggregator/aggregator.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 3bd247d64..b45ed324b 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -1579,8 +1579,9 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new { struct aggregator_proto *p = SKIP_BACK(struct aggregator_proto, p, P); ASSERT_DIE(src_ch == p->src); + struct aggregator_bucket *new_bucket = NULL, *old_bucket = NULL; - struct aggregator_route *old_route = NULL; + struct aggregator_route *new_route = NULL, *old_route = NULL; /* Ignore all updates if protocol is not up */ if (p->p.proto_state != PS_UP) @@ -1738,6 +1739,10 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new new_bucket->count++; HASH_INSERT2(p->routes, AGGR_RTE, p->p.pool, arte); + /* New route */ + new_route = arte; + assert(new_route != NULL); + if (p->logging) log("Inserting rte: %p, arte: %p, net: %p, src: %p, hash: %x", &arte->rte, arte, arte->rte.net, arte->rte.src, aggr_route_hash(&arte->rte)); } @@ -1767,6 +1772,28 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new if (new_bucket && (new_bucket != old_bucket)) aggregator_bucket_update(p, new_bucket, net); } + else if (PREFIX_AGGR == p->aggr_mode) + { + // old => old_route, new => arte + if (p->root) + { + if ((old && new) || (!old && new)) + { + assert(new_route != NULL); + + if (old && new) + log("rt notify: update"); + else if (!old && new) + log("rt notify: announce"); + + trie_receive_update(p, old_route, new_route); + } + else if (old && !new) + { + log("rt notify: withdraw"); + } + } + } /* Cleanup the old bucket if empty */ if (old_bucket && (!old_bucket->rte || !old_bucket->count)) -- 2.47.2