mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 07:31:54 +00:00
Set aggregation mode in the configuration file
This commit is contained in:
parent
c892b2d02f
commit
f5701ed913
@ -1479,7 +1479,7 @@ aggregator_rt_notify(struct proto *P, struct channel *src_ch, net *net, rte *new
|
|||||||
rta_free(old_route->rte.attrs);
|
rta_free(old_route->rte.attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->net_present != 0)
|
if (NET_AGGR == p->aggr_mode)
|
||||||
{
|
{
|
||||||
/* Announce changes */
|
/* Announce changes */
|
||||||
if (old_bucket)
|
if (old_bucket)
|
||||||
@ -1550,10 +1550,10 @@ aggregator_init(struct proto_config *CF)
|
|||||||
proto_configure_channel(P, &p->src, cf->src);
|
proto_configure_channel(P, &p->src, cf->src);
|
||||||
proto_configure_channel(P, &p->dst, cf->dst);
|
proto_configure_channel(P, &p->dst, cf->dst);
|
||||||
|
|
||||||
|
p->aggr_mode = cf->aggr_mode;
|
||||||
p->aggr_on_count = cf->aggr_on_count;
|
p->aggr_on_count = cf->aggr_on_count;
|
||||||
p->aggr_on_da_count = cf->aggr_on_da_count;
|
p->aggr_on_da_count = cf->aggr_on_da_count;
|
||||||
p->aggr_on = cf->aggr_on;
|
p->aggr_on = cf->aggr_on;
|
||||||
p->net_present = cf->net_present;
|
|
||||||
p->merge_by = cf->merge_by;
|
p->merge_by = cf->merge_by;
|
||||||
p->notify_settle_cf = cf->notify_settle_cf;
|
p->notify_settle_cf = cf->notify_settle_cf;
|
||||||
|
|
||||||
|
@ -20,13 +20,17 @@
|
|||||||
|
|
||||||
#define MAX_POTENTIAL_BUCKETS_COUNT 16
|
#define MAX_POTENTIAL_BUCKETS_COUNT 16
|
||||||
|
|
||||||
|
enum aggr_mode {
|
||||||
|
NET_AGGR, PREFIX_AGGR,
|
||||||
|
};
|
||||||
|
|
||||||
struct aggregator_config {
|
struct aggregator_config {
|
||||||
struct proto_config c;
|
struct proto_config c;
|
||||||
struct channel_config *src, *dst;
|
struct channel_config *src, *dst;
|
||||||
|
enum aggr_mode aggr_mode;
|
||||||
uint aggr_on_count;
|
uint aggr_on_count;
|
||||||
uint aggr_on_da_count;
|
uint aggr_on_da_count;
|
||||||
struct aggr_item *aggr_on;
|
struct aggr_item *aggr_on;
|
||||||
int net_present;
|
|
||||||
const struct f_line *merge_by;
|
const struct f_line *merge_by;
|
||||||
struct settle_config notify_settle_cf;
|
struct settle_config notify_settle_cf;
|
||||||
};
|
};
|
||||||
@ -49,7 +53,7 @@ struct aggregator_bucket {
|
|||||||
struct aggregator_proto {
|
struct aggregator_proto {
|
||||||
struct proto p;
|
struct proto p;
|
||||||
struct channel *src, *dst;
|
struct channel *src, *dst;
|
||||||
|
enum aggr_mode aggr_mode;
|
||||||
|
|
||||||
/* Buckets by aggregator rule */
|
/* Buckets by aggregator rule */
|
||||||
HASH(struct aggregator_bucket) buckets;
|
HASH(struct aggregator_bucket) buckets;
|
||||||
@ -63,7 +67,6 @@ struct aggregator_proto {
|
|||||||
uint aggr_on_count;
|
uint aggr_on_count;
|
||||||
uint aggr_on_da_count;
|
uint aggr_on_da_count;
|
||||||
struct aggr_item *aggr_on;
|
struct aggr_item *aggr_on;
|
||||||
int net_present;
|
|
||||||
|
|
||||||
/* Merge filter */
|
/* Merge filter */
|
||||||
const struct f_line *merge_by;
|
const struct f_line *merge_by;
|
||||||
|
@ -36,7 +36,14 @@ aggregator_proto_start: proto_start AGGREGATOR
|
|||||||
this_proto = proto_config_new(&proto_aggregator, $1);
|
this_proto = proto_config_new(&proto_aggregator, $1);
|
||||||
this_channel = AGGREGATOR_CFG->src = channel_config_new(NULL, "source", 0, this_proto);
|
this_channel = AGGREGATOR_CFG->src = channel_config_new(NULL, "source", 0, this_proto);
|
||||||
AGGREGATOR_CFG->dst = channel_config_new(NULL, "destination", 0, this_proto);
|
AGGREGATOR_CFG->dst = channel_config_new(NULL, "destination", 0, this_proto);
|
||||||
AGGREGATOR_CFG->src->ra_mode = AGGREGATOR_CFG->dst->ra_mode = RA_ANY;
|
|
||||||
|
/*
|
||||||
|
* Aggregation mode is set to prefix aggregation by default, in which case we want to receive
|
||||||
|
* updates with the best routes.
|
||||||
|
*/
|
||||||
|
AGGREGATOR_CFG->aggr_mode = PREFIX_AGGR;
|
||||||
|
AGGREGATOR_CFG->src->ra_mode = RA_OPTIMAL;
|
||||||
|
AGGREGATOR_CFG->dst->ra_mode = RA_ANY;
|
||||||
|
|
||||||
AGGREGATOR_CFG->notify_settle_cf = (struct settle_config) {
|
AGGREGATOR_CFG->notify_settle_cf = (struct settle_config) {
|
||||||
.min = 10 MS_,
|
.min = 10 MS_,
|
||||||
@ -52,14 +59,19 @@ aggregator_proto_item:
|
|||||||
if (AGGREGATOR_CFG->aggr_on)
|
if (AGGREGATOR_CFG->aggr_on)
|
||||||
cf_error("Only one aggregate on clause allowed");
|
cf_error("Only one aggregate on clause allowed");
|
||||||
|
|
||||||
AGGREGATOR_CFG->net_present = 0;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (const struct aggr_item_node *item = $3; item; item = item->next) {
|
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);
|
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;
|
* If NET attribute is present, aggregate routes within the same net
|
||||||
|
* and receive updates with any routes.
|
||||||
|
*/
|
||||||
|
if (item->i.type == AGGR_ITEM_STATIC_ATTR && item->i.sa.sa_code == SA_NET) {
|
||||||
|
AGGREGATOR_CFG->aggr_mode = NET_AGGR;
|
||||||
|
AGGREGATOR_CFG->src->ra_mode = RA_ANY;
|
||||||
|
}
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -92,7 +104,7 @@ aggregator_proto: aggregator_proto_start proto_name '{' aggregator_proto_opts '}
|
|||||||
if (AGGREGATOR_CFG->src->table->addr_type != AGGREGATOR_CFG->dst->table->addr_type)
|
if (AGGREGATOR_CFG->src->table->addr_type != AGGREGATOR_CFG->dst->table->addr_type)
|
||||||
cf_error("Both rtables in aggregator must have the same network type");
|
cf_error("Both rtables in aggregator must have the same network type");
|
||||||
|
|
||||||
if (AGGREGATOR_CFG->net_present == 0)
|
if (PREFIX_AGGR == AGGREGATOR_CFG->aggr_mode)
|
||||||
if (AGGREGATOR_CFG->src->table->addr_type != NET_IP4 && AGGREGATOR_CFG->src->table->addr_type != NET_IP6)
|
if (AGGREGATOR_CFG->src->table->addr_type != NET_IP4 && AGGREGATOR_CFG->src->table->addr_type != NET_IP6)
|
||||||
cf_error("Trie aggregation is available only for IP4 or IPv6 networks");
|
cf_error("Trie aggregation is available only for IP4 or IPv6 networks");
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user