]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
When protocols go down, prune the neighbor list.
authorMartin Mares <mj@ucw.cz>
Sat, 13 Feb 1999 20:55:08 +0000 (20:55 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 13 Feb 1999 20:55:08 +0000 (20:55 +0000)
nest/iface.c
nest/iface.h
nest/proto.c

index a3dff4af1cf68bea9d75df8942177198f1187d33..28e7739be664dcb0de710aa39b0540d3d641e6ad 100644 (file)
@@ -23,7 +23,6 @@ static void auto_router_id(void);
  *     Neighbor Cache
  *
  *     FIXME: Use hashing to get some real speed.
- *     FIXME: Cleanup when a protocol goes down.
  */
 
 static slab *neigh_slab;
@@ -160,6 +159,30 @@ neigh_if_down(struct iface *i)
     }
 }
 
+void
+neigh_prune(void)
+{
+  neighbor *n, *m, **N;
+  struct iface *i;
+
+  DBG("Pruning neighbors\n");
+  WALK_LIST(i, iface_list)
+    {
+      N = &i->neigh;
+      while (n = *N)
+       {
+         if (n->proto->core_state == FS_HUNGRY || n->proto->core_state == FS_FLUSHING)
+           {
+             *N = n->sibling;
+             rem_node(&n->n);
+             sl_free(neigh_slab, n);
+             continue;
+           }
+         N = &n->sibling;
+       }
+    }
+}
+
 /*
  *     The Interface List
  */
index 83cbdb07bc656c40f5aafda730dcac736499da8e..378cf3d15616364dbb13c5e3e234c3b69f8a8c79 100644 (file)
@@ -89,6 +89,7 @@ neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags);
 
 void neigh_dump(neighbor *);
 void neigh_dump_all(void);
+void neigh_prune(void);
 
 /*
  *     Interface Pattern Lists
index f96d37dc45eba1008a0d6f0676fbd109314b95b5..21f3630785583f0b38be554d2999bd75b9afe96a 100644 (file)
@@ -330,6 +330,7 @@ proto_flush_all(void *unused)
   struct proto *p;
 
   rt_prune(&master_table);
+  neigh_prune();
   while ((p = HEAD(flush_proto_list))->n.next)
     {
       DBG("Flushing protocol %s\n", p->name);