mroute routers in the stats segment
[vpp.git] / src / vnet / mfib / mfib_entry.c
index cf25b67..7427334 100644 (file)
@@ -217,7 +217,10 @@ format_mfib_entry (u8 * s, va_list * args)
     ({
         s = format(s, "\n  %U", format_mfib_itf, mfi);
     }));
-    s = format(s, "\n  RPF-ID:%d", mfib_entry->mfe_rpf_id);
+    if (MFIB_RPF_ID_NONE != mfib_entry->mfe_rpf_id)
+    {
+        s = format(s, "\n  RPF-ID:%d", mfib_entry->mfe_rpf_id);
+    }
     s = format(s, "\n  %U-chain\n  %U",
                format_fib_forw_chain_type,
                mfib_entry_get_default_chain_type(mfib_entry),
@@ -238,9 +241,7 @@ format_mfib_entry (u8 * s, va_list * args)
 static mfib_entry_t*
 mfib_entry_from_fib_node (fib_node_t *node)
 {
-#if CLIB_DEBUG > 0
     ASSERT(FIB_NODE_TYPE_MFIB_ENTRY == node->fn_type);
-#endif
     return ((mfib_entry_t*)node);
 }
 
@@ -300,7 +301,7 @@ mfib_entry_src_find (const mfib_entry_t *mfib_entry,
 
 static mfib_entry_src_t *
 mfib_entry_src_find_or_create (mfib_entry_t *mfib_entry,
-                              mfib_source_t source)
+                               mfib_source_t source)
 {
     mfib_entry_src_t *esrc;
 
@@ -334,6 +335,17 @@ mfib_entry_get_best_src (const mfib_entry_t *mfib_entry)
     return (bsrc);
 }
 
+int
+mfib_entry_is_sourced (fib_node_index_t mfib_entry_index,
+                       mfib_source_t source)
+{
+    mfib_entry_t *mfib_entry;
+
+    mfib_entry = mfib_entry_get(mfib_entry_index);
+
+    return (NULL != mfib_entry_src_find(mfib_entry, source, NULL));
+}
+
 static void
 mfib_entry_src_flush (mfib_entry_src_t *msrc)
 {
@@ -393,7 +405,7 @@ mfib_entry_alloc (u32 fib_index,
 {
     mfib_entry_t *mfib_entry;
 
-    pool_get(mfib_entry_pool, mfib_entry);
+    pool_get_aligned(mfib_entry_pool, mfib_entry, CLIB_CACHE_LINE_BYTES);
 
     fib_node_init(&mfib_entry->mfe_node,
                   FIB_NODE_TYPE_MFIB_ENTRY);
@@ -524,6 +536,7 @@ mfib_entry_src_collect_forwarding (fib_node_index_t pl_index,
     case FIB_FORW_CHAIN_TYPE_MPLS_EOS:
     case FIB_FORW_CHAIN_TYPE_ETHERNET:
     case FIB_FORW_CHAIN_TYPE_NSH:
+    case FIB_FORW_CHAIN_TYPE_BIER:
         ASSERT(0);
         break;
     }
@@ -764,18 +777,16 @@ mfib_entry_update (fib_node_index_t mfib_entry_index,
          * entry
          */
         fib_node_index_t old_pl_index;
-        fib_protocol_t fp;
+        dpo_proto_t dp;
         dpo_id_t dpo = DPO_INVALID;
 
-        fp = mfib_entry_get_proto(mfib_entry);
+        dp = fib_proto_to_dpo(mfib_entry_get_proto(mfib_entry));
         old_pl_index = msrc->mfes_pl;
 
-        dpo_set(&dpo, DPO_REPLICATE,
-                fib_proto_to_dpo(fp),
-                repi);
+        dpo_set(&dpo, DPO_REPLICATE, dp, repi);
 
         msrc->mfes_pl =
-            fib_path_list_create_special(fp,
+            fib_path_list_create_special(dp,
                                          FIB_PATH_LIST_FLAG_EXCLUSIVE,
                                          &dpo);
 
@@ -827,9 +838,9 @@ mfib_entry_path_update (fib_node_index_t mfib_entry_index,
 {
     fib_node_index_t path_index;
     mfib_path_ext_t *path_ext;
-    mfib_itf_flags_t old, new;
     mfib_entry_t *mfib_entry;
     mfib_entry_src_t *msrc;
+    mfib_itf_flags_t old;
 
     mfib_entry = mfib_entry_get(mfib_entry_index);
     ASSERT(NULL != mfib_entry);
@@ -865,37 +876,32 @@ mfib_entry_path_update (fib_node_index_t mfib_entry_index,
     {
         mfib_itf_t *mfib_itf;
 
-        new = itf_flags;
-
-        if (old != new)
+        if (old != itf_flags)
         {
-            if (MFIB_ITF_FLAG_NONE == new)
-            {
-                /*
-                 * no more interface flags on this path, remove
-                 * from the data-plane set
-                 */
-                mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
-            }
-            else if (MFIB_ITF_FLAG_NONE == old)
+            /*
+             * change of flag contributions
+             */
+            mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs,
+                                           rpath[0].frp_sw_if_index);
+
+            if (NULL == mfib_itf)
             {
-                /*
-                 * This interface is now contributing
-                 */
                 mfib_entry_itf_add(msrc,
                                    rpath[0].frp_sw_if_index,
-                                   mfib_itf_create(rpath[0].frp_sw_if_index,
-                                                   itf_flags));
+                                   mfib_itf_create(path_index, itf_flags));
             }
             else
             {
-                /*
-                 * change of flag contributions
-                 */
-                mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs,
-                                               rpath[0].frp_sw_if_index);
-                /* Seen by packets inflight */
-                mfib_itf->mfi_flags = new;
+                if (mfib_itf_update(mfib_itf,
+                                    path_index,
+                                    itf_flags))
+                {
+                    /*
+                     * no more interface flags on this path, remove
+                     * from the data-plane set
+                     */
+                    mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
+                }
             }
         }
     }
@@ -944,7 +950,21 @@ mfib_entry_path_remove (fib_node_index_t mfib_entry_index,
         mfib_path_ext_remove(msrc, path_index);
         if (~0 != rpath[0].frp_sw_if_index)
         {
-            mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
+            mfib_itf_t *mfib_itf;
+
+            mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs,
+                                           rpath[0].frp_sw_if_index);
+
+            if (mfib_itf_update(mfib_itf,
+                                path_index,
+                                MFIB_ITF_FLAG_NONE))
+            {
+                /*
+                 * no more interface flags on this path, remove
+                 * from the data-plane set
+                 */
+                mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index);
+            }
         }
     }
 
@@ -1086,6 +1106,16 @@ mfib_entry_last_lock_gone (fib_node_t *node)
     pool_put(mfib_entry_pool, mfib_entry);
 }
 
+u32
+mfib_entry_get_stats_index (fib_node_index_t fib_entry_index)
+{
+    mfib_entry_t *mfib_entry;
+
+    mfib_entry = mfib_entry_get(fib_entry_index);
+
+    return (mfib_entry->mfe_rep.dpoi_index);
+}
+
 /*
  * mfib_entry_back_walk_notify
  *
@@ -1218,6 +1248,16 @@ mfib_entry_get_fib_index (fib_node_index_t mfib_entry_index)
     return (mfib_entry->mfe_fib_index);
 }
 
+const dpo_id_t*
+mfib_entry_contribute_ip_forwarding (fib_node_index_t mfib_entry_index)
+{
+    mfib_entry_t *mfib_entry;
+
+    mfib_entry = mfib_entry_get(mfib_entry_index);
+
+    return (&mfib_entry->mfe_rep);
+}
+
 void
 mfib_entry_contribute_forwarding (fib_node_index_t mfib_entry_index,
                                   fib_forward_chain_type_t type,