X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fgre%2Finterface.c;h=f2c679cb9b5cfc0371e6c8353c9d2c47c7b3ed9b;hb=a0455ffdbe9c2765d61d8c8efb7bb73f998ffb5b;hp=5e8ad461d934dd71308d6b2612d4b8a7e04556f7;hpb=59b792ffb1d77309b0ab17e441fd14237adb74db;p=vpp.git diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c index 5e8ad461d93..f2c679cb9b5 100644 --- a/src/vnet/gre/interface.c +++ b/src/vnet/gre/interface.c @@ -155,6 +155,45 @@ gre_tunnel_stack (adj_index_t ai) } } +/** + * mgre_tunnel_stack + * + * 'stack' (resolve the recursion for) the tunnel's midchain adjacency + */ +static void +mgre_tunnel_stack (adj_index_t ai) +{ + gre_main_t *gm = &gre_main; + const ip_adjacency_t *adj; + const gre_tunnel_t *gt; + u32 sw_if_index; + + 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) || + (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index])) + return; + + gt = pool_elt_at_index (gm->tunnels, + gm->tunnel_index_by_sw_if_index[sw_if_index]); + + if ((vnet_hw_interface_get_flags (vnet_get_main (), gt->hw_if_index) & + VNET_HW_INTERFACE_FLAG_LINK_UP) == 0) + { + adj_midchain_delegate_unstack (ai); + } + else + { + const teib_entry_t *ne; + + ne = teib_entry_find_46 (sw_if_index, adj->ia_nh_proto, + &adj->sub_type.nbr.next_hop); + if (NULL != ne) + teib_entry_adj_stack (ne, ai); + } +} + /** * @brief Call back when restacking all adjacencies on a GRE interface */ @@ -165,6 +204,13 @@ gre_adj_walk_cb (adj_index_t ai, void *ctx) return (ADJ_WALK_RC_CONTINUE); } +static adj_walk_rc_t +mgre_adj_walk_cb (adj_index_t ai, void *ctx) +{ + mgre_tunnel_stack (ai); + + return (ADJ_WALK_RC_CONTINUE); +} static void gre_tunnel_restack (gre_tunnel_t * gt) @@ -176,7 +222,15 @@ gre_tunnel_restack (gre_tunnel_t * gt) */ FOR_EACH_FIB_IP_PROTOCOL (proto) { - adj_nbr_walk (gt->sw_if_index, proto, gre_adj_walk_cb, NULL); + switch (gt->mode) + { + case TUNNEL_MODE_P2P: + adj_nbr_walk (gt->sw_if_index, proto, gre_adj_walk_cb, NULL); + break; + case TUNNEL_MODE_MP: + adj_nbr_walk (gt->sw_if_index, proto, mgre_adj_walk_cb, NULL); + break; + } } } @@ -742,10 +796,10 @@ show_gre_tunnel_command_fn (vlib_main_t * vm, if (~0 == ti) { /* *INDENT-OFF* */ - pool_foreach (t, gm->tunnels, - ({ + pool_foreach (t, gm->tunnels) + { vlib_cli_output (vm, "%U", format_gre_tunnel, t); - })); + } /* *INDENT-ON* */ } else