summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Franke <chris@opensourcerouting.org>2017-07-12 18:28:40 +0200
committerChristian Franke <chris@opensourcerouting.org>2017-07-12 18:28:40 +0200
commite3054ee94fc010095262caba2305e82ecbca7597 (patch)
tree78770d783a06a4b6d8d435aafc384c9e954474d7 /lib
parent80507207886f119001ea7e835b59890877e50e10 (diff)
zebra: prettier format for multilevel-recursive routes
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/nexthop.c11
-rw-r--r--lib/nexthop.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 9b5a3ee102..e9ffea0a0e 100644
--- a/lib/nexthop.c
+++ b/lib/nexthop.c
@@ -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;
+}
diff --git a/lib/nexthop.h b/lib/nexthop.h
index 4d7f32f6f0..e9d937f94b 100644
--- a/lib/nexthop.h
+++ b/lib/nexthop.h
@@ -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 */