Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
fib: Adjacency realloc during rewrite update walk (VPP-1822)
[vpp.git]
/
src
/
vnet
/
mpls
/
mpls_tunnel.c
diff --git
a/src/vnet/mpls/mpls_tunnel.c
b/src/vnet/mpls/mpls_tunnel.c
index
1d85c3b
..
3ed77e6
100644
(file)
--- a/
src/vnet/mpls/mpls_tunnel.c
+++ b/
src/vnet/mpls/mpls_tunnel.c
@@
-62,7
+62,7
@@
static u8*
mpls_tunnel_build_rewrite_i (void)
{
/*
mpls_tunnel_build_rewrite_i (void)
{
/*
- * passing the adj code a NULL rew
ir
te means 'i don't have one cos
+ * passing the adj code a NULL rew
ri
te means 'i don't have one cos
* t'other end is unresolved'. That's not the case here. For the mpls
* tunnel there are just no bytes of encap to apply in the adj. We'll impose
* the label stack once we choose a path. So return a zero length rewrite.
* t'other end is unresolved'. That's not the case here. For the mpls
* tunnel there are just no bytes of encap to apply in the adj. We'll impose
* the label stack once we choose a path. So return a zero length rewrite.
@@
-165,9
+165,12
@@
mpls_tunnel_mk_lb (mpls_tunnel_t *mt,
lb_proto = fib_forw_chain_type_to_dpo_proto(fct);
lb_proto = fib_forw_chain_type_to_dpo_proto(fct);
- fib_path_list_walk(mt->mt_path_list,
- mpls_tunnel_collect_forwarding,
- &ctx);
+ if (FIB_NODE_INDEX_INVALID != mt->mt_path_list)
+ {
+ fib_path_list_walk(mt->mt_path_list,
+ mpls_tunnel_collect_forwarding,
+ &ctx);
+ }
if (!dpo_id_is_valid(dpo_lb))
{
if (!dpo_id_is_valid(dpo_lb))
{
@@
-239,9
+242,15
@@
mpls_tunnel_stack (adj_index_t ai)
mt = mpls_tunnel_get_from_sw_if_index(sw_if_index);
mt = mpls_tunnel_get_from_sw_if_index(sw_if_index);
- if (NULL == mt)
+ if (NULL == mt
|| FIB_NODE_INDEX_INVALID == mt->mt_path_list
)
return;
return;
+ if (FIB_NODE_INDEX_INVALID == mt->mt_path_list)
+ {
+ adj_nbr_midchain_unstack(ai);
+ return;
+ }
+
/*
* while we're stacking the adj, remove the tunnel from the child list
* of the path list. this breaks a circular dependency of walk updates
/*
* while we're stacking the adj, remove the tunnel from the child list
* of the path list. this breaks a circular dependency of walk updates
@@
-367,7
+376,7
@@
mpls_tunnel_admin_up_down (vnet_main_t * vnm,
*/
static void
mpls_tunnel_fixup (vlib_main_t *vm,
*/
static void
mpls_tunnel_fixup (vlib_main_t *vm,
- ip_adjacency_t *adj,
+
const
ip_adjacency_t *adj,
vlib_buffer_t *b0,
const void*data)
{
vlib_buffer_t *b0,
const void*data)
{
@@
-606,7
+615,7
@@
vnet_mpls_tunnel_create (u8 l2_only,
vnm = vnet_get_main();
pool_get(mpls_tunnel_pool, mt);
vnm = vnet_get_main();
pool_get(mpls_tunnel_pool, mt);
- memset (mt, 0, sizeof (*mt));
+
clib_
memset (mt, 0, sizeof (*mt));
mti = mt - mpls_tunnel_pool;
fib_node_init(&mt->mt_node, FIB_NODE_TYPE_MPLS_TUNNEL);
mt->mt_path_list = FIB_NODE_INDEX_INVALID;
mti = mt - mpls_tunnel_pool;
fib_node_init(&mt->mt_node, FIB_NODE_TYPE_MPLS_TUNNEL);
mt->mt_path_list = FIB_NODE_INDEX_INVALID;
@@
-645,6
+654,7
@@
void
vnet_mpls_tunnel_path_add (u32 sw_if_index,
fib_route_path_t *rpaths)
{
vnet_mpls_tunnel_path_add (u32 sw_if_index,
fib_route_path_t *rpaths)
{
+ fib_route_path_t *rpath;
mpls_tunnel_t *mt;
u32 mti;
mpls_tunnel_t *mt;
u32 mti;
@@
-686,10
+696,13
@@
vnet_mpls_tunnel_path_add (u32 sw_if_index,
*/
fib_path_ext_list_resolve(&mt->mt_path_exts, mt->mt_path_list);
}
*/
fib_path_ext_list_resolve(&mt->mt_path_exts, mt->mt_path_list);
}
- fib_path_ext_list_insert(&mt->mt_path_exts,
- mt->mt_path_list,
- FIB_PATH_EXT_MPLS,
- rpaths);
+ vec_foreach(rpath, rpaths)
+ {
+ fib_path_ext_list_insert(&mt->mt_path_exts,
+ mt->mt_path_list,
+ FIB_PATH_EXT_MPLS,
+ rpath);
+ }
mpls_tunnel_restack(mt);
}
mpls_tunnel_restack(mt);
}
@@
-721,6
+734,7
@@
vnet_mpls_tunnel_path_remove (u32 sw_if_index,
old_pl_index = mt->mt_path_list;
old_pl_index = mt->mt_path_list;
+ fib_path_list_lock(old_pl_index);
mt->mt_path_list =
fib_path_list_copy_and_path_remove(old_pl_index,
FIB_PATH_LIST_FLAG_SHARED,
mt->mt_path_list =
fib_path_list_copy_and_path_remove(old_pl_index,
FIB_PATH_LIST_FLAG_SHARED,
@@
-732,6
+746,7
@@
vnet_mpls_tunnel_path_remove (u32 sw_if_index,
if (FIB_NODE_INDEX_INVALID == mt->mt_path_list)
{
/* no paths left */
if (FIB_NODE_INDEX_INVALID == mt->mt_path_list)
{
/* no paths left */
+ fib_path_list_unlock(old_pl_index);
return (0);
}
else
return (0);
}
else
@@
-755,11
+770,24
@@
vnet_mpls_tunnel_path_remove (u32 sw_if_index,
mt->mt_path_list);
mpls_tunnel_restack(mt);
mt->mt_path_list);
mpls_tunnel_restack(mt);
+ fib_path_list_unlock(old_pl_index);
}
return (fib_path_list_get_n_paths(mt->mt_path_list));
}
}
return (fib_path_list_get_n_paths(mt->mt_path_list));
}
+int
+vnet_mpls_tunnel_get_index (u32 sw_if_index)
+{
+ mpls_tunnel_t *mt;
+
+ mt = mpls_tunnel_get_from_sw_if_index(sw_if_index);
+
+ if (NULL == mt)
+ return (~0);
+
+ return (mt - mpls_tunnel_pool);
+}
static clib_error_t *
vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
static clib_error_t *
vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
@@
-773,7
+801,7
@@
vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm,
u32 sw_if_index = ~0, payload_proto;
clib_error_t *error = NULL;
u32 sw_if_index = ~0, payload_proto;
clib_error_t *error = NULL;
- memset(&rpath, 0, sizeof(rpath));
+
clib_
memset(&rpath, 0, sizeof(rpath));
payload_proto = DPO_PROTO_MPLS;
/* Get a line of input. */
payload_proto = DPO_PROTO_MPLS;
/* Get a line of input. */
@@
-863,7
+891,7
@@
format_mpls_tunnel (u8 * s, va_list * args)
mpls_tunnel_t *mt = va_arg (*args, mpls_tunnel_t *);
mpls_tunnel_attribute_t attr;
mpls_tunnel_t *mt = va_arg (*args, mpls_tunnel_t *);
mpls_tunnel_attribute_t attr;
- s = format(s, "mpls
_
tunnel%d: sw_if_index:%d hw_if_index:%d",
+ s = format(s, "mpls
-
tunnel%d: sw_if_index:%d hw_if_index:%d",
mt - mpls_tunnel_pool,
mt->mt_sw_if_index,
mt->mt_hw_if_index);
mt - mpls_tunnel_pool,
mt->mt_sw_if_index,
mt->mt_hw_if_index);