p->root = aggregator_root_init(default_rte_bucket, p->trie_slab);
}
+/*
+ * Build and aggregate trie after initial feed ends
+ */
static void
aggregator_aggregate_on_feed_end(struct channel *C)
{
log("===================================================");
}
- /* merge filter needs one argument called "routes" */
+ /* Merge filter needs one argument called "routes" */
struct f_val val = {
.type = T_ROUTES_BLOCK,
.val.rte = bucket->rte,
if (old_route && rte_same(&old_route->rte, new))
return;
- /* Evaluate route attributes. */
+ /* Evaluate route attributes */
struct aggregator_bucket *tmp_bucket = allocz(sizeof(*tmp_bucket) + sizeof(tmp_bucket->aggr_data[0]) * p->aggr_on_count);
ASSERT_DIE(tmp_bucket->id == 0);
}
else if (p->aggr_mode == PREFIX_AGGR)
{
- /* When receiving initial feed, whole trie is aggregated at once */
+ /* After initial feed, recompute trie after receiving incremental update */
if (!p->initial_feed)
{
- /* After initial feed, recompute after receiving incremental update */
aggregator_recompute(p, old_route, new_route);
/* Process route withdrawals triggered by recomputation */
mem_hash_init(&haux);
new_bucket->hash = mem_hash_value(&haux);
- /* Assign ID to the root node bucket */
+ /* Assign ID to the bucket */
new_bucket->id = hmap_first_zero(&p->bucket_id_map);
hmap_set(&p->bucket_id_map, new_bucket->id);
- /* Add bucket pointer to the list of pointers */
+ /* Save bucket pointer */
aggregator_add_bucket(p, new_bucket);
p->buckets_count++;
+ /* Prepare route */
struct aggregator_route *arte = lp_allocz(p->route_pool, sizeof(*arte));
*arte = (struct aggregator_route) {
*
* After every aggregation, following invariants are always satisfied:
*
- * 1. All nodes have some bucket.
+ * 1. All nodes have original bucket set.
* 2. All nodes have the IN_FIB ancestor pointer set.
* 3. If a node is IN_FIB, then
* a) its selected bucket must not be null,
{
ASSERT_DIE(node != NULL);
- /* Imaginary node that would have been added during normalization of the trie */
const size_t node_size = sizeof(*node) + sizeof(node->potential_buckets[0]) * bitmap_size;
+ /* Imaginary node that would have been added during normalization of the trie */
struct trie_node *imaginary_node = allocz(node_size);
*imaginary_node = (struct trie_node) {
{
ASSERT_DIE(old_bucket != NULL);
- /* Node's bucket has changed, remove old route before exporting new */
+ /* Node's bucket has changed, remove old route and export new */
if (old_bucket && old_bucket != node->selected_bucket)
{
aggregator_prepare_rte_withdrawal(p, prefix, pxlen, old_bucket);
struct trie_node *ancestor = updated_node;
/* Find the closest IN_FIB ancestor of the updated node */
- // TODO: use node ancestor pointer instead of traversing
while (ancestor = ancestor->parent)
{
ASSERT_DIE(ancestor != updated_node);