]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Cleanup
authorIgor Putovny <igor.putovny@nic.cz>
Thu, 6 Mar 2025 15:29:03 +0000 (16:29 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 6 Mar 2025 15:29:03 +0000 (16:29 +0100)
proto/aggregator/aggregator.c
proto/aggregator/aggregator.h
proto/aggregator/trie.c

index 7a6be4321ff632979cd9be1033c9918cd3dfc3c6..3736d8f8b56a40c0263b803830060bc8ed929ed3 100644 (file)
@@ -47,9 +47,6 @@
 #include "filter/filter.h"
 #include "proto/aggregator/aggregator.h"
 
-#include <stdlib.h>
-#include <assert.h>
-
 extern linpool *rte_update_pool;
 
 /*
@@ -64,8 +61,9 @@ aggregator_get_new_bucket_id(struct aggregator_proto *p)
 }
 
 /*
- * Insert @bucket to the list of bucket pointers in @p to position @bucket.id
+ * Add @bucket to the list of bucket pointers in @p to position @bucket.id
  */
+// TODO: enable to reset bucket ptr?
 static void
 aggregator_add_bucket(struct aggregator_proto *p, struct aggregator_bucket *bucket)
 {
@@ -712,7 +710,7 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new
     {
       aggregator_recalculate(p, old_route, new_route);
 
-      /* Process all route withdrawals which were caused by the update */
+      /* Process route withdrawals triggered by recalculation */
       aggregator_withdraw_rte(p);
     }
   }
@@ -766,6 +764,7 @@ aggregator_postconfig(struct proto_config *CF)
   cf->dst->debug = cf->src->debug;
 }
 
+// TODO: set pools to NULL?
 static struct proto *
 aggregator_init(struct proto_config *CF)
 {
index 31b9a0a598417f28da5fa96ad71b480082816cf2..5e58526bb359d2ea6be07cb845300111416b37ba 100644 (file)
@@ -55,7 +55,6 @@ struct aggregator_bucket {
   struct f_val aggr_data[0];
 };
 
-/* Information needed for route withdrawal */
 struct rte_withdrawal_item {
   struct rte_withdrawal_item *next;
   struct aggregator_bucket *bucket;
index 49c4c605048de0be4385d688bf932d4bc2090306..bd667d150ae3c74d77aa92bbe138188d674af66e 100644 (file)
@@ -77,9 +77,6 @@
 #include "filter/filter.h"
 #include "proto/aggregator/aggregator.h"
 
-#include <stdlib.h>
-#include <assert.h>
-
 static const char *px_origin_str[] = {
   [FILLER]     = "filler",
   [ORIGINAL]   = "original",
@@ -94,6 +91,7 @@ static const u32 ipa_shift[] = {
 /*
  * Allocate new node in trie slab
  */
+// TODO: inline in aggregator.h?
 struct trie_node *
 aggregator_create_new_node(struct slab *trie_slab)
 {
@@ -109,6 +107,7 @@ aggregator_is_leaf(const struct trie_node *node)
 
 /*
  * Unlink node from the trie by setting appropriate child of parent node to NULL
+ * and free memory.
  */
 static inline void
 aggregator_remove_node(struct trie_node *node)
@@ -248,7 +247,7 @@ aggregator_merge_potential_buckets(struct trie_node *target, const struct trie_n
 
     /*
      * If old and new values are different, the result of their XOR will be
-     * non-zero, thus @changed will be set to non-zero - true, as well.
+     * non-zero, thus @has_changed will be set to non-zero -- true, as well.
      */
     has_changed |= !!(old[i] ^ target->potential_buckets[i]);
   }
@@ -534,7 +533,9 @@ aggregator_find_subtree_prefix(const struct trie_node *target, ip_addr *prefix,
     else
       ipa_setbit(prefix, node->depth + ipa_shift[type]);
 
+    // TODO: remove after testing, traversing back to target node is not neccessary
     node = node->child[path[i]];
+
     len++;
     ASSERT_DIE((u32)node->depth == len);
   }
@@ -612,7 +613,7 @@ aggregator_second_pass(struct trie_node *node, int recomputing)
    */
   aggregator_node_add_potential_bucket(&imaginary_node, node->original_bucket);
 
-  /* Nodes with exactly one child */
+  /* Nodes with only one child */
   if ((left && !right) || (!left && right))
   {
     if (left && !right)
@@ -887,7 +888,7 @@ aggregator_merge_buckets_above(struct trie_node *node)
 
     ASSERT_DIE(left != NULL && right != NULL);
 
-    /* The parent's set wasn't affected by merging, stop here */
+    /* The parent's set didn't change by merging, stop here */
     if (aggregator_merge_potential_buckets(parent, left, right) == 0)
       return node;
 
@@ -994,6 +995,7 @@ aggregator_recalculate(struct aggregator_proto *p, struct aggregator_route *old,
   }
   */
 
+  // TODO: root should never get here
   ASSERT_DIE(ancestor != NULL);
   ASSERT_DIE(ancestor != updated_node);
   ASSERT_DIE(ancestor->status == IN_FIB);