From 682d3f7de0905ca2e853844734cce7ff65f7d77d Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Thu, 27 Sep 2018 22:57:55 +0200 Subject: 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'. --- nest/protocol.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'nest/protocol.h') diff --git a/nest/protocol.h b/nest/protocol.h index 3008087b..aa836f38 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -306,8 +306,6 @@ rte_make_tmp_attrs(struct rte **rt, struct linpool *pool) (*rt)->attrs->eattrs = ea; } -/* Moved from route.h to avoid dependency conflicts */ -static inline void rte_update(struct proto *p, const net_addr *n, rte *new) { rte_update2(p->main_channel, n, new, p->main_source); } extern pool *proto_pool; extern list proto_list; @@ -539,6 +537,11 @@ struct channel { btime last_state_change; /* Time of last state transition */ btime last_tx_filter_change; + + struct rtable *in_table; /* Internal table for received routes */ + struct event *reload_event; /* Event responsible for reloading from in_table */ + struct fib_iterator reload_fit; /* Iterator in in_table used during reloading */ + u8 reload_active; /* Iterator reload_fit is linked */ }; @@ -606,6 +609,8 @@ struct channel *proto_add_channel(struct proto *p, struct channel_config *cf); int proto_configure_channel(struct proto *p, struct channel **c, struct channel_config *cf); void channel_set_state(struct channel *c, uint state); +void channel_setup_in_table(struct channel *c); +void channel_schedule_reload(struct channel *c); static inline void channel_init(struct channel *c) { channel_set_state(c, CS_START); } static inline void channel_open(struct channel *c) { channel_set_state(c, CS_UP); } @@ -617,4 +622,17 @@ void *channel_config_get(const struct channel_class *cc, const char *name, uint int channel_reconfigure(struct channel *c, struct channel_config *cf); +/* Moved from route.h to avoid dependency conflicts */ +static inline void rte_update(struct proto *p, const net_addr *n, rte *new) { rte_update2(p->main_channel, n, new, p->main_source); } + +static inline void +rte_update3(struct channel *c, const net_addr *n, rte *new, struct rte_src *src) +{ + if (c->in_table && !rte_update_in(c, n, new, src)) + return; + + rte_update2(c, n, new, src); +} + + #endif -- cgit v1.2.3