Use per-protocol default flow-hash config when the FIB table index is not known 62/6562/2
authorNeale Ranns <nranns@cisco.com>
Tue, 2 May 2017 17:15:19 +0000 (10:15 -0700)
committerDave Barach <openvpp@barachs.net>
Tue, 2 May 2017 21:53:54 +0000 (21:53 +0000)
Change-Id: If088e75801831befc6bddb77ea20abe9288b93c4
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/vnet/fib/fib_entry_src.c
src/vnet/fib/fib_table.c
src/vnet/fib/fib_table.h

index fd80497..ab72565 100644 (file)
@@ -447,9 +447,24 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
         else
         {
             flow_hash_config_t fhc;
+            fib_protocol_t fp;
 
-            fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index,
-                                                 dpo_proto_to_fib(lb_proto));
+            /*
+             * if the protocol for the LB we are building does not match that
+             * of the fib_entry (i.e. we are build the [n]EOS LB for an IPv[46]
+             * then the fib_index is not an index that relates to the table
+             * type we need. So get the default flow-hash config instead.
+             */
+            fp = dpo_proto_to_fib(lb_proto);
+
+            if (fib_entry->fe_prefix.fp_proto != fp)
+            {
+                fhc = fib_table_get_default_flow_hash_config(fp);
+            }
+            else
+            {
+                fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index, fp);
+            }
             dpo_set(dpo_lb,
                     DPO_LOAD_BALANCE,
                     lb_proto,
index d50f17f..5aa02dd 100644 (file)
@@ -951,6 +951,22 @@ fib_table_get_flow_hash_config (u32 fib_index,
 
     return (fib->ft_flow_hash_config);
 }
+flow_hash_config_t
+fib_table_get_default_flow_hash_config (fib_protocol_t proto)
+{
+    switch (proto)
+    {
+    case FIB_PROTOCOL_IP4:
+    case FIB_PROTOCOL_IP6:
+       return (IP_FLOW_HASH_DEFAULT);
+
+    case FIB_PROTOCOL_MPLS:
+       return (MPLS_FLOW_HASH_DEFAULT);
+    }
+
+    ASSERT(0);
+    return (IP_FLOW_HASH_DEFAULT);
+}
 
 /**
  * @brief Table set flow hash config context.
index 2177334..a65fea7 100644 (file)
@@ -665,6 +665,17 @@ extern u32 fib_table_create_and_lock(fib_protocol_t proto,
 extern flow_hash_config_t fib_table_get_flow_hash_config(u32 fib_index,
                                                         fib_protocol_t proto);
 
+/**
+ * @brief
+ *  Get the flow hash configured used by the protocol
+ *
+ * @paran proto
+ *  The protocol of the FIB (and thus the entries therein)
+ *
+ * @return The flow hash config
+ */
+extern flow_hash_config_t fib_table_get_default_flow_hash_config(fib_protocol_t proto);
+
 /**
  * @brief
  *  Set the flow hash configured used by the table