]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CLI: fix channel stats display
authorMaria Matejka <mq@ucw.cz>
Fri, 27 Dec 2024 14:12:32 +0000 (15:12 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 1 Apr 2025 08:24:52 +0000 (10:24 +0200)
The overall number of updates/withdrawals received, as well as
the number of routes limited, were not updated.

nest/proto.c
nest/protocol.h
nest/rt-export.c
nest/rt-table.c

index 99217dae58affc1615fd476eb82adaa15b4f8136..61d2b3df244a498302426361216ac298c470f49c 100644 (file)
@@ -2595,20 +2595,20 @@ channel_show_stats(struct channel *c)
     cli_msg(-1006, "    Routes:         %u imported, %u exported, %u preferred",
            in_routes, out_routes, SRI(pref));
 
-  cli_msg(-1006, "    Route change stats:     received   rejected   filtered    ignored   RX limit   IN limit   accepted");
+  cli_msg(-1006, "    Route change stats:     received   rejected   filtered    ignored   RX limit      limit   accepted");
   cli_msg(-1006, "      Import updates:     %10u %10u %10u %10u %10u %10u %10u",
          SCI(updates_received), SCI(updates_invalid),
          SCI(updates_filtered), SRI(updates_ignored),
          SCI(updates_limited_rx), SCI(updates_limited_in),
          SRI(updates_accepted));
-  cli_msg(-1006, "      Import withdraws:   %10u %10u        --- %10u        --- %10u",
+  cli_msg(-1006, "      Import withdraws:   %10u %10u        --- %10u        ---        --- %10u",
          SCI(withdraws_received), SCI(withdraws_invalid),
          SRI(withdraws_ignored), SRI(withdraws_accepted));
-  cli_msg(-1006, "      Export updates:     %10u %10u %10u        --- %10u %10u",
-         SRE(updates_received), SCE(updates_rejected),
-         SCE(updates_filtered), SCE(updates_limited), SCE(updates_accepted));
-  cli_msg(-1006, "      Export withdraws:   %10u        ---        ---        ---         ---%10u",
-         SRE(withdraws_received), SCE(withdraws_accepted));
+  cli_msg(-1006, "      Export updates:     %10u %10u %10u %10u        --- %10u %10u",
+         SRE(updates_received), SCE(updates_rejected), SCE(updates_filtered),
+         SCE(updates_ignored), SCE(updates_limited), SCE(updates_accepted));
+  cli_msg(-1006, "      Export withdraws:   %10u        ---        --- %10u        ---        --- %10u",
+         SRE(withdraws_received), SCE(withdraws_ignored), SCE(withdraws_accepted));
 
 #undef SRI
 #undef SRE
index 3ff082803948bfd24542a86f7840039829b13d36..cb506bf3753d33b57f47d9b60e9b9d69a32e2a7e 100644 (file)
@@ -644,10 +644,12 @@ struct channel {
 
   struct channel_export_stats {
     /* Export - from core to protocol */
+    u32 updates_ignored;               /* Number of route updates ignored (squashed) by channel */
     u32 updates_rejected;              /* Number of route updates rejected by protocol */
     u32 updates_filtered;              /* Number of route updates rejected by filters */
     u32 updates_accepted;              /* Number of route updates accepted and exported */
     u32 updates_limited;               /* Number of route updates exceeding the out_limit */
+    u32 withdraws_ignored;             /* Number of route withdraws ignored (squashed) by channel */
     u32 withdraws_accepted;            /* Number of route withdraws accepted and processed */
   } export_stats;
 
index 0b626b04c779a324da258e087cb0d1aa48b3a983..7df334a876723a553f9c7ddd55cd340a1f9b7c7b 100644 (file)
@@ -104,6 +104,7 @@ rt_export_get(struct rt_export_request *r)
       {
        /* Feeding more */
        rtex_trace(r, D_ROUTES, "Feeding %N", feed->ni->addr);
+       r->stats.updates_received += feed->count_routes;
        EXPORT_FOUND(RT_EXPORT_FEED);
       }
       else if (rt_export_get_state(r) == TES_DOWN)
@@ -158,12 +159,18 @@ rt_export_get(struct rt_export_request *r)
 
       ASSERT_DIE(feed && (feed != &rt_feed_index_out_of_range));
 
+      r->stats.updates_received += feed->count_routes;
       EXPORT_FOUND(RT_EXPORT_FEED);
     }
 
     /* OK, now this actually is an update, thank you for your patience */
     rtex_trace(r, D_ROUTES, "Updating %N, seq %lu", n, update->seq);
 
+    if (update->new)
+      r->stats.updates_received++;
+    else
+      r->stats.withdraws_received++;
+
     EXPORT_FOUND(RT_EXPORT_UPDATE);
   }
 
index 2d6cb5bf6c5b7b6f7bca69b9b86b32e51ca5ad39..91199ebbd60e42e6e4c57fdff4fbf4734b849848 100644 (file)
@@ -1131,7 +1131,7 @@ do_rt_notify(struct channel *c, const net_addr *net, rte *new, const rte *old)
   if (!old && new)
     if (CHANNEL_LIMIT_PUSH(c, OUT))
     {
-      stats->updates_rejected++;
+      stats->updates_limited++;
       channel_rte_trace_out(D_FILTERS, c, new, "rejected [limit]");
       return;
     }
@@ -1165,6 +1165,10 @@ rt_notify_basic(struct channel *c, const rte *new, const rte *old)
 {
   const rte *trte = new ?: old;
 
+  /* Have we exported the old route? */
+  if (old && !bmap_test(&c->export_accepted_map, old->id))
+    old = NULL;
+
   /* Ignore invalid routes */
   if (!rte_is_valid(new))
     new = NULL;
@@ -1175,6 +1179,7 @@ rt_notify_basic(struct channel *c, const rte *new, const rte *old)
   if (!new && !old)
   {
     channel_rte_trace_out(D_ROUTES, c, trte, "idempotent withdraw (filtered on import)");
+    c->export_stats.withdraws_ignored++;
     return;
   }
 
@@ -1211,6 +1216,7 @@ rt_notify_basic(struct channel *c, const rte *new, const rte *old)
   if (!np && !old)
   {
     channel_rte_trace_out(D_ROUTES, c, trte, "idempotent withdraw (filtered on export)");
+    /* No stats update, done in export_filter() */
     return;
   }
 
@@ -1576,6 +1582,18 @@ channel_notify_basic(void *_channel)
             */
            if ((rpe->it.old == new) && (new || src && (src == rpe->it.new->src)))
            {
+             /* Fix the stats: the old item is squashed (ignored) */
+             if (new)
+               c->export_stats.updates_ignored++;
+             else
+               c->export_stats.withdraws_ignored++;
+
+             /* Fix the stats: the new update is received */
+             if (rpe->it.new)
+               c->out_req.stats.updates_received++;
+             else
+               c->out_req.stats.withdraws_received++;
+
              new = rpe->it.new;
              rt_export_processed(&c->out_req, rpe->it.seq);
            }
@@ -1601,7 +1619,10 @@ channel_notify_basic(void *_channel)
                bug("Withdrawn route never seen before");
          }
          else if (!new && !old)
+         {
            channel_rte_trace_out(D_ROUTES, c, u->update->new, "idempotent withdraw (squash)");
+           c->export_stats.withdraws_ignored++;
+         }
          else
            rt_notify_basic(c, new, old);
 
@@ -2221,7 +2242,10 @@ channel_preimport(struct rt_import_request *req, rte *new, const rte *old)
 
   if (new && !old)
     if (CHANNEL_LIMIT_PUSH(c, RX))
+    {
+      c->import_stats.updates_limited_rx++;
       return 0;
+    }
 
   if (!new && old)
     CHANNEL_LIMIT_POP(c, RX);
@@ -2236,7 +2260,10 @@ channel_preimport(struct rt_import_request *req, rte *new, const rte *old)
       if (c->in_keep & RIK_REJECTED)
        new->flags |= REF_FILTERED;
       else
+      {
+       c->import_stats.updates_limited_in++;
        verdict = 0;
+      }
 
   if (!new_in && old_in)
     CHANNEL_LIMIT_POP(c, IN);