]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Create default empty route for aggregation
authorIgor Putovny <igor.putovny@nic.cz>
Tue, 5 Dec 2023 13:32:06 +0000 (14:32 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Tue, 5 Dec 2023 13:32:39 +0000 (14:32 +0100)
proto/aggregator/aggregator.c

index ddb343f3f988a1fd88fed7f6ac89c3e48d8d4b34..6c67f18c05a472e9c8aa128b4d7caac183176d4c 100644 (file)
@@ -1284,6 +1284,30 @@ aggregator_start(struct proto *P)
     .data = p,
   };
 
+  /* Create route attributes with zero nexthop */
+  struct rta rta = { 0 };
+
+  /* Allocate bucket for root node */
+  struct aggregator_bucket *new_bucket = sl_allocz(p->bucket_slab);
+  u64 haux = 0;
+  mem_hash_init(&haux);
+  new_bucket->hash = mem_hash_value(&haux);
+
+  struct aggregator_route *arte = sl_alloc(p->route_slab);
+
+  *arte = (struct aggregator_route) {
+    .bucket = new_bucket,
+    .rte = { .attrs = rta_lookup(&rta) },
+  };
+
+  arte->rte.next = new_bucket->rte;
+  new_bucket->rte = &arte->rte;
+  new_bucket->count++;
+  HASH_INSERT2(p->routes, AGGR_RTE, p->p.pool, arte);
+
+  /* Assign default route to the root */
+  p->root->bucket = new_bucket;
+
   return PS_UP;
 }