From 39581c7d7f78947b72097e8cebea321448e89046 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Tue, 5 Dec 2023 14:32:06 +0100 Subject: [PATCH] Create default empty route for aggregation --- proto/aggregator/aggregator.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index ddb343f3..6c67f18c 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -1284,6 +1284,30 @@ aggregator_start(struct proto *P) .data = p, }; + /* Create route attributes with zero nexthop */ + struct rta rta = { 0 }; + + /* Allocate bucket for root node */ + struct aggregator_bucket *new_bucket = sl_allocz(p->bucket_slab); + u64 haux = 0; + mem_hash_init(&haux); + new_bucket->hash = mem_hash_value(&haux); + + struct aggregator_route *arte = sl_alloc(p->route_slab); + + *arte = (struct aggregator_route) { + .bucket = new_bucket, + .rte = { .attrs = rta_lookup(&rta) }, + }; + + arte->rte.next = new_bucket->rte; + new_bucket->rte = &arte->rte; + new_bucket->count++; + HASH_INSERT2(p->routes, AGGR_RTE, p->p.pool, arte); + + /* Assign default route to the root */ + p->root->bucket = new_bucket; + return PS_UP; }