From: Igor Putovny Date: Mon, 7 Oct 2024 15:02:01 +0000 (+0200) Subject: trie_insert_prefix() now allows updating a bucket of existing prefix X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=056abfcde8392d335eab094df115474d2e9f3942;p=thirdparty%2Fbird.git trie_insert_prefix() now allows updating a bucket of existing prefix --- diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index dc7995eba..fa5bb4bdb 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -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; } /*