summaryrefslogtreecommitdiff
path: root/ospfd/ospf_interface.c
diff options
context:
space:
mode:
authorGalaxyGorilla <sascha@netdef.org>2020-08-07 12:13:07 +0000
committerGalaxyGorilla <sascha@netdef.org>2020-08-18 10:58:45 +0000
commit1d376ff539508f336cb5872c5592b780e3db180b (patch)
tree7e276efe8ff4cc3316fed894b5d7e0840c978dec /ospfd/ospf_interface.c
parent5ec5929c62219c221555135b27bf1828497aad4b (diff)
ospfd: introduce a 'dry run' into SPF code
in OSPF interface data is used for the nexthop resolution during the SPF algorithm, see RFC2328 16.1.1. However, for certain technologies like TI-LFA it is desirable to be able to calculate SPFs for arbitrary root nodes, not just the calculating node. Since interface data is not available for other nodes it is necessary to remove this dependency and make its usage optional, depending on the intent of changing the RIB with the generated tree (or not). To signal that a SPF run is used without the intent to change the RIB an additional flag `spf_dry_run` is introduced to the ospf_area struct. This flag is currently only used within the pure SPF code but will be extended to the SPF postprocessing later on. Signed-off-by: GalaxyGorilla <sascha@netdef.org>
Diffstat (limited to 'ospfd/ospf_interface.c')
-rw-r--r--ospfd/ospf_interface.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 7977a2a9f4..af801da8d7 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -995,7 +995,8 @@ void ospf_vl_delete(struct ospf *ospf, struct ospf_vl_data *vl_data)
ospf_vl_data_free(vl_data);
}
-static int ospf_vl_set_params(struct ospf_vl_data *vl_data, struct vertex *v)
+static int ospf_vl_set_params(struct ospf_area *area,
+ struct ospf_vl_data *vl_data, struct vertex *v)
{
int changed = 0;
struct ospf_interface *voi;
@@ -1003,6 +1004,7 @@ static int ospf_vl_set_params(struct ospf_vl_data *vl_data, struct vertex *v)
struct vertex_parent *vp = NULL;
unsigned int i;
struct router_lsa *rl;
+ struct ospf_interface *oi;
voi = vl_data->vl_oi;
@@ -1013,17 +1015,24 @@ static int ospf_vl_set_params(struct ospf_vl_data *vl_data, struct vertex *v)
}
for (ALL_LIST_ELEMENTS_RO(v->parents, node, vp)) {
- vl_data->nexthop.oi = vp->nexthop->oi;
+ vl_data->nexthop.lsa_pos = vp->nexthop->lsa_pos;
vl_data->nexthop.router = vp->nexthop->router;
- if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
- &vl_data->nexthop.oi->address->u.prefix4))
- changed = 1;
+ /*
+ * Only deal with interface data when the local
+ * (calculating) node is the SPF root node
+ */
+ if (!area->spf_dry_run) {
+ oi = ospf_if_lookup_by_lsa_pos(
+ area, vl_data->nexthop.lsa_pos);
- voi->address->u.prefix4 =
- vl_data->nexthop.oi->address->u.prefix4;
- voi->address->prefixlen =
- vl_data->nexthop.oi->address->prefixlen;
+ if (!IPV4_ADDR_SAME(&voi->address->u.prefix4,
+ &oi->address->u.prefix4))
+ changed = 1;
+
+ voi->address->u.prefix4 = oi->address->u.prefix4;
+ voi->address->prefixlen = oi->address->prefixlen;
+ }
break; /* We take the first interface. */
}
@@ -1114,7 +1123,7 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp);
}
- if (ospf_vl_set_params(vl_data, v)) {
+ if (ospf_vl_set_params(area, vl_data, v)) {
if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
zlog_debug(
"ospf_vl_up_check: VL cost change, scheduling router lsa refresh");