Skip to content

Commit

Permalink
ospf6d: Fix metric when sending AS-external LSAs
Browse files Browse the repository at this point in the history
When ospf6d originates an AS-external route that has been read from a kernel
routing table, then the metric of that route was ignored until now.
In my case all of these routes were announced with metric 1 in LS-updates.

Now the metric of the kernel route is added to whatever metric ospf6d already
computed originally.

Signed-off-by: Alexander Rose <[email protected]>
  • Loading branch information
Max-Mustermann33 committed Apr 2, 2024
1 parent d7f6d0d commit f5a1687
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
20 changes: 12 additions & 8 deletions ospf6d/ospf6_asbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,10 +1426,9 @@ static void ospf6_external_lsa_fwd_addr_set(struct ospf6 *ospf6,
}

void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct prefix *prefix,
unsigned int nexthop_num,
const struct in6_addr *nexthop,
route_tag_t tag, struct ospf6 *ospf6)
struct prefix *prefix, unsigned int nexthop_num,
const struct in6_addr *nexthop, route_tag_t tag,
struct ospf6 *ospf6, uint32_t metric)
{
route_map_result_t ret;
struct ospf6_route troute;
Expand Down Expand Up @@ -1498,9 +1497,10 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
match->path.metric_type =
metric_type(ospf6, type, 0);
if (troute.path.cost)
match->path.cost = troute.path.cost;
match->path.cost = troute.path.cost + metric;
else
match->path.cost = metric_value(ospf6, type, 0);
match->path.cost =
metric_value(ospf6, type, 0) + metric;

if (!IN6_IS_ADDR_UNSPECIFIED(&tinfo.forwarding))
memcpy(&info->forwarding, &tinfo.forwarding,
Expand All @@ -1511,10 +1511,14 @@ void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
* metric fields
*/
match->path.metric_type = metric_type(ospf6, type, 0);
match->path.cost = metric_value(ospf6, type, 0);
match->path.cost = metric_value(ospf6, type, 0) + metric;
info->tag = tag;
}

/* sum of metrics caused an overflow */
if (match->path.cost < metric)
match->path.cost = UINT32_MAX;

info->type = type;

if (nexthop_num && nexthop) {
Expand Down Expand Up @@ -1924,7 +1928,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate)
case DEFAULT_ORIGINATE_ALWAYS:
ospf6_asbr_redistribute_add(DEFAULT_ROUTE, 0,
(struct prefix *)&p, 0, &nexthop, 0,
ospf6);
ospf6, 0);
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion ospf6d/ospf6_asbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ extern void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
struct prefix *prefix,
unsigned int nexthop_num,
const struct in6_addr *nexthop,
route_tag_t tag, struct ospf6 *ospf6);
route_tag_t tag, struct ospf6 *ospf6,
uint32_t metric);
extern void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
struct prefix *prefix,
struct ospf6 *ospf6);
Expand Down
2 changes: 1 addition & 1 deletion ospf6d/ospf6_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int ospf6_zebra_read_route(ZAPI_CALLBACK_ARGS)
if (cmd == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
ospf6_asbr_redistribute_add(api.type, ifindex, &api.prefix,
api.nexthop_num, nexthop, api.tag,
ospf6);
ospf6, api.metric);
else
ospf6_asbr_redistribute_remove(api.type, ifindex, &api.prefix,
ospf6);
Expand Down

0 comments on commit f5a1687

Please sign in to comment.