]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Respect loopback's cost that is set and set loopback costs to 0 13485/head
authorDonald Sharp <sharpd@nvidia.com>
Tue, 9 May 2023 17:10:35 +0000 (13:10 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 10 May 2023 12:35:45 +0000 (08:35 -0400)
When setting an loopback's cost, set the value to 0, unless the operator
has assigned a value for the loopback's cost.

RFC states:

If the state of the interface is Loopback, add a Type 3
link (stub network) as long as this is not an interface
to an unnumbered point-to-point network. The Link ID
should be set to the IP interface address, the Link Data
set to the mask 0xffffffff (indicating a host route),
and the cost set to 0.

FRR is going to allow this to be overridden if the operator specifically
sets a value too.

Fixes: #13472
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
ospfd/ospf_interface.c
ospfd/ospf_lsa.c

index 5742ece1f7d0ede078a80665e130c37588c25d7f..f18aa399a432c53dd596ec6a58765e739d45409b 100644 (file)
@@ -101,6 +101,9 @@ int ospf_if_get_output_cost(struct ospf_interface *oi)
                        cost = 1;
                else if (cost > 65535)
                        cost = 65535;
+
+               if (if_is_loopback(oi->ifp))
+                       cost = 0;
        }
 
        return cost;
index 452a3ba3747e597b504905ca2c610853dc5190c4..67f1faf8a9abf948afbec5595f63bf2446f4b21e 100644 (file)
@@ -608,7 +608,8 @@ static int lsa_link_loopback_set(struct stream **s, struct ospf_interface *oi)
 
        mask.s_addr = 0xffffffff;
        id.s_addr = oi->address->u.prefix4.s_addr;
-       return link_info_set(s, id, mask, LSA_LINK_TYPE_STUB, 0, 0);
+       return link_info_set(s, id, mask, LSA_LINK_TYPE_STUB, 0,
+                            oi->output_cost);
 }
 
 /* Describe Virtual Link. */