From: Igor Putovny Date: Thu, 10 Apr 2025 12:40:32 +0000 (+0200) Subject: bucket_update() now takes net_addr instead of net X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=300141b93caec2472030c1dcf7c66bed4b3b9527;p=thirdparty%2Fbird.git bucket_update() now takes net_addr instead of net --- diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 11d3c911f..1d1fdd48f 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -211,12 +211,12 @@ aggregator_same_val_list(const struct f_val *v1, const struct f_val *v2, u32 len * Create and export new merged route */ void -aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net) +aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, const struct net_addr *addr) { /* Empty bucket */ if (!bucket->rte) { - rte_update2(p->dst, net->n.addr, NULL, bucket->last_src); + rte_update2(p->dst, addr, NULL, bucket->last_src); bucket->last_src = NULL; return; } @@ -247,18 +247,20 @@ aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *b aggregator_rta_set_static_attr(rta, bucket->rte->attrs, p->aggr_on[i].sa); } - struct rte *new = rte_get_temp(rta, p->p.main_source); - /* Here we need _some_ net to run the filters properly - * TODO: use a temporary local net instead of a real one to avoid confusion */ - new->net = net; - //struct network *n = allocz(sizeof(*n) + sizeof(addr)); - //net_copy(n->n.addr, &addr); + struct network *net = allocz(sizeof(*net) + sizeof(*addr)); + net_copy(net->n.addr, addr); + /* + * Here we need _some_ net to run the filters properly + * TODO: use a temporary local net instead of a real one to avoid confusion + */ + struct rte *new_rte = rte_get_temp(rta, p->p.main_source); + new_rte->net = net; if (p->logging) { log("=============== CREATE MERGED ROUTE ==============="); - log("New route created: id = %d, protocol: %s", new->src->global_id, new->src->proto->name); + log("New route created: id = %d, protocol: %s", new_rte->src->global_id, new_rte->src->proto->name); log("==================================================="); } @@ -269,17 +271,17 @@ aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *b }; /* Actually run the filter */ - enum filter_return fret = f_eval_rte(p->merge_by, &new, rte_update_pool, 1, &val, 0); + enum filter_return fret = f_eval_rte(p->merge_by, &new_rte, rte_update_pool, 1, &val, 0); /* Src must be stored now, rte_update2() may return new */ - struct rte_src *new_src = new ? new->src : NULL; + struct rte_src *new_src = new_rte ? new_rte->src : NULL; /* Finally import the route */ switch (fret) { /* Pass the route to the protocol */ case F_ACCEPT: - rte_update2(p->dst, net->n.addr, new, bucket->last_src ?: new->src); + rte_update2(p->dst, net->n.addr, new_rte, bucket->last_src ?: new_rte->src); break; /* Something bad happened */ @@ -319,7 +321,7 @@ aggregator_reload_buckets(void *data) HASH_WALK(p->buckets, next_hash, b) if (b->rte) { - aggregator_bucket_update(p, b, b->rte->net); + aggregator_bucket_update(p, b, b->rte->net->n.addr); lp_flush(rte_update_pool); } HASH_WALK_END; @@ -713,10 +715,10 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new { /* Announce changes */ if (old_bucket) - aggregator_bucket_update(p, old_bucket, net); + aggregator_bucket_update(p, old_bucket, net->n.addr); if (new_bucket && (new_bucket != old_bucket)) - aggregator_bucket_update(p, new_bucket, net); + aggregator_bucket_update(p, new_bucket, net->n.addr); } else if (p->aggr_mode == PREFIX_AGGR) { diff --git a/proto/aggregator/aggregator.h b/proto/aggregator/aggregator.h index 97bf12461..d316f979d 100644 --- a/proto/aggregator/aggregator.h +++ b/proto/aggregator/aggregator.h @@ -152,7 +152,7 @@ struct trie_node { void aggregator_aggregate(struct aggregator_proto *p); void aggregator_recompute(struct aggregator_proto *p, struct aggregator_route *old, struct aggregator_route *new); -void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net); +void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, const struct net_addr *addr); struct trie_node *aggregator_root_init(struct aggregator_bucket *bucket, struct slab *trie_slab); diff --git a/proto/aggregator/trie.c b/proto/aggregator/trie.c index 04ee6e3cb..7bf793b0b 100644 --- a/proto/aggregator/trie.c +++ b/proto/aggregator/trie.c @@ -440,11 +440,8 @@ aggregator_create_route(struct aggregator_proto *p, ip_addr prefix, u32 pxlen, s struct net_addr addr = { 0 }; net_fill_ipa(&addr, prefix, pxlen); - struct network *n = allocz(sizeof(*n) + sizeof(addr)); - net_copy(n->n.addr, &addr); - /* TODO: Proč sem vlastně předáváme struct network? Mělo by nám stačit net_addr. */ - aggregator_bucket_update(p, bucket, n); + aggregator_bucket_update(p, bucket, &addr); } /*