]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Better shutdown. (Flush my own router LSA and send 1WAY to every neighbor.)
authorOndrej Filip <feela@network.cz>
Sat, 27 May 2000 15:36:02 +0000 (15:36 +0000)
committerOndrej Filip <feela@network.cz>
Sat, 27 May 2000 15:36:02 +0000 (15:36 +0000)
Ext LSA originating and flushing added.

proto/ospf/lsupd.c
proto/ospf/lsupd.h
proto/ospf/ospf.c
proto/ospf/topology.c
proto/ospf/topology.h

index 002dea07b17340f01ef4aff8c4990fdabc9d261d..6ae6866f273fa083db06b06401c77ac4ecc7eeb6 100644 (file)
@@ -434,3 +434,14 @@ ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
   }
 }
 
+void
+net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
+  struct ospf_area *oa)
+{
+  struct ospf_lsa_header *lsa=&en->lsa;
+
+  lsa->age=LSA_MAXAGE;
+  debug("Premature aging self originated lsa.\n");
+  flood_lsa(NULL,NULL,lsa,po,NULL,oa);
+}
+
index a03ed8c58cb8c6b766ce6c9d9f0973278d26eeea..56368bab717bf1e055e134d7dccb6f57df8f830e 100644 (file)
@@ -16,5 +16,8 @@ void ospf_lsupd_rx(struct ospf_lsupd_packet *ps, struct proto *p,
 int flood_lsa(struct ospf_neighbor *n, struct ospf_lsa_header *hn,
   struct ospf_lsa_header *hh, struct proto_ospf *po, struct ospf_iface *iff,
   struct ospf_area *oa);
+void net_flush_lsa(struct top_hash_entry *en, struct proto_ospf *po,
+                 struct ospf_area *oa);
+
 
 #endif /* _BIRD_OSPF_LSUPD_H_ */
index 7e04a518cc1d2fe630e8588d33dcc82354677843..fde33f5acacbccfa45bba8ebec64d52a01030a28 100644 (file)
@@ -112,12 +112,6 @@ ospf_rte_same(struct rte *new, struct rte *old)
   return 1;
 }
 
-static void
-ospf_postconfig(struct proto_config *c)
-{
-  DBG( " OSPF: postconfig\n" );
-}
-
 int
 ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool *pool)
 {
@@ -129,6 +123,32 @@ ospf_import_control(struct proto *p, rte **new, ea_list **attrs, struct linpool
   return 0;
 }
 
+static int
+ospf_shutdown(struct proto *p)
+{
+  struct proto_ospf *po=(struct proto_ospf *)p;
+  struct ospf_iface *ifa;
+  struct ospf_neighbor *n;
+  struct ospf_area *oa;
+  debug("%s: Shutdown requested\n", p->name);
+  /* first of all flush my rt LSA */
+
+  WALK_LIST(oa,po->area_list)
+  {
+    net_flush_lsa(oa->rt,po,oa);
+  }
+
+
+  /* And send to all my neighbors 1WAY */
+  WALK_LIST(ifa, po->iface_list)
+  {
+    WALK_LIST(n, ifa->neigh_list) neigh_chstate(n,NEIGHBOR_DOWN);
+    hello_timer_hook(ifa->hello_timer);
+  }
+  
+  return PS_DOWN;
+}
+
 void
 ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old, ea_list *attrs)
 {
@@ -139,13 +159,20 @@ ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old, ea_list *attrs)
 
   if(new)              /* Got some new route */
   {
-    int i;
-    /* Originate new external LSA */
+    originate_ext_lsa(n, old, po);
   }
   else
   {
-    int i;
-    /* Flush some old external LSA */
+    u32 rtid=po->proto.cf->global->router_id;
+    struct ospf_area *oa;
+    struct top_hash_entry *en;
+
+    /* Flush old external LSA */
+    WALK_LIST(oa, po->area_list)
+    {
+      if(en=ospf_hash_find(oa->gr, ipa_to_u32(n->n.prefix), rtid, LSA_T_EXT))
+        net_flush_lsa(en,po,oa);
+    }
   }
 }
 
@@ -155,5 +182,5 @@ struct protocol proto_ospf = {
   init:                ospf_init,
   dump:                ospf_dump,
   start:       ospf_start,
-  postconfig:  ospf_postconfig,
+  shutdown:    ospf_shutdown
 };
index c02b0b7901c79628e6cd1643b207c03105e6bef6..f54c63b28466533b0de21eb8ed115eb19c65eaf4 100644 (file)
@@ -350,7 +350,7 @@ originate_ext_lsa_body(net *n, rte *e, struct proto_ospf *po)
 }
 
 void
-originate_ext_lsa(net *n, rte *e, u16 *len, struct proto_ospf *po)
+originate_ext_lsa(net *n, rte *e, struct proto_ospf *po)
 {
   struct ospf_lsa_header lsa;
   u32 rtid=po->proto.cf->global->router_id;
index 92b714386f610cff5d4e59a3de03c7a0ee3226b3..23620b8150fa05bf44c889dddc0d41fd781ae15b 100644 (file)
@@ -49,5 +49,6 @@ void addifa_rtlsa(struct ospf_iface *ifa);
 void originate_rt_lsa(struct ospf_area *oa,struct proto_ospf *po);
 void originate_net_lsa(struct ospf_iface *ifa,struct proto_ospf *po);
 int can_flush_lsa(struct ospf_area *oa);
+void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po);
 
 #endif /* _BIRD_OSPF_TOPOLOGY_H_ */