]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: prettier format for multilevel-recursive routes
authorChristian Franke <chris@opensourcerouting.org>
Wed, 12 Jul 2017 16:28:40 +0000 (18:28 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Wed, 12 Jul 2017 16:28:40 +0000 (18:28 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
lib/nexthop.c
lib/nexthop.h
zebra/zebra_vty.c

index 9b5a3ee1020eae8261cfc6dc1eefa27e0d5f5491..e9ffea0a0e6d4785b0173904481b0bbd9627d10c 100644 (file)
@@ -274,3 +274,14 @@ nexthop_next(struct nexthop *nexthop)
 
   return NULL;
 }
+
+unsigned int
+nexthop_level(struct nexthop *nexthop)
+{
+  unsigned int rv = 0;
+
+  for (struct nexthop *par = nexthop->rparent; par; par = par->rparent)
+    rv++;
+
+  return rv;
+}
index 4d7f32f6f04c8f15acd19af1420589716ad154a7..e9d937f94b8e34fb01b30e6e9e847ceace593d84 100644 (file)
@@ -133,4 +133,5 @@ extern int nexthop_labels_match (struct nexthop *nh1, struct nexthop *nh2);
 
 extern const char * nexthop2str (struct nexthop *nexthop, char *str, int size);
 extern struct nexthop *nexthop_next(struct nexthop *nexthop);
+extern unsigned int nexthop_level(struct nexthop *nexthop);
 #endif /*_LIB_NEXTHOP_H */
index 7f4754fccc8f5beec26df97f028b2dfec89c7a7b..3b138cba8be1c048794ef89577a923ea635b4696 100644 (file)
@@ -985,7 +985,7 @@ vty_show_ip_route (struct vty *vty, struct route_node *rn, struct route_entry *r
        vty_out (vty, "  %c%*c",
                 CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB)
                 ? '*' : ' ',
-                len - 3 + (2 * (nexthop->rparent ? 1 : 0)), ' ');
+                len - 3 + (2 * nexthop_level(nexthop)), ' ');
 
       switch (nexthop->type)
        {