Skip to content

Commit

Permalink
ospf6d: Let the user override interface cost for a loopback
Browse files Browse the repository at this point in the history
Fixes: 80dfa9e ("ospf6d: Set loopback interface cost to 0")

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Nov 13, 2023
1 parent c62c018 commit d46c4e9
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,10 @@ static uint8_t ospf6_default_iftype(struct interface *ifp)
static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
{
/* If all else fails, use default OSPF cost */
uint32_t cost = 0;
uint32_t cost;
uint32_t bw, refbw;
struct ospf6 *ospf6;

/* If the interface type is point-to-multipoint or the interface
* is in the state Loopback, the global scope IPv6 addresses
* associated with the interface (if any) are copied into the
* intra-area-prefix-LSA with the PrefixOptions LA-bit set, the
* PrefixLength set to 128, and the metric set to 0.
*/
if (if_is_loopback(oi->interface))
return cost;

/* interface speed and bw can be 0 in some platforms,
* use ospf default bw. If bw is configured then it would
* be used.
Expand All @@ -162,6 +153,15 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
cost = (uint32_t)((double)refbw / (double)bw + (double)0.5);
if (cost < 1)
cost = 1;

/* If the interface type is point-to-multipoint or the interface
* is in the state Loopback, the global scope IPv6 addresses
* associated with the interface (if any) are copied into the
* intra-area-prefix-LSA with the PrefixOptions LA-bit set, the
* PrefixLength set to 128, and the metric set to 0.
*/
if (if_is_loopback(oi->interface))
cost = 0;
}

return cost;
Expand Down

0 comments on commit d46c4e9

Please sign in to comment.