]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Fixing infinite loop when listing OSPF interfaces
authorRodrigo Nardi <rnardi@netdef.org>
Mon, 18 Sep 2023 20:40:35 +0000 (17:40 -0300)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Wed, 11 Oct 2023 14:29:06 +0000 (14:29 +0000)
The problem was happening because the ospf->oiflist has this behaviour, each interface was removed and added at the end of the list in each ospf_network_run_subnet call, generation an infinite loop.
As a solution, a copy of the list was generated and we interacted with a fixed list.

Signed-off-by: Rodrigo Nardi <rnardi@netdef.org>
(cherry picked from commit e0dbeff5bc599be0dfade8256b53dcfef4435bc8)

ospfd/ospfd.c

index 08044d63e5b19deb610d8dc055b6a0841c037fbb..6519bade28493ae54a5dbfed4d277599295f6c90 100644 (file)
@@ -1243,8 +1243,9 @@ int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
 {
        struct route_node *rn;
        struct ospf_network *network;
-       struct listnode *node, *nnode;
+       struct listnode *node;
        struct ospf_interface *oi;
+       struct list *ospf_oiflist = NULL;
 
        rn = route_node_lookup(ospf->networks, (struct prefix *)p);
        if (rn == NULL)
@@ -1259,8 +1260,9 @@ int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
        rn->info = NULL;
        route_unlock_node(rn); /* initial reference */
 
-       /* Find interfaces that are not configured already.  */
-       for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi)) {
+       ospf_oiflist = list_dup(ospf->oiflist);
+       /* Find interfaces that are not configured already. */
+       for (ALL_LIST_ELEMENTS_RO(ospf_oiflist, node, oi)) {
 
                if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
                        continue;
@@ -1268,6 +1270,8 @@ int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
                ospf_network_run_subnet(ospf, oi->connected, NULL, NULL);
        }
 
+       list_delete(&ospf_oiflist);
+
        /* Update connected redistribute. */
        update_redistributed(ospf, 0); /* interfaces possibly removed */
        ospf_area_check_free(ospf, area_id);
@@ -1275,6 +1279,7 @@ int ospf_network_unset(struct ospf *ospf, struct prefix_ipv4 *p,
        return 1;
 }
 
+
 /* Ensure there's an OSPF instance, as "ip ospf area" enabled OSPF means
  * there might not be any 'router ospf' config.
  *