BIER
[vpp.git] / src / vnet / fib / fib_entry_src.c
index 8c50828..667aa48 100644 (file)
  */
 static fib_entry_src_vft_t fib_entry_src_vft[FIB_SOURCE_MAX];
 
-static fib_protocol_t
-fib_entry_get_proto (const fib_entry_t * fib_entry)
-{
-    return (fib_entry->fe_prefix.fp_proto);
-}
-
 void
 fib_entry_src_register (fib_source_t source,
                        const fib_entry_src_vft_t *vft)
@@ -193,6 +187,7 @@ typedef struct fib_entry_src_collect_forwarding_ctx_t_
     const fib_entry_src_t *esrc;
     fib_forward_chain_type_t fct;
     int n_recursive_constrained;
+    u16 preference;
 } fib_entry_src_collect_forwarding_ctx_t;
 
 /**
@@ -280,6 +275,7 @@ fib_entry_src_get_path_forwarding (fib_node_index_t path_index,
     case FIB_FORW_CHAIN_TYPE_UNICAST_IP6:
     case FIB_FORW_CHAIN_TYPE_MCAST_IP4:
     case FIB_FORW_CHAIN_TYPE_MCAST_IP6:
+    case FIB_FORW_CHAIN_TYPE_BIER:
         /*
          * EOS traffic with no label to stack, we need the IP Adj
          */
@@ -351,6 +347,22 @@ fib_entry_src_collect_forwarding (fib_node_index_t pl_index,
     {
         ctx->n_recursive_constrained += 1;
     }
+    if (0xffff == ctx->preference)
+    {
+        /*
+         * not set a preference yet, so the first path we encounter
+         * sets the preference we are collecting.
+         */
+        ctx->preference = fib_path_get_preference(path_index);
+    }
+    else if (ctx->preference != fib_path_get_preference(path_index))
+    {
+        /*
+         * this path does not belong to the same preference as the
+         * previous paths encountered. we are done now.
+         */
+        return (FIB_PATH_LIST_WALK_STOP);
+    }
 
     /*
      * get the matching path-extension for the path being visited.
@@ -422,6 +434,7 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
         .next_hops = NULL,
         .n_recursive_constrained = 0,
         .fct = fct,
+        .preference = 0xffff,
     };
 
     /*
@@ -468,8 +481,8 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
         }
         else
         {
+            fib_protocol_t flow_hash_proto;
             flow_hash_config_t fhc;
-            fib_protocol_t fp;
 
             /*
              * if the protocol for the LB we are building does not match that
@@ -477,16 +490,17 @@ fib_entry_src_mk_lb (fib_entry_t *fib_entry,
              * 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)
+            flow_hash_proto = dpo_proto_to_fib(lb_proto);
+            if (fib_entry->fe_prefix.fp_proto != flow_hash_proto)
             {
-                fhc = fib_table_get_default_flow_hash_config(fp);
+                fhc = fib_table_get_default_flow_hash_config(flow_hash_proto);
             }
             else
             {
-                fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index, fp);
+                fhc = fib_table_get_flow_hash_config(fib_entry->fe_fib_index,
+                                                     flow_hash_proto);
             }
+
             dpo_set(dpo_lb,
                     DPO_LOAD_BALANCE,
                     lb_proto,
@@ -843,7 +857,7 @@ fib_entry_src_action_add (fib_entry_t *fib_entry,
        fib_entry_src_vft[source].fesv_add(esrc,
                                           fib_entry,
                                           flags,
-                                          fib_entry_get_proto(fib_entry),
+                                           fib_entry_get_dpo_proto(fib_entry),
                                           dpo);
     }
 
@@ -896,7 +910,7 @@ fib_entry_src_action_update (fib_entry_t *fib_entry,
        fib_entry_src_vft[source].fesv_add(esrc,
                                           fib_entry,
                                           flags,
-                                          fib_entry_get_proto(fib_entry),
+                                          fib_entry_get_dpo_proto(fib_entry),
                                           dpo);
     }
 
@@ -1088,8 +1102,7 @@ fib_entry_src_action_path_add (fib_entry_t *fib_entry,
                                      source,
                                      flags,
                                      drop_dpo_get(
-                                         fib_proto_to_dpo(
-                                             fib_entry_get_proto(fib_entry))));
+                                         fib_entry_get_dpo_proto(fib_entry)));
        esrc = fib_entry_src_find(fib_entry, source, NULL);
     }
 
@@ -1148,8 +1161,7 @@ fib_entry_src_action_path_swap (fib_entry_t *fib_entry,
                                             source,
                                             flags,
                                              drop_dpo_get(
-                                                 fib_proto_to_dpo(
-                                                     fib_entry_get_proto(fib_entry))));
+                                                 fib_entry_get_dpo_proto(fib_entry)));
        esrc = fib_entry_src_find(fib_entry, source, NULL);
     }