X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fgre%2Finterface.c;h=b9bfb79c172393a7d90df853e648a4fb9b30e017;hb=refs%2Fchanges%2F31%2F17631%2F2;hp=5b165c858d3e3289145cb9db214748cedb7949d8;hpb=25d417f28680c78a709792d997884dd80227bb70;p=vpp.git diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c index 5b165c858d3..b9bfb79c172 100644 --- a/src/vnet/gre/interface.c +++ b/src/vnet/gre/interface.c @@ -24,6 +24,7 @@ #include #include #include +#include static const char *gre_tunnel_type_names[] = GRE_TUNNEL_TYPE_NAMES; @@ -135,7 +136,7 @@ gre_tunnel_stack (adj_index_t ai) adj = adj_get (ai); sw_if_index = adj->rewrite_header.sw_if_index; - if ((vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index) || + if ((vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index) || (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index])) return; @@ -146,44 +147,14 @@ gre_tunnel_stack (adj_index_t ai) VNET_HW_INTERFACE_FLAG_LINK_UP) == 0) { adj_nbr_midchain_unstack (ai); - return; } - - dpo_id_t tmp = DPO_INVALID; - fib_forward_chain_type_t fib_fwd = (FIB_PROTOCOL_IP6 == adj->ia_nh_proto) ? - FIB_FORW_CHAIN_TYPE_UNICAST_IP6 : FIB_FORW_CHAIN_TYPE_UNICAST_IP4; - - fib_entry_contribute_forwarding (gt->fib_entry_index, fib_fwd, &tmp); - if (DPO_LOAD_BALANCE == tmp.dpoi_type) + else { - /* - * post GRE rewrite we will load-balance. However, the GRE encap - * is always the same for this adjacency/tunnel and hence the IP/GRE - * src,dst hash is always the same result too. So we do that hash now and - * stack on the choice. - * If the choice is an incomplete adj then we will need a poke when - * it becomes complete. This happens since the adj update walk propagates - * as far a recursive paths. - */ - const dpo_id_t *choice; - load_balance_t *lb; - int hash; - - lb = load_balance_get (tmp.dpoi_index); - - if (fib_fwd == FIB_FORW_CHAIN_TYPE_UNICAST_IP4) - hash = ip4_compute_flow_hash ((ip4_header_t *) adj_get_rewrite (ai), - lb->lb_hash_config); - else - hash = ip6_compute_flow_hash ((ip6_header_t *) adj_get_rewrite (ai), - lb->lb_hash_config); - choice = - load_balance_get_bucket_i (lb, hash & lb->lb_n_buckets_minus_1); - dpo_copy (&tmp, choice); + adj_nbr_midchain_stack_on_fib_entry (ai, + gt->fib_entry_index, + fib_forw_chain_type_from_fib_proto + (gt->tunnel_dst.fp_proto)); } - - adj_nbr_midchain_stack (ai, &tmp); - dpo_reset (&tmp); } /** @@ -280,7 +251,7 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a, return VNET_API_ERROR_IF_ALREADY_EXISTS; pool_get_aligned (gm->tunnels, t, CLIB_CACHE_LINE_BYTES); - memset (t, 0, sizeof (*t)); + clib_memset (t, 0, sizeof (*t)); /* Reconcile the real dev_instance and a possible requested instance */ u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */ @@ -348,11 +319,8 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a, 64 + sizeof (gre_header_t) + sizeof (ip6_header_t); } - hi->per_packet_overhead_bytes = - /* preamble */ 8 + /* inter frame gap */ 12; - /* Standard default gre MTU. */ - hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] = 9000; + vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000); /* * source the FIB entry for the tunnel's destination @@ -425,7 +393,8 @@ vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a, vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ ); /* make sure tunnel is removed from l2 bd or xconnect */ - set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0, 0, 0, 0); + set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0, + L2_BD_PORT_TYPE_NORMAL, 0, 0); gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0; if (t->type == GRE_TUNNEL_TYPE_L3) @@ -607,7 +576,7 @@ create_gre_tunnel_command_fn (vlib_main_t * vm, goto done; } - memset (a, 0, sizeof (*a)); + clib_memset (a, 0, sizeof (*a)); a->is_add = is_add; a->outer_fib_id = outer_fib_id; a->tunnel_type = t_type;