]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Nest: Show mergable routes in 'show route' output
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Fri, 2 Aug 2019 22:16:49 +0000 (00:16 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Fri, 2 Aug 2019 22:16:49 +0000 (00:16 +0200)
Routes mergable with the best route are marked by '+'.

nest/config.Y
nest/route.h
nest/rt-show.c
nest/rt-table.c

index 0650be0444c7d1958976f4ccfb44f72f07255cb1..959802824a0633b4609d9b5341f56111671177e5 100644 (file)
@@ -533,6 +533,7 @@ r_args:
      $$ = cfg_allocz(sizeof(struct rt_show_data));
      init_list(&($$->tables));
      $$->filter = FILTER_ACCEPT;
+     $$->show_mergable = 1;
    }
  | r_args net_any {
      $$ = $1;
index 1e9c7c5504c249fe028bcc029f6637df0fca5dc4..f0f4a6dd2219f09b48ba227d0e131091798ed4e2 100644 (file)
@@ -320,6 +320,7 @@ void rte_free(rte *);
 rte *rte_do_cow(rte *);
 static inline rte * rte_cow(rte *r) { return (r->flags & REF_COW) ? rte_do_cow(r) : r; }
 rte *rte_cow_rta(rte *r, linpool *lp);
+int rte_mergable(rte *pri, rte *sec);
 void rt_dump(rtable *);
 void rt_dump_all(void);
 int rt_feed_channel(struct channel *c);
@@ -353,7 +354,7 @@ struct rt_show_data {
   struct proto *export_protocol;
   struct channel *export_channel;
   struct config *running_on_config;
-  int export_mode, primary_only, filtered, stats, show_for;
+  int export_mode, primary_only, filtered, stats, show_for, show_mergable;
 
   int table_open;                      /* Iteration (fit) is open */
   int net_counter, rt_counter, show_counter, table_counter;
index f3706d783995b41e7b6d6ea89d73a85e21c70dfb..5d112979081ae7120b5b529b7f1f5930ec79295e 100644 (file)
@@ -35,6 +35,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
   byte tm[TM_DATETIME_BUFFER_SIZE], info[256];
   rta *a = e->attrs;
   int primary = (e->net->routes == e) && rte_is_valid(e);
+  int mergable = d->show_mergable && !primary && rte_mergable(e->net->routes, e);
   int sync_error = (e->net->n.flags & KRF_SYNC_ERROR);
   void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs);
   struct nexthop *nh;
@@ -63,8 +64,10 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm
   if (d->last_table != d->tab)
     rt_show_table(c, d);
 
-  cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s", ia, rta_dest_name(a->dest),
-            a->src->proto->name, tm, from, primary ? (sync_error ? " !" : " *") : "", info);
+  cli_printf(c, -1007, "%-20s %s [%s %s%s]%s%s",
+            ia, rta_dest_name(a->dest), a->src->proto->name, tm, from,
+            primary ? (sync_error ? " !" : " *") : (mergable ? " +" : ""),
+            info);
 
   if (a->dest == RTD_UNICAST)
     for (nh = &(a->nh); nh; nh = nh->next)
index 001cfd10756f682645e007502d4d37289c7dc93b..31cdb55918d85066a0f751dd4aaabf5f47952928 100644 (file)
@@ -453,7 +453,7 @@ rte_better(rte *new, rte *old)
   return 0;
 }
 
-static int
+int
 rte_mergable(rte *pri, rte *sec)
 {
   int (*mergable)(rte *, rte *);