From: Hasso Tepper <hasso@estpak.ee>
 To: zebra@zebra.org
Subject: [zebra 18648] [PATCH] Selforiginated Type-7 LSA's are not flushed
         from lsdb
diff --git a/ChangeLog b/ChangeLog
index 3f15329..ecee45f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
 	* Amir: Opaque LSA bug fix for deletion of Type11's
 	* configure.ac: use --localstatedir for Unix sockets
+	* Hasso Tepper: When flushing as-ext LSAs flush associated NSSA
+	  LSAs.
 
 2003-04-04 Paul Jakma <paul@dishone.st>
 
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 0facaf0..0d1485b 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -1860,6 +1860,42 @@
   return 0;
 }
 
+#ifdef HAVE_NSSA
+/* Flush any NSSA LSAs for given prefix */
+void
+ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p)
+{
+  struct listnode *node;
+  struct ospf_lsa *lsa;
+  struct ospf_area *area;
+
+  if (ospf->anyNSSA) 
+  {
+     for (node = listhead (ospf->areas); node; nextnode (node)) 
+     {
+        if (((area = getdata (node)) != NULL) 
+              && (area->external_routing == OSPF_AREA_NSSA)) 
+        {
+           if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix,
+                                        ospf->router_id))) 
+           {
+              if (IS_DEBUG_OSPF (lsa, LSA_FLOODING)) 
+                 zlog_warn ("LSA: There is no such AS-NSSA-LSA %s/%d in LSDB",
+                        inet_ntoa (p->prefix), p->prefixlen);
+              return;
+           }
+           ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
+           if (!IS_LSA_MAXAGE (lsa)) 
+           {
+              ospf_refresher_unregister_lsa (ospf, lsa);
+              ospf_lsa_flush_as (ospf, lsa);
+           }
+        }
+     }
+  }
+}
+#endif /* HAVE_NSSA */
+
 /* Flush an AS-external-LSA from LSDB and routing domain. */
 void
 ospf_external_lsa_flush (struct ospf *ospf,
@@ -1899,6 +1935,11 @@
       ospf_lsa_flush_as (ospf, lsa);
     }
 
+#ifdef HAVE_NSSA
+  /* If there is NSSA area, flush Type-7 lsa's as well */
+  ospf_nssa_lsa_flush (ospf, p);
+#endif /* HAVE_NSSA */
+  
   if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
     zlog_info ("ospf_external_lsa_flush(): stop");
 }
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index 82d9549..b12feeb 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -266,6 +266,7 @@
 struct ospf_lsa *ospf_lsa_install (struct ospf *,
 				   struct ospf_interface *, struct ospf_lsa *);
 
+void ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p);
 void ospf_external_lsa_flush (struct ospf *, u_char, struct prefix_ipv4 *,
 			      unsigned int, struct in_addr);