X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fmpls%2Fmpls_tunnel.c;h=55b60cdb1e5c5bd2ba11712c06a5c82ecddbed04;hb=6a30b5f9182a44989e97bbc044f29adccdef09b2;hp=c2067d81b008d1c4adc27a0ef8b3cf5b52ba1b1d;hpb=31ed74407643595fdce206e9d7487108fb8b33ab;p=vpp.git diff --git a/src/vnet/mpls/mpls_tunnel.c b/src/vnet/mpls/mpls_tunnel.c index c2067d81b00..55b60cdb1e5 100644 --- a/src/vnet/mpls/mpls_tunnel.c +++ b/src/vnet/mpls/mpls_tunnel.c @@ -31,11 +31,6 @@ */ static mpls_tunnel_t *mpls_tunnel_pool; -/** - * @brief Pool of free tunnel SW indices - i.e. recycled indices - */ -static u32 * mpls_tunnel_free_hw_if_indices; - /** * @brief DB of SW index to tunnel index */ @@ -52,7 +47,7 @@ static const char *mpls_tunnel_attribute_names[] = MPLS_TUNNEL_ATTRIBUTES; static mpls_tunnel_t* mpls_tunnel_get_from_sw_if_index (u32 sw_if_index) { - if ((vec_len(mpls_tunnel_db) < sw_if_index) || + if ((vec_len(mpls_tunnel_db) <= sw_if_index) || (~0 == mpls_tunnel_db[sw_if_index])) return (NULL); @@ -129,23 +124,14 @@ mpls_tunnel_collect_forwarding (fib_node_index_t pl_index, */ path_ext->fpe_mpls_flags |= FIB_PATH_EXT_MPLS_FLAG_NO_IP_TTL_DECR; - if (NULL != path_ext) - { - /* - * found a matching extension. stack it to obtain the forwarding - * info for this path. - */ - ctx->next_hops = fib_path_ext_stack(path_ext, - ctx->fct, - ctx->fct, - ctx->next_hops); - } - else - ASSERT(0); /* - * else - * There should be a path-extenios associated with each path + * found a matching extension. stack it to obtain the forwarding + * info for this path. */ + ctx->next_hops = fib_path_ext_stack(path_ext, + ctx->fct, + ctx->fct, + ctx->next_hops); return (FIB_PATH_LIST_WALK_CONTINUE); } @@ -179,9 +165,12 @@ mpls_tunnel_mk_lb (mpls_tunnel_t *mt, 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)) { @@ -408,6 +397,7 @@ mpls_tunnel_update_adj (vnet_main_t * vnm, { case IP_LOOKUP_NEXT_ARP: case IP_LOOKUP_NEXT_GLEAN: + case IP_LOOKUP_NEXT_BCAST: adj_nbr_midchain_update_rewrite(ai, mpls_tunnel_fixup, NULL, ADJ_FLAG_NONE, @@ -602,7 +592,8 @@ vnet_mpls_tunnel_del (u32 sw_if_index) mt->mt_sibling_index); dpo_reset(&mt->mt_l2_lb); - vec_add1 (mpls_tunnel_free_hw_if_indices, mt->mt_hw_if_index); + vnet_delete_hw_interface (vnet_get_main(), mt->mt_hw_if_index); + pool_put(mpls_tunnel_pool, mt); mpls_tunnel_db[sw_if_index] = ~0; } @@ -630,27 +621,18 @@ vnet_mpls_tunnel_create (u8 l2_only, mt->mt_flags |= MPLS_TUNNEL_FLAG_L2; /* - * Create a new, or re=use and old, tunnel HW interface + * Create a new tunnel HW interface */ - if (vec_len (mpls_tunnel_free_hw_if_indices) > 0) - { - mt->mt_hw_if_index = - mpls_tunnel_free_hw_if_indices[vec_len(mpls_tunnel_free_hw_if_indices)-1]; - _vec_len (mpls_tunnel_free_hw_if_indices) -= 1; - hi = vnet_get_hw_interface (vnm, mt->mt_hw_if_index); - hi->hw_instance = mti; - hi->dev_instance = mti; - } - else - { - mt->mt_hw_if_index = vnet_register_interface( - vnm, - mpls_tunnel_class.index, - mti, - mpls_tunnel_hw_interface_class.index, - mti); - hi = vnet_get_hw_interface (vnm, mt->mt_hw_if_index); - } + mt->mt_hw_if_index = vnet_register_interface( + vnm, + mpls_tunnel_class.index, + mti, + mpls_tunnel_hw_interface_class.index, + mti); + hi = vnet_get_hw_interface (vnm, mt->mt_hw_if_index); + + /* Standard default MPLS tunnel MTU. */ + vnet_sw_interface_set_mtu (vnm, hi->sw_if_index, 9000); /* * Add the new tunnel to the tunnel DB - key:SW if index @@ -831,7 +813,11 @@ vnet_create_mpls_tunnel_command_fn (vlib_main_t * vm, if (is_del) { - if (!vnet_mpls_tunnel_path_remove(sw_if_index, rpaths)) + if (NULL == rpaths) + { + vnet_mpls_tunnel_del(sw_if_index); + } + else if (!vnet_mpls_tunnel_path_remove(sw_if_index, rpaths)) { vnet_mpls_tunnel_del(sw_if_index); } @@ -939,7 +925,7 @@ show_mpls_tunnel_command_fn (vlib_main_t * vm, else { if (pool_is_free_index(mpls_tunnel_pool, mti)) - return clib_error_return (0, "Not atunnel index %d", mti); + return clib_error_return (0, "Not a tunnel index %d", mti); mt = pool_elt_at_index(mpls_tunnel_pool, mti);