summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_interface.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-11-13 21:06:20 +0200
committerDonatas Abraitis <donatas@opensourcerouting.org>2023-11-13 21:19:54 +0200
commitd46c4e94022ae26eb69e5990b1254f8c24b29958 (patch)
tree5bac1617e89ae303d16baaabcb634e1882e14bbf /ospf6d/ospf6_interface.c
parentc62c0181f07241fa3beb0a3aec3c39401ed8e5c7 (diff)
ospf6d: Let the user override interface cost for a loopback
Fixes: 80dfa9e012eb ("ospf6d: Set loopback interface cost to 0") Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'ospf6d/ospf6_interface.c')
-rw-r--r--ospf6d/ospf6_interface.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index a05ff1098c..4a88b32dfb 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -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.
@@ -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;