]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
trie_insert_prefix() now allows updating a bucket of existing prefix
authorIgor Putovny <igor.putovny@nic.cz>
Mon, 7 Oct 2024 15:02:01 +0000 (17:02 +0200)
committerIgor Putovny <igor.putovny@nic.cz>
Wed, 9 Oct 2024 10:50:55 +0000 (12:50 +0200)
proto/aggregator/aggregator.c

index dc7995ebadb6b80fc5bb02bd1ccbcd80a34bdba8..fa5bb4bdb272ca22fa4b4ff664b3ce42abd5b7f3 100644 (file)
@@ -280,9 +280,10 @@ proto_insert_bucket(struct aggregator_proto *p, struct aggregator_bucket *bucket
 }
 
 /*
- * Insert prefix in @addr to prefix trie with beginning at @root and assign @bucket to this prefix
+ * Insert prefix in @addr to prefix trie with beginning at @root and assign @bucket to this prefix.
+ * If the prefix is already in the trie, update its bucket to @bucket and return updated node.
  */
-static void
+static struct trie_node *
 trie_insert_prefix_ip4(struct trie_node * const root, const struct net_addr_ip4 *addr, struct aggregator_bucket *bucket, linpool *trie_pool)
 {
   assert(addr != NULL);
@@ -312,9 +313,11 @@ trie_insert_prefix_ip4(struct trie_node * const root, const struct net_addr_ip4
   /* Assign bucket to the last node */
   node->bucket = bucket;
   node->status = IN_FIB;
+
+  return node;
 }
 
-static void
+static struct trie_node *
 trie_insert_prefix_ip6(struct trie_node * const root, const struct net_addr_ip6 *addr, struct aggregator_bucket *bucket, linpool *trie_pool)
 {
   assert(addr != NULL);
@@ -344,6 +347,8 @@ trie_insert_prefix_ip6(struct trie_node * const root, const struct net_addr_ip6
   /* Assign bucket to the last node */
   node->bucket = bucket;
   node->status = IN_FIB;
+
+  return node;
 }
 
 /*