]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospfd.c
zebra: Allow ns delete to happen after under/over flow checks
[mirror_frr.git] / ospfd / ospfd.c
index d481e9e4c898ec48db6c3501a5d27b5efda87145..a18e2de72511b7d14429489e376ba4f8fd98be84 100644 (file)
@@ -171,7 +171,7 @@ void ospf_router_id_update(struct ospf *ospf)
 
                /* Flush (inline) all external LSAs which now match the new
                   router-id,
-                  need to adjust the OSPF_LSA_SELF flag, so the flush doesnt
+                  need to adjust the OSPF_LSA_SELF flag, so the flush doesn't
                   hit
                   asserts in ospf_refresher_unregister_lsa(). This step is
                   needed
@@ -635,7 +635,7 @@ static void ospf_finish_final(struct ospf *ospf)
        for (ALL_LIST_ELEMENTS(ospf->vlinks, node, nnode, vl_data))
                ospf_vl_delete(ospf, vl_data);
 
-       list_delete_and_null(&ospf->vlinks);
+       list_delete(&ospf->vlinks);
 
        /* Remove any ospf interface config params */
        FOR_ALL_INTERFACES (vrf, ifp) {
@@ -649,7 +649,7 @@ static void ospf_finish_final(struct ospf *ospf)
        /* Reset interface. */
        for (ALL_LIST_ELEMENTS(ospf->oiflist, node, nnode, oi))
                ospf_if_free(oi);
-       list_delete_and_null(&ospf->oiflist);
+       list_delete(&ospf->oiflist);
 
        /* De-Register VRF */
        ospf_zebra_vrf_deregister(ospf);
@@ -749,8 +749,8 @@ static void ospf_finish_final(struct ospf *ospf)
                ospf_ase_external_lsas_finish(ospf->external_lsas);
        }
 
-       list_delete_and_null(&ospf->areas);
-       list_delete_and_null(&ospf->oi_write_q);
+       list_delete(&ospf->areas);
+       list_delete(&ospf->oi_write_q);
 
        for (i = ZEBRA_ROUTE_SYSTEM; i <= ZEBRA_ROUTE_MAX; i++) {
                struct list *ext_list;
@@ -866,7 +866,7 @@ static void ospf_area_free(struct ospf_area *area)
        ospf_lsa_unlock(&area->router_lsa_self);
 
        route_table_finish(area->ranges);
-       list_delete_and_null(&area->oiflist);
+       list_delete(&area->oiflist);
 
        if (EXPORT_NAME(area))
                free(EXPORT_NAME(area));
@@ -890,6 +890,7 @@ void ospf_area_check_free(struct ospf *ospf, struct in_addr area_id)
 
        area = ospf_area_lookup_by_area_id(ospf, area_id);
        if (area && listcount(area->oiflist) == 0 && area->ranges->top == NULL
+           && !ospf_vl_count(ospf, area)
            && area->shortcut_configured == OSPF_SHORTCUT_DEFAULT
            && area->external_routing == OSPF_AREA_DEFAULT
            && area->no_summary == 0 && area->default_cost == 1
@@ -1148,6 +1149,32 @@ void ospf_interface_area_unset(struct ospf *ospf, struct interface *ifp)
        update_redistributed(ospf, 0); /* interfaces possibly removed */
 }
 
+bool ospf_interface_area_is_already_set(struct ospf *ospf,
+                                       struct interface *ifp)
+{
+       struct route_node *rn_oi;
+
+       if (!ospf)
+               return false; /* Ospf not ready yet */
+
+       /* Find interfaces that may need to be removed. */
+       for (rn_oi = route_top(IF_OIFS(ifp)); rn_oi;
+            rn_oi = route_next(rn_oi)) {
+               struct ospf_interface *oi = rn_oi->info;
+
+               if (oi == NULL)
+                       continue;
+
+               if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
+                       continue;
+               /* at least one route covered by interface
+                * that implies already done
+                */
+               return true;
+       }
+       return false;
+}
+
 /* Check whether interface matches given network
  * returns: 1, true. 0, false
  */
@@ -1297,7 +1324,7 @@ void ospf_ls_upd_queue_empty(struct ospf_interface *oi)
                if ((lst = (struct list *)rn->info)) {
                        for (ALL_LIST_ELEMENTS(lst, node, nnode, lsa))
                                ospf_lsa_unlock(&lsa); /* oi->ls_upd_queue */
-                       list_delete_and_null(&lst);
+                       list_delete(&lst);
                        rn->info = NULL;
                }