]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Run correct aggregation (by nets or by attributes) according to configuration
authorIgor Putovny <igor.putovny@nic.cz>
Fri, 5 Jan 2024 12:48:02 +0000 (13:48 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 30 May 2024 10:30:00 +0000 (12:30 +0200)
proto/aggregator/aggregator.c
proto/aggregator/aggregator.h
proto/aggregator/config.Y

index 41afa0ff07bed6d6b1747468361aede88b2c610e..461fb9082d451d4a8d9771a80ed9edaf13da7fef 100644 (file)
@@ -65,6 +65,8 @@
 
 extern linpool *rte_update_pool;
 
+static void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net);
+
 static inline int
 is_leaf(const struct trie_node *node)
 {
@@ -1332,14 +1334,17 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new
   }
   HASH_WALK_END;
 
-  ev_schedule(&p->reload_trie);
-
-  /* Announce changes */
-  if (old_bucket)
-    aggregator_bucket_update(p, old_bucket, net);
+  if (p->net_present == 0)
+    ev_schedule(&p->reload_trie);
+  else
+  {
+    /* Announce changes */
+    if (old_bucket)
+      aggregator_bucket_update(p, old_bucket, net);
 
-  if (new_bucket && (new_bucket != old_bucket))
-    aggregator_bucket_update(p, new_bucket, net);
+    if (new_bucket && (new_bucket != old_bucket))
+      aggregator_bucket_update(p, new_bucket, net);
+  }
 
   /* Cleanup the old bucket if empty */
   if (old_bucket && (!old_bucket->rte || !old_bucket->count))
@@ -1403,6 +1408,7 @@ aggregator_init(struct proto_config *CF)
   p->aggr_on_count = cf->aggr_on_count;
   p->aggr_on_da_count = cf->aggr_on_da_count;
   p->aggr_on = cf->aggr_on;
+  p->net_present = cf->net_present;
   p->merge_by = cf->merge_by;
 
   P->rt_notify = aggregator_rt_notify;
index 22638ac210ec0f68c4b93d52e61d71ea0e517114..b2fd01551b714f85eccfceded232a35e38079f2f 100644 (file)
@@ -25,6 +25,7 @@ struct aggregator_config {
   uint aggr_on_count;
   uint aggr_on_da_count;
   struct aggr_item *aggr_on;
+  int net_present;
   const struct f_line *merge_by;
 };
 
@@ -59,6 +60,7 @@ struct aggregator_proto {
   uint aggr_on_count;
   uint aggr_on_da_count;
   struct aggr_item *aggr_on;
+  int net_present;
 
   /* Merge filter */
   const struct f_line *merge_by;
index ad5b1e2795b232b954bd87e4aace8ed9c1cb991f..cec24c60f9e0ac2eadf1e1908da6f513c5ef6e99 100644 (file)
@@ -47,10 +47,15 @@ aggregator_proto_item:
     if (AGGREGATOR_CFG->aggr_on)
       cf_error("Only one aggregate on clause allowed");
 
+    AGGREGATOR_CFG->net_present = 0;
     int count = 0;
 
     for (const struct aggr_item_node *item = $3; item; item = item->next) {
       log(L_WARN "type %d sacode %d", item->i.type, item->i.sa.sa_code);
+
+      if (item->i.type == AGGR_ITEM_STATIC_ATTR && item->i.sa.sa_code == SA_NET)
+        AGGREGATOR_CFG->net_present = 1;
+
       count++;
     }