aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/gbp
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-12-04 06:11:00 +0000
committerOle Trøan <otroan@employees.org>2019-12-04 22:47:12 +0000
commit3bab8f9c5396a7bf1115b93a9e0691a76a9ed14c (patch)
tree0212708b47f042ac393848e0471669f837788278 /src/plugins/gbp
parent5f8f6173328f8d77feea5fd100e150c3094c11f0 (diff)
fib: Decouple source from priority and behaviour
Type: feature the fib_source_t enum alone no longer defines the priority and behaviour, instead each source must be allocated these attributes. This allows the creation of other sources by the plugins (and soon over the API). Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: I890ee820fbc16079ee417ea1fbc163192806e853
Diffstat (limited to 'src/plugins/gbp')
-rw-r--r--src/plugins/gbp/gbp_endpoint.c21
-rw-r--r--src/plugins/gbp/gbp_route_domain.c9
-rw-r--r--src/plugins/gbp/gbp_subnet.c13
3 files changed, 29 insertions, 14 deletions
diff --git a/src/plugins/gbp/gbp_endpoint.c b/src/plugins/gbp/gbp_endpoint.c
index 12865461d18..bef67770fd9 100644
--- a/src/plugins/gbp/gbp_endpoint.c
+++ b/src/plugins/gbp/gbp_endpoint.c
@@ -41,9 +41,10 @@ static const char *gbp_endpoint_attr_names[] = GBP_ENDPOINT_ATTR_NAMES;
*/
gbp_ep_db_t gbp_ep_db;
-fib_node_type_t gbp_endpoint_fib_type;
-
-vlib_log_class_t gbp_ep_logger;
+static fib_source_t gbp_fib_source_hi;
+static fib_source_t gbp_fib_source_low;
+static fib_node_type_t gbp_endpoint_fib_type;
+static vlib_log_class_t gbp_ep_logger;
#define GBP_ENDPOINT_DBG(...) \
vlib_log_debug (gbp_ep_logger, __VA_ARGS__);
@@ -588,10 +589,10 @@ gbb_endpoint_fwd_reset (gbp_endpoint_t * ge)
*/
if (gbp_endpoint_is_remote (ge))
{
- fib_table_entry_special_remove (fib_index, pfx, FIB_SOURCE_PLUGIN_HI);
+ fib_table_entry_special_remove (fib_index, pfx, gbp_fib_source_hi);
}
- fib_table_entry_delete (fib_index, pfx, FIB_SOURCE_PLUGIN_LOW);
+ fib_table_entry_delete (fib_index, pfx, gbp_fib_source_low);
}
vec_foreach (ai, gef->gef_adjs)
{
@@ -726,7 +727,7 @@ gbb_endpoint_fwd_recalc (gbp_endpoint_t * ge)
}
fib_table_entry_path_add (fib_index, pfx,
- FIB_SOURCE_PLUGIN_LOW,
+ gbp_fib_source_low,
FIB_ENTRY_FLAG_NONE,
fib_proto_to_dpo (pfx->fp_proto),
&pfx->fp_addr, ip_sw_if_index,
@@ -759,7 +760,7 @@ gbb_endpoint_fwd_recalc (gbp_endpoint_t * ge)
gg->gg_sclass, ~0, &policy_dpo);
fib_table_entry_special_dpo_add (fib_index, pfx,
- FIB_SOURCE_PLUGIN_HI,
+ gbp_fib_source_hi,
FIB_ENTRY_FLAG_INTERPOSE,
&policy_dpo);
dpo_reset (&policy_dpo);
@@ -1576,6 +1577,12 @@ gbp_endpoint_init (vlib_main_t * vm)
gbp_ep_logger = vlib_log_register_class ("gbp", "ep");
gbp_endpoint_fib_type = fib_node_register_new_type (&gbp_endpoint_vft);
+ gbp_fib_source_hi = fib_source_allocate ("gbp-endpoint-hi",
+ FIB_SOURCE_PRIORITY_HI,
+ FIB_SOURCE_BH_SIMPLE);
+ gbp_fib_source_low = fib_source_allocate ("gbp-endpoint-low",
+ FIB_SOURCE_PRIORITY_LOW,
+ FIB_SOURCE_BH_SIMPLE);
return (NULL);
}
diff --git a/src/plugins/gbp/gbp_route_domain.c b/src/plugins/gbp/gbp_route_domain.c
index ab998591982..f0aa694d44a 100644
--- a/src/plugins/gbp/gbp_route_domain.c
+++ b/src/plugins/gbp/gbp_route_domain.c
@@ -53,6 +53,7 @@ typedef struct gbp_route_domain_db_t
} gbp_route_domain_db_t;
static gbp_route_domain_db_t gbp_route_domain_db;
+static fib_source_t gbp_fib_source;
/**
* logger
@@ -154,7 +155,7 @@ gbp_route_domain_add_and_lock (u32 rd_id,
grd->grd_fib_index[fproto] =
fib_table_find_or_create_and_lock (fproto,
grd->grd_table_id[fproto],
- FIB_SOURCE_PLUGIN_HI);
+ gbp_fib_source);
if (~0 != grd->grd_uu_sw_if_index[fproto])
{
@@ -221,8 +222,7 @@ gbp_route_domain_unlock (index_t index)
FOR_EACH_FIB_IP_PROTOCOL (fproto)
{
- fib_table_unlock (grd->grd_fib_index[fproto],
- fproto, FIB_SOURCE_PLUGIN_HI);
+ fib_table_unlock (grd->grd_fib_index[fproto], fproto, gbp_fib_source);
if (INDEX_INVALID != grd->grd_adj[fproto])
adj_unlock (grd->grd_adj[fproto]);
}
@@ -430,6 +430,9 @@ static clib_error_t *
gbp_route_domain_init (vlib_main_t * vm)
{
grd_logger = vlib_log_register_class ("gbp", "rd");
+ gbp_fib_source = fib_source_allocate ("gbp-rd",
+ FIB_SOURCE_PRIORITY_HI,
+ FIB_SOURCE_BH_DROP);
return (NULL);
}
diff --git a/src/plugins/gbp/gbp_subnet.c b/src/plugins/gbp/gbp_subnet.c
index bb069ffe892..2ef3fcfd534 100644
--- a/src/plugins/gbp/gbp_subnet.c
+++ b/src/plugins/gbp/gbp_subnet.c
@@ -65,6 +65,8 @@ uword *gbp_subnet_db;
*/
gbp_subnet_t *gbp_subnet_pool;
+static fib_source_t gbp_fib_source;
+
static index_t
gbp_subnet_db_find (u32 fib_index, const fib_prefix_t * pfx)
{
@@ -122,7 +124,7 @@ gbp_subnet_transport_add (gbp_subnet_t * gs)
gs->gs_fei = fib_table_entry_update_one_path (gs->gs_key->gsk_fib_index,
&gs->gs_key->gsk_pfx,
- FIB_SOURCE_PLUGIN_HI,
+ gbp_fib_source,
FIB_ENTRY_FLAG_NONE,
fib_proto_to_dpo (fproto),
&ADJ_BCAST_ADDR,
@@ -145,7 +147,7 @@ gbp_subnet_internal_add (gbp_subnet_t * gs)
gs->gs_fei = fib_table_entry_special_dpo_update (gs->gs_key->gsk_fib_index,
&gs->gs_key->gsk_pfx,
- FIB_SOURCE_PLUGIN_HI,
+ gbp_fib_source,
FIB_ENTRY_FLAG_EXCLUSIVE,
&gfd);
@@ -169,7 +171,7 @@ gbp_subnet_external_add (gbp_subnet_t * gs, u32 sw_if_index, sclass_t sclass)
gs->gs_fei = fib_table_entry_special_dpo_update (gs->gs_key->gsk_fib_index,
&gs->gs_key->gsk_pfx,
- FIB_SOURCE_PLUGIN_HI,
+ gbp_fib_source,
(FIB_ENTRY_FLAG_EXCLUSIVE |
FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT),
&gpd);
@@ -216,7 +218,7 @@ gbp_subnet_del_i (index_t gsi)
(GBP_SUBNET_L3_OUT == gs->gs_type
|| GBP_SUBNET_ANON_L3_OUT ==
gs->gs_type) ? FIB_SOURCE_SPECIAL :
- FIB_SOURCE_PLUGIN_HI);
+ gbp_fib_source);
gbp_subnet_db_del (gs);
gbp_route_domain_unlock (gs->gs_rd);
@@ -578,6 +580,9 @@ gbp_subnet_init (vlib_main_t * vm)
{
gbp_subnet_db = hash_create_mem (0,
sizeof (gbp_subnet_key_t), sizeof (u32));
+ gbp_fib_source = fib_source_allocate ("gbp-subnet",
+ FIB_SOURCE_PRIORITY_HI,
+ FIB_SOURCE_BH_SIMPLE);
return (NULL);
}