diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2023-03-30 22:36:13 -0500 | 
|---|---|---|
| committer | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2023-04-18 00:21:05 -0500 | 
| commit | 6af89f8f033b61217322ca1e8fca324f813a1ef5 (patch) | |
| tree | 626c01046012a628a44314d6d61e446ef61977ee /ospfd/ospf_asbr.c | |
| parent | be574cf987311bf299de018b71084e69eb08f5fc (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_asbr.c')
| -rw-r--r-- | ospfd/ospf_asbr.c | 7 | 
1 files changed, 4 insertions, 3 deletions
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c index 7befcc1086..516ee80c5b 100644 --- a/ospfd/ospf_asbr.c +++ b/ospfd/ospf_asbr.c @@ -94,7 +94,7 @@ int ospf_route_map_set_compare(struct route_map_set_values *values1,  struct external_info *  ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance,  		       struct prefix_ipv4 p, ifindex_t ifindex, -		       struct in_addr nexthop, route_tag_t tag) +		       struct in_addr nexthop, route_tag_t tag, uint32_t metric)  {  	struct external_info *new;  	struct route_node *rn; @@ -131,6 +131,7 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance,  	new->tag = tag;  	new->orig_tag = tag;  	new->aggr_route = NULL; +	new->metric = metric;  	/* we don't unlock rn from the get() because we're attaching the info */  	if (rn) @@ -138,9 +139,9 @@ ospf_external_info_add(struct ospf *ospf, uint8_t type, unsigned short instance,  	if (IS_DEBUG_OSPF(lsa, LSA_GENERATE)) {  		zlog_debug( -			"Redistribute[%s][%u]: %pFX external info created, with NH %pI4", +			"Redistribute[%s][%u]: %pFX external info created, with NH %pI4, metric:%u",  			ospf_redist_string(type), ospf->vrf_id, &p, -			&nexthop.s_addr); +			&nexthop.s_addr, metric);  	}  	return new;  }  | 
