summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-03-25 22:11:08 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2019-04-02 00:27:38 +0200
commita1e8b87c042994f8b5a495bdb2c45bbe7d68da4e (patch)
treee3e35a4d23e6c6dac2250afd7ba0cdb31f3d1a71
parentfb9e38b0661771b894bee67d5ecd1ad463a59da8 (diff)
nest: Recursive bgp routes
Allow recursive routes if they reference a route with a hight igp_metric. Max depth set to 10.
-rw-r--r--nest/rt-show.c3
-rw-r--r--nest/rt-table.c23
2 files changed, 20 insertions, 6 deletions
diff --git a/nest/rt-show.c b/nest/rt-show.c
index c7bcdf2f..244cd3bc 100644
--- a/nest/rt-show.c
+++ b/nest/rt-show.c
@@ -48,7 +48,8 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d)
get_route_info = a->src->proto->proto->get_route_info;
/* Need to normalize the extended attributes */
if ((get_route_info || d->verbose) && !rta_is_cached(a))
- ea_normalize(a->eattrs);
+ if (a->eattrs)
+ ea_normalize(a->eattrs);
if (get_route_info)
get_route_info(e, info);
else
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 6bf07a09..238aec39 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -2703,12 +2703,25 @@ rt_update_hostentry(rtable *tab, struct hostentry *he)
rta *a = e->attrs;
pxlen = n->n.addr->pxlen;
- if (a->hostentry)
+ int MAX_REC = 10;
+ u32 prev_igp_metric = 0;
+ int i = 0;
+ for (struct hostentry *he = a->hostentry;
+ he && he->src;
+ i++, he = he->src->hostentry)
{
- /* Recursive route should not depend on another recursive route */
- log(L_WARN "Next hop address %I resolvable through recursive route for %N",
- he->addr, n->n.addr);
- goto done;
+ log(L_WARN "Next hop address %I resolvable through recursive route for %N igp_metric %u %u",
+ he->addr, n->n.addr, prev_igp_metric, he->igp_metric);
+
+ if (prev_igp_metric >= he->igp_metric || i >= MAX_REC)
+ {
+ /* Recursive route should not depend on another recursive route */
+ log(L_WARN "Next hop address %I resolvable through deep recursive route for %N",
+ he->addr, n->n.addr);
+ goto done;
+ }
+
+ prev_igp_metric = he->igp_metric;
}
if (a->dest == RTD_UNICAST)