]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: External LSA not flushed when area is configured as nssa or stub
authorSoman K S <somanks@gmail.com>
Sun, 18 Oct 2020 11:49:32 +0000 (17:19 +0530)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 28 Oct 2020 18:35:48 +0000 (21:35 +0300)
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 8095219146457679a4edeb46a2e12f01c0c69658..6c9a36ad5acfe9289d601592b231aed533733edd 100644 (file)
@@ -3636,3 +3636,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 4033659bffbe8ae2095400db45642a265a35dc0b..64d6617c37aabc777f4bef3df30620cd42859aca 100644 (file)
@@ -331,5 +331,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 0ecd8b91ca7c49bf59ca534b618c1baa48bd1cd3..af0a39d59e6b7d71508a80992bc4012138315265 100644 (file)
@@ -1444,6 +1444,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;
@@ -1566,6 +1568,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;
@@ -1671,6 +1675,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);