From cb41a8a1a91d6d1bf6d4abac8ff065a67b73ba18 Mon Sep 17 00:00:00 2001 From: Igor Putovny Date: Wed, 5 Feb 2025 18:26:03 +0100 Subject: [PATCH] Small changes --- proto/aggregator/aggregator.c | 16 ++++++++++++---- proto/aggregator/aggregator.h | 13 +++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 247b9a8a7..937ed7f05 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -444,13 +444,17 @@ trie_remove_prefix_ip4(struct trie_node * const root, const struct net_addr_ip4 memset(node->potential_buckets, 0, sizeof(node->potential_buckets)); /* - * If prefix node is a leaf, delete it along with the branch - * it resides on, until a non-leaf or prefix node is reached. + * If prefix node is a leaf, remove it along with the branch + * it resides on, until non-leaf or prefix node is reached. */ for (struct trie_node *parent = node->parent; parent; node = parent, parent = node->parent) { - if (is_leaf(node) && FILLER == node->px_origin) + if (FILLER == node->px_origin && is_leaf(node)) + { remove_node(node); + assert(node != NULL); + assert(parent != NULL); + } else break; } @@ -483,8 +487,12 @@ trie_remove_prefix_ip6(struct trie_node * const root, const struct net_addr_ip6 for (struct trie_node *parent = node->parent; parent; node = parent, parent = node->parent) { - if (is_leaf(node) && FILLER == node->px_origin) + if (FILLER == node->px_origin && is_leaf(node)) + { remove_node(node); + assert(node != NULL); + assert(parent != NULL); + } else break; } diff --git a/proto/aggregator/aggregator.h b/proto/aggregator/aggregator.h index a42d4e998..114432ef8 100644 --- a/proto/aggregator/aggregator.h +++ b/proto/aggregator/aggregator.h @@ -113,14 +113,15 @@ struct aggr_item_node { }; enum fib_status { - IN_FIB = 1, - NON_FIB = 2, + UNASSIGNED_STATUS, + IN_FIB, + NON_FIB, }; enum prefix_origin { - FILLER = 0, - ORIGINAL = 1, - AGGREGATED = 2, + FILLER, + ORIGINAL, + AGGREGATED, }; struct trie_node { @@ -129,9 +130,9 @@ struct trie_node { struct trie_node *ancestor; struct aggregator_bucket *original_bucket; struct aggregator_bucket *selected_bucket; - u32 potential_buckets[POTENTIAL_BUCKETS_BITMAP_SIZE]; enum fib_status status; enum prefix_origin px_origin; + u32 potential_buckets[POTENTIAL_BUCKETS_BITMAP_SIZE]; int potential_buckets_count; int depth; }; -- 2.47.2