2023-06-23 11:18:39 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Aggregator Pseudoprotocol
|
|
|
|
*
|
|
|
|
* (c) 2023 Igor Putovny <igor.putovny@nic.cz>
|
|
|
|
* (c) 2023 Maria Matejka <mq@ucw.cz>
|
|
|
|
* (c) 2023 CZ.NIC z.s.p.o.
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*
|
|
|
|
* This file contains the data structures used by Babel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_AGGREGATOR_H_
|
|
|
|
#define _BIRD_AGGREGATOR_H_
|
|
|
|
|
|
|
|
#include "nest/bird.h"
|
|
|
|
#include "nest/protocol.h"
|
|
|
|
#include "lib/hash.h"
|
2024-05-17 13:28:08 +00:00
|
|
|
#include "lib/settle.h"
|
2023-06-23 11:18:39 +00:00
|
|
|
|
2023-10-20 11:13:47 +00:00
|
|
|
#define MAX_POTENTIAL_BUCKETS_COUNT 16
|
2023-09-11 10:38:19 +00:00
|
|
|
|
2024-06-12 16:27:36 +00:00
|
|
|
enum aggr_mode {
|
|
|
|
NET_AGGR, PREFIX_AGGR,
|
|
|
|
};
|
|
|
|
|
2023-06-23 11:18:39 +00:00
|
|
|
struct aggregator_config {
|
|
|
|
struct proto_config c;
|
|
|
|
struct channel_config *src, *dst;
|
2024-06-12 16:27:36 +00:00
|
|
|
enum aggr_mode aggr_mode;
|
2023-06-23 11:18:39 +00:00
|
|
|
uint aggr_on_count;
|
|
|
|
uint aggr_on_da_count;
|
|
|
|
struct aggr_item *aggr_on;
|
|
|
|
const struct f_line *merge_by;
|
2024-06-12 15:27:05 +00:00
|
|
|
struct settle_config notify_settle_cf;
|
2023-06-23 11:18:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct aggregator_route {
|
|
|
|
struct aggregator_route *next_hash;
|
|
|
|
struct aggregator_bucket *bucket;
|
|
|
|
struct rte rte;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct aggregator_bucket {
|
|
|
|
struct aggregator_bucket *next_hash;
|
|
|
|
struct rte *rte; /* Pointer to struct aggregator_route.rte */
|
|
|
|
struct rte_src *last_src; /* Which src we announced the bucket last with */
|
|
|
|
u32 count;
|
|
|
|
u32 hash;
|
|
|
|
struct f_val aggr_data[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct aggregator_proto {
|
|
|
|
struct proto p;
|
|
|
|
struct channel *src, *dst;
|
2024-06-12 16:27:36 +00:00
|
|
|
enum aggr_mode aggr_mode;
|
2024-06-11 11:27:15 +00:00
|
|
|
|
2023-06-23 11:18:39 +00:00
|
|
|
/* Buckets by aggregator rule */
|
|
|
|
HASH(struct aggregator_bucket) buckets;
|
2024-06-04 15:44:28 +00:00
|
|
|
linpool *bucket_pool;
|
2023-06-23 11:18:39 +00:00
|
|
|
|
|
|
|
/* Routes by net and src */
|
|
|
|
HASH(struct aggregator_route) routes;
|
2024-06-04 15:44:28 +00:00
|
|
|
linpool *route_pool;
|
2023-06-23 11:18:39 +00:00
|
|
|
|
|
|
|
/* Aggregator rule */
|
|
|
|
uint aggr_on_count;
|
|
|
|
uint aggr_on_da_count;
|
|
|
|
struct aggr_item *aggr_on;
|
|
|
|
|
|
|
|
/* Merge filter */
|
|
|
|
const struct f_line *merge_by;
|
|
|
|
event reload_buckets;
|
2023-09-11 10:38:19 +00:00
|
|
|
|
|
|
|
/* Aggregation trie */
|
2024-06-11 11:27:15 +00:00
|
|
|
int first_run;
|
2024-03-07 14:14:26 +00:00
|
|
|
uint addr_type;
|
2024-06-04 15:44:28 +00:00
|
|
|
linpool *trie_pool;
|
2023-09-11 10:38:19 +00:00
|
|
|
struct trie_node *root;
|
2024-06-12 15:27:05 +00:00
|
|
|
struct settle_config notify_settle_cf;
|
|
|
|
struct settle notify_settle;
|
2024-05-09 15:29:03 +00:00
|
|
|
int before_count;
|
|
|
|
int after_count;
|
2023-06-23 11:18:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum aggr_item_type {
|
|
|
|
AGGR_ITEM_TERM,
|
|
|
|
AGGR_ITEM_STATIC_ATTR,
|
|
|
|
AGGR_ITEM_DYNAMIC_ATTR,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct aggr_item {
|
|
|
|
enum aggr_item_type type;
|
|
|
|
union {
|
|
|
|
struct f_static_attr sa;
|
|
|
|
struct f_dynamic_attr da;
|
|
|
|
const struct f_line *line;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct aggr_item_node {
|
|
|
|
const struct aggr_item_node *next;
|
|
|
|
struct aggr_item i;
|
|
|
|
};
|
|
|
|
|
2023-09-11 10:38:19 +00:00
|
|
|
struct trie_node {
|
|
|
|
struct trie_node *parent;
|
|
|
|
struct trie_node *child[2];
|
2024-01-05 12:37:35 +00:00
|
|
|
struct aggregator_bucket *bucket;
|
|
|
|
struct aggregator_bucket *potential_buckets[MAX_POTENTIAL_BUCKETS_COUNT];
|
2023-09-11 10:38:19 +00:00
|
|
|
int potential_buckets_count;
|
2024-03-27 11:03:47 +00:00
|
|
|
int depth;
|
2023-09-11 10:38:19 +00:00
|
|
|
};
|
|
|
|
|
2023-06-23 11:18:39 +00:00
|
|
|
#endif
|