vcl: add api to retrieve num bytes for tx
[vpp.git] / src / vnet / fib / fib_entry_src_adj.c
index 14bc1c4..fb46f2e 100644 (file)
@@ -125,6 +125,12 @@ static void
 fib_entry_src_adj_remove (fib_entry_src_t *src)
 {
     src->fes_pl = FIB_NODE_INDEX_INVALID;
+
+    if (FIB_NODE_INDEX_INVALID != src->u.adj.fesa_cover)
+    {
+        fib_entry_cover_untrack(fib_entry_get(src->u.adj.fesa_cover),
+                                src->u.adj.fesa_sibling);
+    }
 }
 
 /*
@@ -237,7 +243,9 @@ fib_entry_src_adj_activate (fib_entry_src_t *src,
      *   ip route add 10.0.0.0/24 Eth0
      * is attached. and we want adj-fibs to install on Eth0.
      */
-    if (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags_i(cover))
+    if (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags_i(cover) ||
+        (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags_for_source(src->u.adj.fesa_cover,
+                                                                  FIB_SOURCE_INTERFACE)))
     {
         fib_entry_src_path_list_walk_cxt_t ctx = {
             .cover_itf = fib_entry_get_resolving_interface(src->u.adj.fesa_cover),
@@ -290,7 +298,7 @@ fib_entry_src_adj_deactivate (fib_entry_src_t *src,
     fib_entry_t *cover;
 
     /*
-     * remove the depednecy on the covering entry
+     * remove the dependency on the covering entry
      */
     if (FIB_NODE_INDEX_INVALID == src->u.adj.fesa_cover)
     {
@@ -309,6 +317,7 @@ fib_entry_src_adj_deactivate (fib_entry_src_t *src,
     fib_attached_export_covered_removed(cover, fib_entry_get_index(fib_entry));
 
     src->u.adj.fesa_cover = FIB_NODE_INDEX_INVALID;
+    src->u.adj.fesa_sibling = FIB_NODE_INDEX_INVALID;
 }
 
 static u8*
@@ -339,10 +348,17 @@ fib_entry_src_adj_cover_change (fib_entry_src_t *src,
                                 const fib_entry_t *fib_entry)
 {
     fib_entry_src_cover_res_t res = {
-        .install = !0,
+        .install = 0,
         .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
     };
 
+    /*
+     * not interested in a change to the cover if the cover
+     * is not being tracked, i.e. the source is not active
+     */
+    if (FIB_NODE_INDEX_INVALID == src->u.adj.fesa_cover)
+        return res;
+
     fib_entry_src_adj_deactivate(src, fib_entry);
 
     res.install = fib_entry_src_adj_activate(src, fib_entry);
@@ -367,23 +383,27 @@ fib_entry_src_adj_cover_update (fib_entry_src_t *src,
 {
     /*
      * the cover has updated, i.e. its forwarding or flags
-     * have changed. don't decativate/activate here, since this
+     * have changed. don't deactivate/activate here, since this
      * prefix is updated during the covers walk.
      */
     fib_entry_src_cover_res_t res = {
-        .install = !0,
+        .install = 0,
         .bw_reason = FIB_NODE_BW_REASON_FLAG_NONE,
     };
     fib_entry_t *cover;
 
-    ASSERT(FIB_NODE_INDEX_INVALID != src->u.adj.fesa_cover);
-
-    cover = fib_entry_get(src->u.adj.fesa_cover);
-
-    res.install = (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags_i(cover));
+    /*
+     * If there is no cover, then the source is not active and we can ignore
+     * this update
+     */
+    if (FIB_NODE_INDEX_INVALID != src->u.adj.fesa_cover)
+    {
+        cover = fib_entry_get(src->u.adj.fesa_cover);
 
-    FIB_ENTRY_DBG(fib_entry, "adj-src-cover-updated");
+        res.install = (FIB_ENTRY_FLAG_ATTACHED & fib_entry_get_flags_i(cover));
 
+        FIB_ENTRY_DBG(fib_entry, "adj-src-cover-updated");
+    }
     return (res);
 }
 
@@ -405,5 +425,5 @@ const static fib_entry_src_vft_t adj_src_vft = {
 void
 fib_entry_src_adj_register (void)
 {
-    fib_entry_src_register(FIB_SOURCE_ADJ, &adj_src_vft);
+    fib_entry_src_behaviour_register(FIB_SOURCE_BH_ADJ, &adj_src_vft);
 }