]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: External LSA not flushed when area is configured as nssa or stub 7341/head
authorSoman K S <somanks@gmail.com>
Sun, 18 Oct 2020 11:49:32 +0000 (17:19 +0530)
committerSoman K S <somanks@gmail.com>
Sat, 24 Oct 2020 12:35:40 +0000 (18:05 +0530)
Issue:
When the ospf area is changed from default to nssa or stub, the previously
advertised external LSAs are not removed from the neighbor.
The LSAs remain in database till maxage timeout.

Fix:
Advertise the external LSAs with age set to maxage and flood to the
nssa or stub area.

Signed-off-by: kssoman <somanks@gmail.com>
ospfd/ospf_lsa.c
ospfd/ospf_lsa.h
ospfd/ospf_vty.c

index 0200bf5e260384de9fee4a5dd6da0fb0489f488e..d7c26da5586f8515fddd9de9aeb08d95a07f74a7 100644 (file)
@@ -3648,3 +3648,34 @@ int ospf_lsa_refresh_walker(struct thread *t)
 
        return 0;
 }
+
+/* Flush the LSAs for the specific area */
+void ospf_flush_lsa_from_area(struct ospf *ospf, struct in_addr area_id,
+                             int type)
+{
+       struct ospf_area *area;
+       struct route_node *rn;
+       struct ospf_lsa *lsa;
+
+       area = ospf_area_get(ospf, area_id);
+
+       switch (type) {
+       case OSPF_AS_EXTERNAL_LSA:
+               if ((area->external_routing == OSPF_AREA_NSSA) ||
+                   (area->external_routing == OSPF_AREA_STUB)) {
+                       LSDB_LOOP (EXTERNAL_LSDB(ospf), rn, lsa)
+                               if (IS_LSA_SELF(lsa) &&
+                                   !(CHECK_FLAG(lsa->flags,
+                                                OSPF_LSA_LOCAL_XLT)))
+                                       ospf_lsa_flush_area(lsa, area);
+               }
+               break;
+       case OSPF_AS_NSSA_LSA:
+               LSDB_LOOP (NSSA_LSDB(area), rn, lsa)
+                       if (IS_LSA_SELF(lsa))
+                               ospf_lsa_flush_area(lsa, area);
+               break;
+       default:
+               break;
+       }
+}
index 90f7b5363258a2b1c6def579689110908697c6f5..e63af4b347e335a83588112b54d6feb24ea2d6ab 100644 (file)
@@ -339,5 +339,6 @@ extern struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *,
                                                     struct ospf_lsa *);
 extern struct ospf_lsa *ospf_translated_nssa_originate(struct ospf *,
                                                       struct ospf_lsa *);
-
+extern void ospf_flush_lsa_from_area(struct ospf *ospf, struct in_addr area_id,
+                                    int type);
 #endif /* _ZEBRA_OSPF_LSA_H */
index 5c82e11393c972cc538d7a5aabbcf80fd81095c6..ce9826c37f86319655c4722cf476126569e7b878 100644 (file)
@@ -1445,6 +1445,8 @@ DEFUN (ospf_area_stub,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
+       /* Flush the external LSAs from the specified area */
+       ospf_flush_lsa_from_area(ospf, area_id, OSPF_AS_EXTERNAL_LSA);
        ospf_area_no_summary_unset(ospf, area_id);
 
        return CMD_SUCCESS;
@@ -1567,6 +1569,8 @@ static int ospf_area_nssa_cmd_handler(struct vty *vty, int argc,
                        ospf_area_no_summary_unset(ospf, area_id);
        }
 
+       /* Flush the external LSA for the specified area */
+       ospf_flush_lsa_from_area(ospf, area_id, OSPF_AS_EXTERNAL_LSA);
        ospf_schedule_abr_task(ospf);
 
        return CMD_SUCCESS;
@@ -1672,6 +1676,8 @@ DEFUN (no_ospf_area_nssa,
        VTY_GET_OSPF_AREA_ID_NO_BB("NSSA", area_id, format,
                                   argv[idx_ipv4_number]->arg);
 
+       /* Flush the NSSA LSA for the specified area */
+       ospf_flush_lsa_from_area(ospf, area_id, OSPF_AS_NSSA_LSA);
        ospf_area_nssa_unset(ospf, area_id, argc);
 
        ospf_schedule_abr_task(ospf);