summaryrefslogtreecommitdiff
path: root/ospfd/ospf_routemap.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2019-04-08 17:05:45 +0000
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-04-08 17:05:45 +0000
commit236e900ca428cfcebfdf07ce27de9afffd24b923 (patch)
tree30c5b664e8d3d89b7b5b708855d161e79f7dc252 /ospfd/ospf_routemap.c
parent421ac5391f22b0659762b184c33c50ff302256ce (diff)
ospfd: fix behavior of +/-metric
OSPFD uses -1 as a sentinel value for uninitialized metrics. When applying a route map with a +/-metric to redistributed routes, we were using -1 as our base value to increment or decrement on, which meant that if you set e.g. +10, you would end up with a redistributed route of metric 9. This patch also removes an off-by-one sanity check that would cause a set metric +1 or set metric 0 to result in a metric value of 20 :-) Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'ospfd/ospf_routemap.c')
-rw-r--r--ospfd/ospf_routemap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index a15e605aca..30b2a50bb3 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -374,15 +374,16 @@ static route_map_result_t route_set_metric(void *rule,
/* Set metric out value. */
if (!metric->used)
return RMAP_OKAY;
+
+ ei->route_map_set.metric = DEFAULT_DEFAULT_METRIC;
+
if (metric->type == metric_increment)
ei->route_map_set.metric += metric->metric;
- if (metric->type == metric_decrement)
+ else if (metric->type == metric_decrement)
ei->route_map_set.metric -= metric->metric;
- if (metric->type == metric_absolute)
+ else if (metric->type == metric_absolute)
ei->route_map_set.metric = metric->metric;
- if ((signed int)ei->route_map_set.metric < 1)
- ei->route_map_set.metric = -1;
if (ei->route_map_set.metric > OSPF_LS_INFINITY)
ei->route_map_set.metric = OSPF_LS_INFINITY;
}