0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-09 12:48:43 +00:00

Run correct aggregation (by nets or by attributes) according to configuration

This commit is contained in:
Igor Putovny 2024-01-05 13:48:02 +01:00
parent ecfb73332a
commit dcf0038fd0
3 changed files with 20 additions and 7 deletions

View 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);
if (p->net_present == 0)
ev_schedule(&p->reload_trie);
else
{
/* Announce changes */
if (old_bucket)
aggregator_bucket_update(p, old_bucket, net);
/* 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;

View 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;

View 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++;
}