From 85ad5855a02e8b185a61bbcb601f005d2e6747db Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Mon, 29 Jan 2018 12:49:37 +0100 Subject: Nest: Fix corner case in recursive next hop lookup Thanks to Svenne Krap for the bugreport. --- nest/rt-table.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nest/rt-table.c b/nest/rt-table.c index 4640d6a9..6ee261e8 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2392,12 +2392,13 @@ static int rt_update_hostentry(rtable *tab, struct hostentry *he) { rta *old_src = he->src; + int direct = 0; int pxlen = 0; /* Reset the hostentry */ he->src = NULL; - he->nexthop_linkable = 0; he->dest = RTD_UNREACHABLE; + he->nexthop_linkable = 0; he->igp_metric = 0; net_addr he_addr; @@ -2417,9 +2418,7 @@ rt_update_hostentry(rtable *tab, struct hostentry *he) goto done; } - he->dest = a->dest; - he->nexthop_linkable = 1; - if (he->dest == RTD_UNICAST) + if (a->dest == RTD_UNICAST) { for (struct nexthop *nh = &(a->nh); nh; nh = nh->next) if (ipa_zero(nh->gw)) @@ -2432,12 +2431,13 @@ rt_update_hostentry(rtable *tab, struct hostentry *he) goto done; } - he->nexthop_linkable = 0; - break; + direct++; } } he->src = rta_clone(a); + he->dest = a->dest; + he->nexthop_linkable = !direct; he->igp_metric = rt_get_igp_metric(e); } -- cgit v1.2.3