summaryrefslogtreecommitdiff
path: root/ospfd/ospf_zebra.c
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <jafar@atcorp.com>2023-03-30 22:36:13 -0500
committerJafar Al-Gharaibeh <jafar@atcorp.com>2023-04-18 00:21:05 -0500
commit6af89f8f033b61217322ca1e8fca324f813a1ef5 (patch)
tree626c01046012a628a44314d6d61e446ef61977ee /ospfd/ospf_zebra.c
parentbe574cf987311bf299de018b71084e69eb08f5fc (diff)
ospfd: use rib metric as the base for set metric +/-
When using route maps with external routes in OSPF as follows: ``` set metric +10 ``` The current behavior is to use the default ospf metric as the base and then add to 10 to it. The behavior isn't useful as-is. A value 30 (20 dfeault + 10) can be set directly instead. the behavior is also not consistent with bgp. bgp does use the rib metric in this case as the base. The current behavior also doesn't allow the metric to accumulate when crossing different routing domains such as vrfs causing the metric to reset every time the route enters a new vrf with a new ospf network. This PR changes the behavior such that the rib metric is used as a base for ospf exteral routes when used with `set metric -/+` Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
Diffstat (limited to 'ospfd/ospf_zebra.c')
-rw-r--r--ospfd/ospf_zebra.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index 3f967e41e4..0b770a8364 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -956,8 +956,8 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype,
type_str = "always";
ospf->redistribute++;
ospf_external_add(ospf, DEFAULT_ROUTE, 0);
- ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop,
- 0);
+ ospf_external_info_add(ospf, DEFAULT_ROUTE, 0, p, 0, nexthop, 0,
+ DEFAULT_DEFAULT_METRIC);
break;
}
@@ -1303,9 +1303,11 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)
rt_type = DEFAULT_ROUTE;
if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE))
- zlog_debug("%s: cmd %s from client %s: vrf_id %d, p %pFX",
- __func__, zserv_command_string(cmd),
- zebra_route_string(api.type), vrf_id, &api.prefix);
+ zlog_debug(
+ "%s: cmd %s from client %s: vrf_id %d, p %pFX, metric %d",
+ __func__, zserv_command_string(cmd),
+ zebra_route_string(api.type), vrf_id, &api.prefix,
+ api.metric);
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD) {
/* XXX|HACK|TODO|FIXME:
@@ -1332,7 +1334,8 @@ static int ospf_zebra_read_route(ZAPI_CALLBACK_ARGS)
p);
ei = ospf_external_info_add(ospf, rt_type, api.instance, p,
- ifindex, nexthop, api.tag);
+ ifindex, nexthop, api.tag,
+ api.metric);
if (ei == NULL) {
/* Nothing has changed, so nothing to do; return */
return 0;