L3 cross connect
[vpp.git] / src / vnet / fib / fib_path_list.c
index 4655c68..47170ad 100644 (file)
 #include <vnet/fib/fib_node_list.h>
 #include <vnet/fib/fib_walk.h>
 #include <vnet/fib/fib_urpf_list.h>
+#include <vnet/fib/fib_path_ext.h>
+#include <vnet/fib/fib_table.h>
 
 /**
  * The magic number of child entries that make a path-list popular.
  * There's a trade-off here between convergnece and forwarding speed.
- * Popular path-lists generate load-balance maps for the entires that
+ * Popular path-lists generate load-balance maps for the entries that
  * use them. If the map is present there is a switch path cost to indirect
  * through the map - this indirection provides the fast convergence - so
  * without the map convergence is slower.
@@ -363,10 +365,12 @@ fib_path_list_mk_lb (fib_path_list_t *path_list,
                     dpo_id_t *dpo,
                      fib_path_list_fwd_flags_t flags)
 {
-    load_balance_path_t *nhs;
     fib_node_index_t *path_index;
+    load_balance_path_t *nhs;
+    dpo_proto_t dproto;
 
     nhs = NULL;
+    dproto = fib_forw_chain_type_to_dpo_proto(fct);
 
     /*
      * We gather the DPOs from resolved paths.
@@ -387,10 +391,11 @@ fib_path_list_mk_lb (fib_path_list_t *path_list,
      */
     dpo_set(dpo,
             DPO_LOAD_BALANCE,
-            fib_forw_chain_type_to_dpo_proto(fct),
+            dproto,
             load_balance_create(vec_len(nhs),
-                                fib_forw_chain_type_to_dpo_proto(fct),
-                                0 /* FIXME FLOW HASH */));
+                                dproto,
+                                fib_table_get_default_flow_hash_config(
+                                    dpo_proto_to_fib(dproto))));
     load_balance_multipath_update(dpo, nhs,
                                   fib_path_list_fwd_flags_2_load_balance(flags));
 
@@ -542,7 +547,7 @@ fib_path_list_alloc (fib_node_index_t *path_list_index)
     fib_path_list_t *path_list;
 
     pool_get(fib_path_list_pool, path_list);
-    memset(path_list, 0, sizeof(*path_list));
+    clib_memset(path_list, 0, sizeof(*path_list));
 
     fib_node_init(&path_list->fpl_node,
                  FIB_NODE_TYPE_PATH_LIST);
@@ -722,7 +727,7 @@ fib_path_list_create (fib_path_list_flags_t flags,
        if (FIB_NODE_INDEX_INVALID != old_path_list_index)
        {
            fib_path_list_destroy(path_list);
-       
+
            path_list_index = old_path_list_index;
        }
        else
@@ -747,7 +752,7 @@ fib_path_list_create (fib_path_list_flags_t flags,
     return (path_list_index);
 }
 
-static fib_path_cfg_flags_t 
+static fib_path_cfg_flags_t
 fib_path_list_flags_2_path_flags (fib_path_list_flags_t plf)
 {
     fib_path_cfg_flags_t pf = FIB_PATH_CFG_FLAG_NONE;
@@ -1343,6 +1348,29 @@ fib_path_list_walk (fib_node_index_t path_list_index,
     }
 }
 
+void
+fib_path_list_walk_w_ext (fib_node_index_t path_list_index,
+                          const fib_path_ext_list_t *ext_list,
+                          fib_path_list_walk_w_ext_fn_t func,
+                          void *ctx)
+{
+    fib_node_index_t *path_index;
+    fib_path_list_t *path_list;
+    fib_path_ext_t *path_ext;
+
+    path_list = fib_path_list_get(path_list_index);
+
+    vec_foreach(path_index, path_list->fpl_paths)
+    {
+        path_ext = fib_path_ext_list_find_by_path_index(ext_list, *path_index);
+
+        if (FIB_PATH_LIST_WALK_STOP == func(path_list_index,
+                                            *path_index,
+                                            path_ext,
+                                            ctx))
+            break;
+    }
+}
 
 void
 fib_path_list_module_init (void)