FIB: store the node type not the function pointer.
[vpp.git] / src / vnet / fib / fib_entry.c
index cdebfbc..35716ca 100644 (file)
@@ -58,12 +58,18 @@ fib_entry_get_index (const fib_entry_t * fib_entry)
     return (fib_entry - fib_entry_pool);
 }
 
-static fib_protocol_t
+fib_protocol_t
 fib_entry_get_proto (const fib_entry_t * fib_entry)
 {
     return (fib_entry->fe_prefix.fp_proto);
 }
 
+dpo_proto_t
+fib_entry_get_dpo_proto (const fib_entry_t * fib_entry)
+{
+    return (fib_proto_to_dpo(fib_entry->fe_prefix.fp_proto));
+}
+
 fib_forward_chain_type_t
 fib_entry_get_default_chain_type (const fib_entry_t *fib_entry)
 {
@@ -83,6 +89,16 @@ fib_entry_get_default_chain_type (const fib_entry_t *fib_entry)
     return (FIB_FORW_CHAIN_TYPE_UNICAST_IP4);
 }
 
+u8 *
+format_fib_source (u8 * s, va_list * args)
+{
+    fib_source_t source = va_arg (*args, int);
+
+    s = format (s, "src:%s", fib_source_names[source]);
+
+    return (s);
+}
+
 u8 *
 format_fib_entry (u8 * s, va_list * args)
 {
@@ -108,8 +124,7 @@ format_fib_entry (u8 * s, va_list * args)
 
        FOR_EACH_SRC_ADDED(fib_entry, src, source,
         ({
-           s = format (s, "\n  src:%s ",
-                       fib_source_names[source]);
+           s = format (s, "\n  %U", format_fib_source, source);
            s = fib_entry_src_format(fib_entry, source, s);
            s = format (s, " refs:%d ", src->fes_ref_count);
            if (FIB_ENTRY_FLAG_NONE != src->fes_entry_flags) {
@@ -176,9 +191,7 @@ format_fib_entry (u8 * s, va_list * args)
 static fib_entry_t*
 fib_entry_from_fib_node (fib_node_t *node)
 {
-#if CLIB_DEBUG > 0
     ASSERT(FIB_NODE_TYPE_ENTRY == node->fn_type);
-#endif
     return ((fib_entry_t*)node);
 }
 
@@ -379,6 +392,7 @@ fib_entry_chain_type_mcast_to_ucast (fib_forward_chain_type_t fct)
     case FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS:
     case FIB_FORW_CHAIN_TYPE_ETHERNET:
     case FIB_FORW_CHAIN_TYPE_NSH:
+    case FIB_FORW_CHAIN_TYPE_BIER:
         break;
     }
 
@@ -462,11 +476,15 @@ fib_entry_get_adj (fib_node_index_t fib_entry_index)
     const dpo_id_t *dpo;
 
     dpo = fib_entry_contribute_ip_forwarding(fib_entry_index);
-    dpo = load_balance_get_bucket(dpo->dpoi_index, 0);
 
-    if (dpo_is_adj(dpo))
+    if (dpo_id_is_valid(dpo))
     {
-       return (dpo->dpoi_index);
+        dpo = load_balance_get_bucket(dpo->dpoi_index, 0);
+
+        if (dpo_is_adj(dpo))
+        {
+            return (dpo->dpoi_index);
+        }
     }
     return (ADJ_INDEX_INVALID);
 }
@@ -1369,7 +1387,7 @@ fib_entry_is_resolved (fib_node_index_t fib_entry_index)
     if (NULL == fed)
     {
         /*
-         * no BFD tracking - resolved
+         * no BFD tracking - consider it resolved.
          */
         return (!0);
     }