]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: Fix P2MP handling when TI-LFA is enabled 7127/head
authorGalaxyGorilla <sascha@netdef.org>
Wed, 16 Dec 2020 15:02:29 +0000 (15:02 +0000)
committerGalaxyGorilla <sascha@netdef.org>
Tue, 19 Jan 2021 15:32:13 +0000 (15:32 +0000)
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
ospfd/ospf_spf.c
tests/ospfd/test_ospf_spf.c

index 080256e5a79d16d54e22721a85fd5be6a4ce162d..fae4f1e10c13e7ab61c77adf52762d6609bd3052 100644 (file)
@@ -847,17 +847,22 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
                                struct ospf_interface *oi = NULL;
                                struct in_addr nexthop = {.s_addr = 0};
 
-                               oi = ospf_if_lookup_by_lsa_pos(area, lsa_pos);
-                               if (!oi) {
-                                       zlog_debug(
-                                               "%s: OI not found in LSA: lsa_pos: %d link_id:%s link_data:%s",
-                                               __func__, lsa_pos,
-                                               inet_ntop(AF_INET, &l->link_id,
-                                                         buf1, BUFSIZ),
-                                               inet_ntop(AF_INET,
-                                                         &l->link_data, buf2,
-                                                         BUFSIZ));
-                                       return 0;
+                               if (area->spf_root_node) {
+                                       oi = ospf_if_lookup_by_lsa_pos(area,
+                                                                      lsa_pos);
+                                       if (!oi) {
+                                               zlog_debug(
+                                                       "%s: OI not found in LSA: lsa_pos: %d link_id:%s link_data:%s",
+                                                       __func__, lsa_pos,
+                                                       inet_ntop(AF_INET,
+                                                                 &l->link_id,
+                                                                 buf1, BUFSIZ),
+                                                       inet_ntop(AF_INET,
+                                                                 &l->link_data,
+                                                                 buf2,
+                                                                 BUFSIZ));
+                                               return 0;
+                                       }
                                }
 
                                /*
@@ -905,7 +910,21 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
                                 * as described above using a reverse lookup to
                                 * figure out the nexthop.
                                 */
-                               if (oi->type == OSPF_IFTYPE_POINTOPOINT) {
+
+                               /*
+                                * HACK: we don't know (yet) how to distinguish
+                                * between P2P and P2MP interfaces by just
+                                * looking at LSAs, which is important for
+                                * TI-LFA since you want to do SPF calculations
+                                * from the perspective of other nodes. Since
+                                * TI-LFA is currently not implemented for P2MP
+                                * we just check here if it is enabled and then
+                                * blindly assume that P2P is used. Ultimately
+                                * the interface code needs to be removed
+                                * somehow.
+                                */
+                               if (area->ospf->ti_lfa_enabled
+                                   || (oi && oi->type == OSPF_IFTYPE_POINTOPOINT)) {
                                        struct ospf_neighbor *nbr_w = NULL;
 
                                        /* Calculating node is root node, link
@@ -934,7 +953,7 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
                                                        }
                                                }
                                        }
-                               } else if (oi->type
+                               } else if (oi && oi->type
                                           == OSPF_IFTYPE_POINTOMULTIPOINT) {
                                        struct prefix_ipv4 la;
 
@@ -979,7 +998,7 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area,
                                } else
                                        zlog_info(
                                                "%s: could not determine nexthop for link %s",
-                                               __func__, oi->ifp->name);
+                                               __func__, oi ? oi->ifp->name : "");
                        } /* end point-to-point link from V to W */
                        else if (l->m[0].type == LSA_LINK_TYPE_VIRTUALLINK) {
                                /*
index 4b7e5f7e7054a567a6cc72fbfc0e0c32bd1352e8..a85f7e14eceb5a0c210815c3f018920132c83bdd 100644 (file)
@@ -43,6 +43,7 @@ static struct ospf *test_init(struct ospf_test_node *root)
        inet_aton(root->router_id, &router_id);
        ospf->router_id = router_id;
        ospf->router_id_static = router_id;
+       ospf->ti_lfa_enabled = true;
 
        return ospf;
 }