summaryrefslogtreecommitdiff
path: root/nest/proto.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-08-13 18:22:07 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-08-14 06:02:33 +0200
commitb7d7599ce3576f28310af18b403fed49a0840b67 (patch)
tree7d7dc8f052d564c3fdbc49eea529f22850ab44ff /nest/proto.c
parentdfe63ed84d42178a53b01071c64f23250e74d6d9 (diff)
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'.
Diffstat (limited to 'nest/proto.c')
-rw-r--r--nest/proto.c26
1 files changed, 26 insertions, 0 deletions
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;