#include "lib/string.h"
#include "lib/alloca.h"
#include "lib/flowspec.h"
+#include "lib/idm.h"
#ifdef CONFIG_BGP
#include "proto/bgp/bgp.h"
rtable *dst = ln->dst;
ASSUME(rt_is_flow(dst));
- /* No need to inspect it further if recalculation is already active */
+ /* No need to inspect it further if recalculation is already scheduled */
if ((dst->nhu_state == NHU_SCHEDULED) || (dst->nhu_state == NHU_DIRTY)
|| !trie_match_net(dst->flowspec_trie, net))
{
init_list(&e->hooks);
}
+static struct idm rtable_idm;
+uint rtable_max_id = 0;
+
rtable *
rt_setup(pool *pp, struct rtable_config *cf)
{
t->name = cf->name;
t->config = cf;
t->addr_type = cf->addr_type;
+ t->id = idm_alloc(&rtable_idm);
+ if (t->id >= rtable_max_id)
+ rtable_max_id = t->id + 1;
fib_init(&t->fib, p, t->addr_type, sizeof(net), OFFSETOF(net, n), 0, NULL);
init_list(&deleted_routing_tables);
ev_init_list(&rt_cork.queue, &main_birdloop, "Route cork release");
rt_cork.run = (event) { .hook = rt_cork_release_hook };
+ idm_init(&rtable_idm, rt_table_pool, 256);
}
return;
}
+ /* Destination schedule map */
+ rtable **nhu_pending = tmp_allocz(sizeof(rtable *) * rtable_max_id);
+
struct hostentry *he;
node *n, *x;
}
if (rt_update_hostentry(tab, he))
- rt_schedule_nhu(he->tab);
+ nhu_pending[he->tab->id] = he->tab;
}
+
+ for (uint i=0; i<rtable_max_id; i++)
+ if (nhu_pending[i])
+ rt_schedule_nhu(nhu_pending[i]);
}
static struct hostentry *
u64 next_seq; /* The next export will have this ID */
};
+extern uint rtable_max_id;
+
typedef struct rtable {
resource r;
node n; /* Node in list of all tables */
struct f_trie *trie; /* Trie of prefixes defined in fib */
char *name; /* Name of this table */
uint addr_type; /* Type of address data stored in table (NET_*) */
+ uint id; /* Integer table ID for fast lookup */
int use_count; /* Number of protocols using this table */
u32 rt_count; /* Number of routes in the table */