summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_entry_src_mpls.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-02-21 04:57:17 -0800
committerNeale Ranns <nranns@cisco.com>2018-03-20 23:59:06 +0000
commit2303cb181b51f63c909cd506125c1f832432865a (patch)
treeea2389593abc50790e06b6ac2e80f2a38c536942 /src/vnet/fib/fib_entry_src_mpls.c
parentf55957e71c58e38770b12af0720e9d19a8f6a8d6 (diff)
FIB Interpose Source
The interpose source allows the source/provider to insert/interpose a DPO in the forwarding chain of the FIB entry ahead of the forwarding provided by the next best source. For example if the API source (i.e the 'control plane') has provided an adjacency for forwarding, then an interpose source (e.g. a monitoring service) couold interpose a replicatte DPO to copy the traffic to another location AND forward using the API's adjacency. To use the interose feature an existing source (i.e FIB_SOURCE_PLUGIN_HI) cn specifiy as a flag FIB_ENTRY_FLAG_INTERPOSE and provide a DPO to interpose. One might also consider using interpose in conjunction with FIB_ENTRY_FLAG_COVER_INHERIT to ensure the interpose object affects all prefixes in the sub-tree. Change-Id: I8b2737b985f8f7c08123406d0491881def347b52 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_entry_src_mpls.c')
-rw-r--r--src/vnet/fib/fib_entry_src_mpls.c126
1 files changed, 62 insertions, 64 deletions
diff --git a/src/vnet/fib/fib_entry_src_mpls.c b/src/vnet/fib/fib_entry_src_mpls.c
index f80d42afbb0..32a620de713 100644
--- a/src/vnet/fib/fib_entry_src_mpls.c
+++ b/src/vnet/fib/fib_entry_src_mpls.c
@@ -22,7 +22,7 @@
#include <vnet/fib/mpls_fib.h>
/**
- * Source initialisation Function
+ * Source initialisation Function
*/
static void
fib_entry_src_mpls_init (fib_entry_src_t *src)
@@ -30,16 +30,16 @@ fib_entry_src_mpls_init (fib_entry_src_t *src)
mpls_eos_bit_t eos;
src->fes_flags = FIB_ENTRY_SRC_FLAG_NONE;
- src->mpls.fesm_label = MPLS_LABEL_INVALID;
+ src->u.mpls.fesm_label = MPLS_LABEL_INVALID;
FOR_EACH_MPLS_EOS_BIT(eos)
{
- src->mpls.fesm_lfes[eos] = FIB_NODE_INDEX_INVALID;
+ src->u.mpls.fesm_lfes[eos] = FIB_NODE_INDEX_INVALID;
}
}
/**
- * Source deinitialisation Function
+ * Source deinitialisation Function
*/
static void
fib_entry_src_mpls_deinit (fib_entry_src_t *src)
@@ -50,7 +50,7 @@ static void
fib_entry_src_mpls_remove (fib_entry_src_t *src)
{
src->fes_pl = FIB_NODE_INDEX_INVALID;
- src->mpls.fesm_label = MPLS_LABEL_INVALID;
+ src->u.mpls.fesm_label = MPLS_LABEL_INVALID;
}
static void
@@ -61,9 +61,9 @@ fib_entry_src_mpls_add (fib_entry_src_t *src,
const dpo_id_t *dpo)
{
src->fes_pl =
- fib_path_list_create_special(proto,
- FIB_PATH_LIST_FLAG_DROP,
- drop_dpo_get(proto));
+ fib_path_list_create_special(proto,
+ FIB_PATH_LIST_FLAG_DROP,
+ drop_dpo_get(proto));
}
static void
@@ -91,71 +91,71 @@ fib_entry_src_mpls_set_data (fib_entry_src_t *src,
*/
FOR_EACH_MPLS_EOS_BIT(eos)
{
- fib_table_entry_delete_index(src->mpls.fesm_lfes[eos],
- FIB_SOURCE_SPECIAL);
+ fib_table_entry_delete_index(src->u.mpls.fesm_lfes[eos],
+ FIB_SOURCE_SPECIAL);
}
fib_table_unlock(MPLS_FIB_DEFAULT_TABLE_ID,
FIB_PROTOCOL_MPLS,
FIB_SOURCE_MPLS);
- src->mpls.fesm_label = label;
+ src->u.mpls.fesm_label = label;
}
else
{
- fib_prefix_t prefix = {
- .fp_proto = FIB_PROTOCOL_MPLS,
- .fp_label = label,
- };
- fib_node_index_t fib_index;
- dpo_id_t dpo = DPO_INVALID;
+ fib_prefix_t prefix = {
+ .fp_proto = FIB_PROTOCOL_MPLS,
+ .fp_label = label,
+ };
+ fib_node_index_t fib_index;
+ dpo_id_t dpo = DPO_INVALID;
/*
* adding a new local label. make sure the MPLS fib exists.
*/
- if (MPLS_LABEL_INVALID == src->mpls.fesm_label)
+ if (MPLS_LABEL_INVALID == src->u.mpls.fesm_label)
{
fib_index =
- fib_table_find_or_create_and_lock(FIB_PROTOCOL_MPLS,
- MPLS_FIB_DEFAULT_TABLE_ID,
+ fib_table_find_or_create_and_lock(FIB_PROTOCOL_MPLS,
+ MPLS_FIB_DEFAULT_TABLE_ID,
FIB_SOURCE_MPLS);
}
- else
- {
- fib_index = mpls_fib_index_from_table_id(MPLS_FIB_DEFAULT_TABLE_ID);
-
- /*
- * if this is a change in label, reomve the old one first
- */
- if (src->mpls.fesm_label != label)
- {
- FOR_EACH_MPLS_EOS_BIT(eos)
- {
- ASSERT(FIB_NODE_INDEX_INVALID != src->mpls.fesm_lfes[eos]);
- fib_table_entry_delete_index(src->mpls.fesm_lfes[eos],
- FIB_SOURCE_SPECIAL);
- }
- }
- }
-
- src->mpls.fesm_label = label;
-
- FOR_EACH_MPLS_EOS_BIT(eos)
- {
- prefix.fp_eos = eos;
- prefix.fp_payload_proto = fib_proto_to_dpo(payload_proto);
-
- fib_entry_contribute_forwarding(fei,
- (eos ?
- FIB_FORW_CHAIN_TYPE_MPLS_EOS :
- FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS),
- &dpo);
- src->mpls.fesm_lfes[eos] =
- fib_table_entry_special_dpo_add(fib_index,
- &prefix,
- FIB_SOURCE_SPECIAL,
- FIB_ENTRY_FLAG_EXCLUSIVE,
- &dpo);
- dpo_reset(&dpo);
- }
+ else
+ {
+ fib_index = mpls_fib_index_from_table_id(MPLS_FIB_DEFAULT_TABLE_ID);
+
+ /*
+ * if this is a change in label, reomve the old one first
+ */
+ if (src->u.mpls.fesm_label != label)
+ {
+ FOR_EACH_MPLS_EOS_BIT(eos)
+ {
+ ASSERT(FIB_NODE_INDEX_INVALID != src->u.mpls.fesm_lfes[eos]);
+ fib_table_entry_delete_index(src->u.mpls.fesm_lfes[eos],
+ FIB_SOURCE_SPECIAL);
+ }
+ }
+ }
+
+ src->u.mpls.fesm_label = label;
+
+ FOR_EACH_MPLS_EOS_BIT(eos)
+ {
+ prefix.fp_eos = eos;
+ prefix.fp_payload_proto = fib_proto_to_dpo(payload_proto);
+
+ fib_entry_contribute_forwarding(fei,
+ (eos ?
+ FIB_FORW_CHAIN_TYPE_MPLS_EOS :
+ FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS),
+ &dpo);
+ src->u.mpls.fesm_lfes[eos] =
+ fib_table_entry_special_dpo_add(fib_index,
+ &prefix,
+ FIB_SOURCE_SPECIAL,
+ FIB_ENTRY_FLAG_EXCLUSIVE,
+ &dpo);
+ dpo_reset(&dpo);
+ }
}
}
@@ -163,14 +163,14 @@ static const void *
fib_entry_src_mpls_get_data (fib_entry_src_t *src,
const fib_entry_t *entry)
{
- return (&(src->mpls.fesm_label));
+ return (&(src->u.mpls.fesm_label));
}
static u8*
fib_entry_src_mpls_format (fib_entry_src_t *src,
- u8* s)
+ u8* s)
{
- return (format(s, " local-label:%d", src->mpls.fesm_label));
+ return (format(s, " local-label:%d", src->u.mpls.fesm_label));
}
const static fib_entry_src_vft_t mpls_src_vft = {
@@ -193,7 +193,5 @@ const static fib_entry_src_vft_t mpls_src_vft = {
void
fib_entry_src_mpls_register (void)
{
- fib_entry_src_register(FIB_SOURCE_MPLS, &mpls_src_vft);
+ fib_entry_src_register(FIB_SOURCE_MPLS, &mpls_src_vft);
}
-
-