summaryrefslogtreecommitdiff
path: root/proto/bgp/bgp.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2018-09-27 22:57:55 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2018-12-12 14:46:24 +0100
commit682d3f7de0905ca2e853844734cce7ff65f7d77d (patch)
treee84ab31b4c5b7e99a283cf4c2faf2523dd5d884c /proto/bgp/bgp.c
parent01fd00f5ed9298ab5829403cd7a8a9ba22bcc96a (diff)
BGP: implement Adj-RIB-In
The patch implements optional internal import table to a channel and hooks it to BGP so it can be used as Adj-RIB-In. When enabled, all received (pre-filtered) routes are stored there and import filters can be re-evaluated without explicit route refresh. An import table can be examined using e.g. 'show route import table bgp1.ipv4'.
Diffstat (limited to 'proto/bgp/bgp.c')
-rw-r--r--proto/bgp/bgp.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index e20097ae..b2dbd780 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -545,7 +545,7 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
int active = loc->ready && rem->ready;
c->c.disabled = !active;
- c->c.reloadable = p->route_refresh;
+ c->c.reloadable = p->route_refresh || c->cf->import_table;
c->index = active ? num++ : 0;
@@ -838,6 +838,9 @@ bgp_refresh_begin(struct bgp_channel *c)
c->load_state = BFS_REFRESHING;
rt_refresh_begin(c->c.table, &c->c);
+
+ if (c->c.in_table)
+ rt_refresh_begin(c->c.in_table, &c->c);
}
/**
@@ -859,6 +862,9 @@ bgp_refresh_end(struct bgp_channel *c)
c->load_state = BFS_NONE;
rt_refresh_end(c->c.table, &c->c);
+
+ if (c->c.in_table)
+ rt_prune_sync(c->c.in_table, 0);
}
@@ -1296,9 +1302,12 @@ bgp_reload_routes(struct channel *C)
struct bgp_proto *p = (void *) C->proto;
struct bgp_channel *c = (void *) C;
- ASSERT(p->conn && p->route_refresh);
+ ASSERT(p->conn && (p->route_refresh || c->c.in_table));
- bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
+ if (c->c.in_table)
+ channel_schedule_reload(C);
+ else
+ bgp_schedule_packet(p->conn, c, PKT_ROUTE_REFRESH);
}
static void
@@ -1598,6 +1607,9 @@ bgp_channel_start(struct channel *C)
bgp_init_bucket_table(c);
bgp_init_prefix_table(c);
+ if (c->cf->import_table)
+ channel_setup_in_table(C);
+
c->stale_timer = tm_new_init(c->pool, bgp_long_lived_stale_timeout, c, 0, 0);
c->next_hop_addr = c->cf->next_hop_addr;