From b7d7599ce3576f28310af18b403fed49a0840b67 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 13 Aug 2019 18:22:07 +0200 Subject: BGP: implement Adj-RIB-Out The patch implements optional internal export table to a channel and hooks it to BGP so it can be used as Adj-RIB-Out. When enabled, all exported (post-filtered) routes are stored there. An export table can be examined using e.g. 'show route export table bgp1.ipv4'. --- nest/proto.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'nest/proto.c') diff --git a/nest/proto.c b/nest/proto.c index 18cf214b..54955bdd 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -317,6 +317,13 @@ channel_reset_import(struct channel *c) rt_prune_sync(c->in_table, 1); } +static void +channel_reset_export(struct channel *c) +{ + /* Just free the routes */ + rt_prune_sync(c->out_table, 1); +} + /* Called by protocol to activate in_table */ void channel_setup_in_table(struct channel *c) @@ -331,6 +338,18 @@ channel_setup_in_table(struct channel *c) c->reload_event = ev_new_init(c->proto->pool, channel_reload_loop, c); } +/* Called by protocol to activate out_table */ +void +channel_setup_out_table(struct channel *c) +{ + struct rtable_config *cf = mb_allocz(c->proto->pool, sizeof(struct rtable_config)); + cf->name = "export"; + cf->addr_type = c->net_type; + + c->out_table = mb_allocz(c->proto->pool, sizeof(struct rtable)); + rt_setup(c->proto->pool, c->out_table, cf); +} + static void channel_do_start(struct channel *c) @@ -376,6 +395,7 @@ channel_do_down(struct channel *c) c->in_table = NULL; c->reload_event = NULL; + c->out_table = NULL; CALL(c->channel->cleanup, c); @@ -411,6 +431,9 @@ channel_set_state(struct channel *c, uint state) if (c->in_table && (cs == CS_UP)) channel_reset_import(c); + if (c->out_table && (cs == CS_UP)) + channel_reset_export(c); + break; case CS_UP: @@ -433,6 +456,9 @@ channel_set_state(struct channel *c, uint state) if (c->in_table && (cs == CS_UP)) channel_reset_import(c); + if (c->out_table && (cs == CS_UP)) + channel_reset_export(c); + channel_do_flush(c); break; -- cgit v1.2.3