aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorIJsbrand Wijnands <ice@cisco.com>2020-03-05 10:56:26 -0800
committerNeale Ranns <nranns@cisco.com>2020-03-10 13:47:10 +0000
commit39ae0a07ac17640a7f8ba136eaaf334bfd504030 (patch)
treec6c19f469f2b4d75ac54b890eda6a0dc3610ac30 /src/vnet
parent287d5e109a93f14490f38bdbe34b6741af436984 (diff)
mpls: add user defined name tag to mpls tunnels
This allows a user creating MPLS tunnel through the bin_api to add a name tag. This is useful to correlate the Tunnel with its use-case. Also useful if the user needs to recover the MPLS Tunnel after a restart (mark-sweep). Type: feature Change-Id: Signed-off-by: IJsbrand Wijnands <ice@cisco.com> Change-Id: Idc080a63810a176ab090a2678a73d2cf9f7b523f
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/mpls/mpls.api2
-rw-r--r--src/vnet/mpls/mpls_api.c4
-rw-r--r--src/vnet/mpls/mpls_tunnel.c9
-rw-r--r--src/vnet/mpls/mpls_tunnel.h8
4 files changed, 19 insertions, 4 deletions
diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api
index 920479eff6c..25aa1c645af 100644
--- a/src/vnet/mpls/mpls.api
+++ b/src/vnet/mpls/mpls.api
@@ -46,9 +46,11 @@ typedef mpls_tunnel
u32 mt_tunnel_index;
bool mt_l2_only;
bool mt_is_multicast;
+ string mt_tag[64];
u8 mt_n_paths;
vl_api_fib_path_t mt_paths[mt_n_paths];
};
+
define mpls_tunnel_add_del
{
u32 client_index;
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index 0185e373a41..70e8872317a 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -283,7 +283,8 @@ vl_api_mpls_tunnel_add_del_t_handler (vl_api_mpls_tunnel_add_del_t * mp)
if (~0 == tunnel_sw_if_index)
tunnel_sw_if_index =
vnet_mpls_tunnel_create (mp->mt_tunnel.mt_l2_only,
- mp->mt_tunnel.mt_is_multicast);
+ mp->mt_tunnel.mt_is_multicast,
+ mp->mt_tunnel.mt_tag);
vnet_mpls_tunnel_path_add (tunnel_sw_if_index, rpaths);
tunnel_index = vnet_mpls_tunnel_get_index (tunnel_sw_if_index);
@@ -365,6 +366,7 @@ send_mpls_tunnel_entry (u32 mti, void *arg)
mp->mt_tunnel.mt_tunnel_index = ntohl (mti);
mp->mt_tunnel.mt_l2_only = ! !(MPLS_TUNNEL_FLAG_L2 & mt->mt_flags);
mp->mt_tunnel.mt_is_multicast = ! !(MPLS_TUNNEL_FLAG_MCAST & mt->mt_flags);
+ memcpy (mp->mt_tunnel.mt_tag, mt->mt_tag, sizeof (mp->mt_tunnel.mt_tag));
fib_path_list_walk_w_ext (mt->mt_path_list,
&mt->mt_path_exts, fib_path_encode, &path_ctx);
diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c
index 3ed77e63a6a..55d814858c3 100644
--- a/src/vnet/mpls/mpls_tunnel.c
+++ b/src/vnet/mpls/mpls_tunnel.c
@@ -606,7 +606,8 @@ vnet_mpls_tunnel_del (u32 sw_if_index)
u32
vnet_mpls_tunnel_create (u8 l2_only,
- u8 is_multicast)
+ u8 is_multicast,
+ u8 *tag)
{
vnet_hw_interface_t * hi;
mpls_tunnel_t *mt;
@@ -625,6 +626,10 @@ vnet_mpls_tunnel_create (u8 l2_only,
mt->mt_flags |= MPLS_TUNNEL_FLAG_MCAST;
if (l2_only)
mt->mt_flags |= MPLS_TUNNEL_FLAG_L2;
+ if (tag)
+ memcpy(mt->mt_tag, tag, sizeof(mt->mt_tag));
+ else
+ mt->mt_tag[0] = '\0';
/*
* Create a new tunnel HW interface
@@ -858,7 +863,7 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
if (~0 == sw_if_index)
{
- sw_if_index = vnet_mpls_tunnel_create(l2_only, is_multicast);
+ sw_if_index = vnet_mpls_tunnel_create(l2_only, is_multicast, NULL);
}
vnet_mpls_tunnel_path_add(sw_if_index, rpaths);
}
diff --git a/src/vnet/mpls/mpls_tunnel.h b/src/vnet/mpls/mpls_tunnel.h
index 5685a0d8d6c..11a461b7b57 100644
--- a/src/vnet/mpls/mpls_tunnel.h
+++ b/src/vnet/mpls/mpls_tunnel.h
@@ -65,6 +65,11 @@ typedef struct mpls_tunnel_t_
mpls_tunnel_flags_t mt_flags;
/**
+ * @brief User defined name tag for this MPLS Tunnel.
+ */
+ u8 mt_tag[64];
+
+ /**
* @brief If the tunnel is an L2 tunnel, this is the link type ETHERNET
* load-balance
*/
@@ -101,7 +106,8 @@ typedef struct mpls_tunnel_t_
* @return the SW Interface index of the newly created tuneel
*/
extern u32 vnet_mpls_tunnel_create (u8 l2_only,
- u8 is_multicast);
+ u8 is_multicast,
+ u8 *description);
/**
* @brief Add a path to an MPLS tunnel