]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Add preferred counter
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 16 Jan 2019 14:16:51 +0000 (15:16 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 16 Jan 2019 14:16:51 +0000 (15:16 +0100)
nest/proto.c
nest/protocol.h
nest/rt-table.c

index a895ef30455a8bee4dc60271091cc7aea133acbf..ca22526da2331807903bf30086565bd9288832c7 100644 (file)
@@ -1624,8 +1624,8 @@ channel_show_stats(struct channel *c)
     cli_msg(-1006, "    Routes:         %u imported, %u filtered, %u exported",
            s->imp_routes, s->filt_routes, s->exp_routes);
   else
-    cli_msg(-1006, "    Routes:         %u imported, %u exported",
-           s->imp_routes, s->exp_routes);
+    cli_msg(-1006, "    Routes:         %u imported, %u exported, %u preferred",
+           s->imp_routes, s->exp_routes, s->pref_routes);
 
   cli_msg(-1006, "    Route change stats:     received   rejected   filtered    ignored   accepted");
   cli_msg(-1006, "      Import updates:     %10u %10u %10u %10u %10u",
index 8a22d76b860ca5a3dc241881c1deae6601baebeb..16d1c51147bf0d2d2ff56114b51c9b3ebbf8401d 100644 (file)
@@ -112,6 +112,7 @@ struct proto_stats {
   /* Import - from protocol to core */
   u32 imp_routes;              /* Number of routes successfully imported to the (adjacent) routing table */
   u32 filt_routes;             /* Number of routes rejected in import filter but kept in the routing table */
+  u32 pref_routes;             /* Number of routes that are preferred, sum over all routing tables */
   u32 imp_updates_received;    /* Number of route updates received */
   u32 imp_updates_invalid;     /* Number of route updates rejected as invalid */
   u32 imp_updates_filtered;    /* Number of route updates rejected by filters */
index 5a0ef91434db7c74178d73cf8eec4f7c0901a390..c6a7b7065aa85578055c032da9c0bbbe7491b27c 100644 (file)
@@ -909,8 +909,16 @@ rte_announce(rtable *tab, unsigned type, net *net, rte *new, rte *old,
   if (!old && !new)
     return;
 
-  if ((type == RA_OPTIMAL) && tab->hostcache)
-    rt_notify_hostcache(tab, net);
+  if (type == RA_OPTIMAL)
+  {
+    if (new)
+      new->sender->stats.pref_routes++;
+    if (old)
+      old->sender->stats.pref_routes--;
+
+    if (tab->hostcache)
+      rt_notify_hostcache(tab, net);
+  }
 
   struct channel *c; node *n;
   WALK_LIST2(c, n, tab->channels, table_node)
@@ -2559,7 +2567,7 @@ rt_show_table_stats(rtable *tab)
   cli_msg(-1026, "Route withdraws:\t%u", tab->route_withdraws);
 
   cli_msg(-1026, "");
-  cli_msg(-1026, "%-16s %10s %10s %10s", "Protocol", "Routes", "Updates", "Withdraws");
+  cli_msg(-1026, "%-16s %10s %10s %10s %10s", "Protocol", "Routes", "Preferred", "Updates", "Withdraws");
 
   struct channel *c; node *n;
   WALK_LIST2(c, n, tab->channels, table_node)
@@ -2567,7 +2575,8 @@ rt_show_table_stats(rtable *tab)
     if (c->channel_state == CS_DOWN)
       continue;
 
-    cli_msg(-1026, "%-16s %10u %10u %10u", c->proto->name, c->stats.imp_routes,
+    cli_msg(-1026, "%-16s %10u %10u %10u %10u", c->proto->name,
+           c->stats.imp_routes, c->stats.pref_routes,
            c->stats.imp_updates_accepted, c->stats.imp_withdraws_accepted);
   }
   cli_msg(-1026, "");