Attached hosts
[vpp.git] / src / vnet / fib / fib_entry_src.c
index 060fac9..aa1d5a2 100644 (file)
@@ -266,6 +266,7 @@ fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
 {
     fib_entry_src_collect_forwarding_ctx_t *ctx;
     fib_path_ext_t *path_ext;
+    int have_path_ext;
 
     ctx = arg;
 
@@ -285,14 +286,17 @@ fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
     /*
      * get the matching path-extension for the path being visited.
      */
+    have_path_ext = 0;
     vec_foreach(path_ext, ctx->esrc->fes_path_exts)
     {
         if (path_ext->fpe_path_index == path_index)
+        {
+            have_path_ext = 1;
             break;
+        }
     }
     
-    if (NULL != path_ext &&
-        path_ext->fpe_path_index == path_index &&
+    if (have_path_ext &&
         fib_entry_src_valid_out_label(path_ext->fpe_label_stack[0]))
     {
         /*
@@ -313,6 +317,8 @@ fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
         {
         case FIB_FORW_CHAIN_TYPE_UNICAST_IP4:
         case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
+        case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
+        case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
             /*
              * EOS traffic with no label to stack, we need the IP Adj
              */
@@ -353,6 +359,7 @@ fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
             break;
         }
         case FIB_FORW_CHAIN_TYPE_ETHERNET:
+        case FIB_FORW_CHAIN_TYPE_NSH:
            ASSERT(0);
            break;
         }
@@ -382,6 +389,14 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
         .fct = fct,
     };
 
+    /*
+     * As an optimisation we allocate the vector of next-hops to be sized
+     * equal to the maximum nuber of paths we will need, which is also the
+     * most likely number we will need, since in most cases the paths are 'up'.
+     */
+    vec_validate(ctx.next_hops, fib_path_list_get_n_paths(esrc->fes_pl));
+    vec_reset_length(ctx.next_hops);
+
     lb_proto = fib_proto_to_dpo(fib_entry->fe_prefix.fp_proto);
 
     fib_path_list_walk(esrc->fes_pl,
@@ -431,8 +446,9 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
      */
     index_t ui = fib_path_list_get_urpf(esrc->fes_pl);
 
-    if (fib_entry_is_sourced(fib_entry_get_index(fib_entry),
-                            FIB_SOURCE_URPF_EXEMPT) &&
+    if ((fib_entry_is_sourced(fib_entry_get_index(fib_entry),
+                             FIB_SOURCE_URPF_EXEMPT) ||
+        (esrc->fes_entry_flags & FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT))&&
        (0 == fib_urpf_check_size(ui)))
     {
        /*
@@ -450,6 +466,8 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
     {
        load_balance_set_urpf(dpo_lb->dpoi_index, ui);
     }
+    load_balance_set_fib_entry_flags(dpo_lb->dpoi_index,
+                                     fib_entry_get_flags_i(fib_entry));
 }
 
 void
@@ -928,6 +946,10 @@ fib_path_is_attached (const fib_route_path_t *rpath)
     {
        return (!0);
     }
+    else if (rpath->frp_flags & FIB_ROUTE_PATH_ATTACHED)
+    {
+        return (!0);
+    }
     return (0);
 }