summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2023-05-09 13:10:35 -0400
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-05-10 16:13:57 +0000
commit2b047212309667452facce473309db1c877619db (patch)
tree26da4b69bd0044c4f18ce30d138b71ddf367dfb8
parent9e013ffd45ea0130e8fcfc8de0943baea7c70104 (diff)
ospfd: Respect loopback's cost that is set and set loopback costs to 0
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> (cherry picked from commit dd2bc4fb406cc9284d35ef623ebb8838cb158bc8)
-rw-r--r--ospfd/ospf_interface.c3
-rw-r--r--ospfd/ospf_lsa.c3
2 files changed, 5 insertions, 1 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index bed36cfb1b..6f52b60f9b 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -116,6 +116,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;
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 109229f909..3ca8427d88 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -603,7 +603,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. */