]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Add prefix to function names, rename
authorIgor Putovny <igor.putovny@nic.cz>
Mon, 24 Feb 2025 11:31:56 +0000 (12:31 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Mon, 24 Feb 2025 11:31:56 +0000 (12:31 +0100)
proto/aggregator/aggregator.c
proto/aggregator/aggregator.h
proto/aggregator/trie.c

index 1070fc2dfc28af39164d74099bc728dd851f78c8..77ee8c69ef0f9efb81607e6a17c4f891767e4e57 100644 (file)
@@ -103,8 +103,8 @@ agregator_insert_bucket(struct aggregator_proto *p, struct aggregator_bucket *bu
 static void
 aggregator_withdraw_rte(struct aggregator_proto *p)
 {
-  if ((p->addr_type == NET_IP4 && p->rte_withdrawal_count > IP4_WITHDRAWAL_LIMIT) ||
-      (p->addr_type == NET_IP6 && p->rte_withdrawal_count > IP6_WITHDRAWAL_LIMIT))
+  if ((p->addr_type == NET_IP4 && p->rte_withdrawal_count > IP4_WITHDRAWAL_MAX_EXPECTED_LIMIT) ||
+      (p->addr_type == NET_IP6 && p->rte_withdrawal_count > IP6_WITHDRAWAL_MAX_EXPECTED_LIMIT))
     log(L_WARN "This number of updates was not expected."
                "They will be processed, but please, contact the developers.");
 
@@ -674,7 +674,8 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new
     ASSERT_DIE(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, aggregator_route_hash(&arte->rte));
+      log("Inserting rte: %p, arte: %p, net: %p, src: %p, hash: %x",
+          &arte->rte, arte, arte->rte.net, arte->rte.src, aggregator_route_hash(&arte->rte));
   }
 
   /* Remove the old route from its bucket */
@@ -820,9 +821,6 @@ aggregator_init_trie(struct aggregator_proto *p)
       log("Creating net %p for default route %N", default_net, default_net->n.addr);
   }
 
-  /* Create root node */
-  p->root = create_new_node(p->trie_pool);
-
   /* Create route attributes with zero nexthop */
   struct rta rta = { 0 };
 
@@ -855,6 +853,9 @@ aggregator_init_trie(struct aggregator_proto *p)
   HASH_INSERT2(p->routes, AGGR_RTE, p->p.pool, arte);
   HASH_INSERT2(p->buckets, AGGR_BUCK, p->p.pool, new_bucket);
 
+  /* Create root node */
+  p->root = aggregator_create_new_node(p->trie_pool);
+
   /*
    * Root node is initialized with NON_FIB status.
    * Default route will be exported during first aggregation run.
index 10c80c2f04e48cb8669bc925cc9d32b190f5948e..f48296fb7b6c98532a0946618ac275181cfafced 100644 (file)
@@ -21,8 +21,8 @@
 #define POTENTIAL_BUCKETS_BITMAP_SIZE 8
 #define MAX_POTENTIAL_BUCKETS_COUNT   ((int)(sizeof(u32) * 8 * POTENTIAL_BUCKETS_BITMAP_SIZE))
 
-#define IP4_WITHDRAWAL_LIMIT 100
-#define IP6_WITHDRAWAL_LIMIT 200
+#define IP4_WITHDRAWAL_MAX_EXPECTED_LIMIT 100
+#define IP6_WITHDRAWAL_MAX_EXPECTED_LIMIT 200
 
 enum aggregation_mode {
   NET_AGGR, PREFIX_AGGR,
@@ -152,6 +152,6 @@ void aggregator_update_prefix(struct aggregator_proto *p, struct aggregator_rout
 void aggregator_withdraw_prefix(struct aggregator_proto *p, struct aggregator_route *old);
 void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net);
 
-struct trie_node *create_new_node(linpool *trie_pool);
+struct trie_node *aggregator_create_new_node(linpool *trie_pool);
 
 #endif
index 774a33d25db235f857d9dca3e1ab88acfd205403..bc31bf89c6b4f08b4fb982818ae80e8aba4a6333 100644 (file)
@@ -97,14 +97,14 @@ static const u32 ipa_shift[] = {
  * Allocate new node in protocol linpool
  */
 struct trie_node *
-create_new_node(linpool *trie_pool)
+aggregator_create_new_node(linpool *trie_pool)
 {
   struct trie_node *node = lp_allocz(trie_pool, sizeof(*node));
   return node;
 }
 
 static inline int
-is_leaf(const struct trie_node *node)
+aggregator_is_leaf(const struct trie_node *node)
 {
   ASSERT_DIE(node != NULL);
   return !node->child[0] && !node->child[1];
@@ -114,7 +114,7 @@ is_leaf(const struct trie_node *node)
  * Unlink node from the trie by setting appropriate child of parent node to NULL
  */
 static inline void
-remove_node(struct trie_node *node)
+aggregator_remove_node(struct trie_node *node)
 {
   ASSERT_DIE(node != NULL);
   ASSERT_DIE(node->child[0] == NULL && node->child[1] == NULL);
@@ -138,7 +138,7 @@ remove_node(struct trie_node *node)
  * Insert @bucket to the set of potential buckets in @node
  */
 static inline void
-node_add_potential_bucket(struct trie_node *node, const struct aggregator_bucket *bucket)
+aggregator_node_add_potential_bucket(struct trie_node *node, const struct aggregator_bucket *bucket)
 {
   ASSERT_DIE(node->potential_buckets_count < MAX_POTENTIAL_BUCKETS_COUNT);
 
@@ -171,7 +171,7 @@ node_add_potential_bucket(struct trie_node *node, const struct aggregator_bucket
  * Check if @bucket is one of potential buckets of @node
  */
 static inline int
-node_is_bucket_potential(const struct trie_node *node, const struct aggregator_bucket *bucket)
+aggregator_is_bucket_potential(const struct trie_node *node, const struct aggregator_bucket *bucket)
 {
   ASSERT_DIE(node != NULL);
   ASSERT_DIE(bucket != NULL);
@@ -186,7 +186,7 @@ node_is_bucket_potential(const struct trie_node *node, const struct aggregator_b
  * lies at position equal to bucket ID to enable fast lookup.
  */
 static inline struct aggregator_bucket *
-get_bucket_from_id(const struct aggregator_proto *p, u32 id)
+aggregator_get_bucket_from_id(const struct aggregator_proto *p, u32 id)
 {
   ASSERT_DIE(id < p->bucket_list_size);
   ASSERT_DIE(p->bucket_list[id] != NULL);
@@ -198,7 +198,7 @@ get_bucket_from_id(const struct aggregator_proto *p, u32 id)
  * Select bucket with the lowest ID from the set of node's potential buckets
  */
 static inline struct aggregator_bucket *
-select_lowest_id_bucket(const struct aggregator_proto *p, const struct trie_node *node)
+aggregator_select_lowest_id_bucket(const struct aggregator_proto *p, const struct trie_node *node)
 {
   ASSERT_DIE(p != NULL);
   ASSERT_DIE(node != NULL);
@@ -207,7 +207,7 @@ select_lowest_id_bucket(const struct aggregator_proto *p, const struct trie_node
   {
     if (BIT32R_TEST(node->potential_buckets, i))
     {
-      struct aggregator_bucket *bucket = get_bucket_from_id(p, i);
+      struct aggregator_bucket *bucket = aggregator_get_bucket_from_id(p, i);
       ASSERT_DIE(bucket != NULL);
       ASSERT_DIE(bucket->id == i);
       return bucket;
@@ -443,7 +443,7 @@ aggregator_insert_prefix(struct aggregator_proto *p, ip_addr prefix, u32 pxlen,
 
     if (!node->child[bit])
     {
-      struct trie_node *new = create_new_node(p->trie_pool);
+      struct trie_node *new = aggregator_create_new_node(p->trie_pool);
 
       *new = (struct trie_node) {
         .parent = node,
@@ -502,9 +502,9 @@ aggregator_remove_prefix(struct aggregator_proto *p, ip_addr prefix, u32 pxlen)
    */
   for (struct trie_node *parent = node->parent; parent; node = parent, parent = node->parent)
   {
-    if (node->px_origin == FILLER && is_leaf(node))
+    if (node->px_origin == FILLER && aggregator_is_leaf(node))
     {
-      remove_node(node);
+      aggregator_remove_node(node);
       ASSERT_DIE(node != NULL);
       ASSERT_DIE(parent != NULL);
     }
@@ -576,12 +576,12 @@ aggregator_second_pass(struct trie_node *node)
   ASSERT_DIE(node != NULL);
   ASSERT_DIE(node->potential_buckets_count <= MAX_POTENTIAL_BUCKETS_COUNT);
 
-  if (is_leaf(node))
+  if (aggregator_is_leaf(node))
   {
     ASSERT_DIE(node->original_bucket != NULL);
     ASSERT_DIE(node->status == NON_FIB);
     ASSERT_DIE(node->potential_buckets_count == 0);
-    node_add_potential_bucket(node, node->original_bucket);
+    aggregator_node_add_potential_bucket(node, node->original_bucket);
     return;
   }
 
@@ -614,7 +614,7 @@ aggregator_second_pass(struct trie_node *node)
    * Imaginary node is used only for computing sets of potential buckets
    * of its parent node. It inherits parent's potential bucket.
    */
-  node_add_potential_bucket(&imaginary_node, node->original_bucket);
+  aggregator_node_add_potential_bucket(&imaginary_node, node->original_bucket);
 
   /* Nodes with exactly one child */
   if ((left && !right) || (!left && right))
@@ -654,7 +654,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
    * of this node, then this node doesn't need a bucket because it inherits
    * one, and is not needed in FIB.
    */
-  if (node_is_bucket_potential(node, inherited_bucket))
+  if (aggregator_is_bucket_potential(node, inherited_bucket))
   {
     /*
      * Prefix status is changing from IN_FIB to NON_FIB, thus its route
@@ -684,7 +684,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
     ASSERT_DIE(node->potential_buckets_count > 0);
 
     /* Assign bucket with the lowest ID to the node */
-    node->selected_bucket = select_lowest_id_bucket(p, node);
+    node->selected_bucket = aggregator_select_lowest_id_bucket(p, node);
     ASSERT_DIE(node->selected_bucket != NULL);
 
     /*
@@ -725,7 +725,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
       .depth = node->depth + 1,
     };
 
-    node_add_potential_bucket(&imaginary_node, node->original_bucket);
+    aggregator_node_add_potential_bucket(&imaginary_node, node->original_bucket);
 
     /*
      * If the current node (parent of the imaginary node) has a bucket,
@@ -746,9 +746,9 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
      * one of their potential buckets. In this case, we need to add these nodes
      * to the trie.
      */
-    if (!node_is_bucket_potential(&imaginary_node, imaginary_node_inherited_bucket))
+    if (!aggregator_is_bucket_potential(&imaginary_node, imaginary_node_inherited_bucket))
     {
-      struct trie_node *new = create_new_node(p->trie_pool);
+      struct trie_node *new = aggregator_create_new_node(p->trie_pool);
       *new = imaginary_node;
 
       /* Connect new node to the trie */
@@ -775,7 +775,7 @@ aggregator_third_pass_helper(struct aggregator_proto *p, struct trie_node *node,
     ipa_clrbit(prefix, node->depth + ipa_shift[p->addr_type]);
   }
 
-  if (node->status == NON_FIB && is_leaf(node))
+  if (node->status == NON_FIB && aggregator_is_leaf(node))
     ASSERT_DIE(node->selected_bucket == NULL);
 }
 
@@ -799,7 +799,7 @@ aggregator_third_pass(struct aggregator_proto *p, struct trie_node *node)
   aggregator_find_subtree_prefix(node, &prefix, &pxlen, p->addr_type);
 
   /* Select bucket with the lowest ID */
-  node->selected_bucket = select_lowest_id_bucket(p, node);
+  node->selected_bucket = aggregator_select_lowest_id_bucket(p, node);
   ASSERT_DIE(node->selected_bucket != NULL);
 
   /*
@@ -887,11 +887,11 @@ aggregator_deaggregate(struct trie_node * const node)
   ASSERT_DIE(node->potential_buckets_count == 0);
 
   /* As during the first pass, leaves get one potential bucket */
-  if (is_leaf(node))
+  if (aggregator_is_leaf(node))
   {
     ASSERT_DIE(node->px_origin == ORIGINAL);
     ASSERT_DIE(node->potential_buckets_count == 0);
-    node_add_potential_bucket(node, node->original_bucket);
+    aggregator_node_add_potential_bucket(node, node->original_bucket);
   }
 
   if (node->child[0])