From 1410dd3f1b0648d75490995153e8a70fc9eb39f7 Mon Sep 17 00:00:00 2001 From: Naveen Thanikachalam Date: Tue, 14 Jul 2020 09:15:27 -0700 Subject: [PATCH] libfrr: Retain ret value if the best idx is found While iteratively looking for a best match route-map index amongst a list of potential best match route-map indices, if a candidate best match index is already found, disregard the value returned by the function route_map_apply_match() if it returns either RMAP_NOOP or RMAP_NOMATCH in the following iterations. This is because if a best match route-map index is found then, the return value must always be set to RMAP_MATCH. Signed-off-by: NaveenThanikachalam --- lib/routemap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/routemap.c b/lib/routemap.c index 3d69a3495a..b2bbdf8651 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1741,14 +1741,19 @@ route_map_get_index(struct route_map *map, const struct prefix *prefix, * more noops, we retain this return value and * return this eventually if there are no * matches. + * If a best match route-map index already + * exists, do not reset the match_ret. */ - if (*match_ret != RMAP_NOMATCH) + if (!best_index && (*match_ret != RMAP_NOMATCH)) *match_ret = ret; } else { /* * ret is RMAP_NOMATCH. + * If a best match route-map index already + * exists, do not reset the match_ret. */ - *match_ret = ret; + if (!best_index) + *match_ret = ret; } } -- 2.39.5