From 6eadd11a8ac5ae5c44a30058e21d1776d7f22fa0 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Mon, 10 Feb 2025 17:22:26 +0100 Subject: [PATCH] Create default route in the thid pass --- proto/aggregator/aggregator.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index d2bad701f..1a0097d65 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -877,14 +877,6 @@ third_pass(struct aggregator_proto *p, struct trie_node *node) assert(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT); assert(node->potential_buckets_count > 0); - /* Assign bucket with the lowest ID to the node */ - node->selected_bucket = choose_lowest_id_bucket(p, node); - node->status = IN_FIB; - assert(node->selected_bucket != NULL); - - /* The closest ancestor of the root node with a non-null bucket is the root itself */ - node->ancestor = node; - struct net_addr_ip4 addr = { 0 }; net_fill_ip4((net_addr *)&addr, IP4_NONE, 0); @@ -894,6 +886,24 @@ third_pass(struct aggregator_proto *p, struct trie_node *node) */ find_subtree_prefix(node, &addr); + /* Select bucket with the lowest ID */ + node->selected_bucket = choose_lowest_id_bucket(p, node); + assert(node->selected_bucket != NULL); + + /* + * Export new route if node status is changing from NON_FIB + * or UNASSIGNED to IN_FIB. + */ + if (IN_FIB != node->status) + { + create_route_ip4(p, &addr, node->selected_bucket); + exported++; + } + + /* The closest ancestor of the IN_FIB node with a non-null bucket is the node itself */ + node->ancestor = node; + node->status = IN_FIB; + if (node->child[0]) { ip4_clrbit(&addr.prefix, node->depth); -- 2.47.2