]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Move aggregation algorithm to separate function
authorIgor Putovny <igor.putovny@nic.cz>
Thu, 16 May 2024 12:48:14 +0000 (14:48 +0200)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 30 May 2024 10:30:00 +0000 (12:30 +0200)
proto/aggregator/aggregator.c

index 5285c14caf2e8fe72c6a8f4833416c0f336e6ef2..baa52acc2e8cecd0cd2a964f6b784fc44b3c3fa2 100644 (file)
@@ -906,14 +906,8 @@ calculate_trie(struct aggregator_proto *p)
 }
 
 static void
-run_aggregation(struct channel *C)
+run_aggregation(struct aggregator_proto *p)
 {
-  struct aggregator_proto *p = (void *)C->proto;
-
-  /* Run aggregation only on feed-end from source channel */
-  if (C != p->src)
-    return;
-
   construct_trie(p);
   calculate_trie(p);
   collect_prefixes(p);
@@ -923,6 +917,16 @@ run_aggregation(struct channel *C)
   log("==== AGGREGATION DONE ====");
 }
 
+static void
+aggregate_on_feed_end(struct channel *C)
+{
+  struct aggregator_proto *p = SKIP_BACK(struct aggregator_proto, p, C);
+
+  /* Run aggregation only on feed end from the source channel */
+  if (C == p->src)
+    run_aggregation(p);
+}
+
 /*
  * Set static attribute in @rta from static attribute in @old according to @sa.
  */
@@ -1532,7 +1536,7 @@ aggregator_init(struct proto_config *CF)
 
   P->rt_notify = aggregator_rt_notify;
   P->preexport = aggregator_preexport;
-  P->feed_end = run_aggregation;
+  P->feed_end = aggregate_on_feed_end;
 
   return P;
 }