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;
}
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;
}
};
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 {
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;
};