summaryrefslogtreecommitdiffstats
path: root/src/vnet/mpls/interface.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-09-10 04:39:11 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-09-11 10:14:36 +0000
commit1500254bee11355bbd69cc1dd9705be4f002f2bd (patch)
treec403642105f399baccb3a727020232b5732fe8f7 /src/vnet/mpls/interface.c
parenta7191840beeb2c3a0f2598707ed1051a9f23c45f (diff)
FIB table add/delete API
part 2; - this adds the code to create an IP and MPLS table via the API. - but the enforcement that the table must be created before it is used is still missing, this is so that CSIT can pass. Change-Id: Id124d884ade6cb7da947225200e3bb193454c555 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/mpls/interface.c')
-rw-r--r--src/vnet/mpls/interface.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/vnet/mpls/interface.c b/src/vnet/mpls/interface.c
index a085aaa2f19..d7c8e7d340e 100644
--- a/src/vnet/mpls/interface.c
+++ b/src/vnet/mpls/interface.c
@@ -35,25 +35,33 @@ mpls_sw_interface_is_enabled (u32 sw_if_index)
return (mm->mpls_enabled_by_sw_if_index[sw_if_index]);
}
-void
+int
mpls_sw_interface_enable_disable (mpls_main_t * mm,
u32 sw_if_index,
- u8 is_enable)
+ u8 is_enable,
+ u8 is_api)
{
fib_node_index_t lfib_index;
vec_validate_init_empty (mm->mpls_enabled_by_sw_if_index, sw_if_index, 0);
+ lfib_index = fib_table_find(FIB_PROTOCOL_MPLS,
+ MPLS_FIB_DEFAULT_TABLE_ID);
+
+ if (~0 == lfib_index)
+ return VNET_API_ERROR_NO_SUCH_FIB;
+
/*
* enable/disable only on the 1<->0 transition
*/
if (is_enable)
{
if (1 != ++mm->mpls_enabled_by_sw_if_index[sw_if_index])
- return;
+ return (0);
+
+ fib_table_lock(lfib_index, FIB_PROTOCOL_MPLS,
+ (is_api? FIB_SOURCE_API: FIB_SOURCE_CLI));
- lfib_index = fib_table_find_or_create_and_lock(FIB_PROTOCOL_MPLS,
- MPLS_FIB_DEFAULT_TABLE_ID);
vec_validate(mm->fib_index_by_sw_if_index, 0);
mm->fib_index_by_sw_if_index[sw_if_index] = lfib_index;
}
@@ -61,15 +69,17 @@ mpls_sw_interface_enable_disable (mpls_main_t * mm,
{
ASSERT(mm->mpls_enabled_by_sw_if_index[sw_if_index] > 0);
if (0 != --mm->mpls_enabled_by_sw_if_index[sw_if_index])
- return;
+ return (0);
fib_table_unlock(mm->fib_index_by_sw_if_index[sw_if_index],
- FIB_PROTOCOL_MPLS);
+ FIB_PROTOCOL_MPLS,
+ (is_api? FIB_SOURCE_API: FIB_SOURCE_CLI));
}
vnet_feature_enable_disable ("mpls-input", "mpls-not-enabled",
sw_if_index, !is_enable, 0, 0);
+ return (0);
}
static clib_error_t *
@@ -101,7 +111,7 @@ mpls_interface_enable_disable (vlib_main_t * vm,
goto done;
}
- mpls_sw_interface_enable_disable(&mpls_main, sw_if_index, enable);
+ mpls_sw_interface_enable_disable(&mpls_main, sw_if_index, enable, 0);
done:
return error;