When protocols go down, prune the neighbor list.

This commit is contained in:
Martin Mares 1999-02-13 20:55:08 +00:00
parent 013a9b91fe
commit 783f8b689a
3 changed files with 26 additions and 1 deletions

View file

@ -23,7 +23,6 @@ static void auto_router_id(void);
* Neighbor Cache * Neighbor Cache
* *
* FIXME: Use hashing to get some real speed. * FIXME: Use hashing to get some real speed.
* FIXME: Cleanup when a protocol goes down.
*/ */
static slab *neigh_slab; 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 * The Interface List
*/ */

View file

@ -89,6 +89,7 @@ neighbor *neigh_find(struct proto *, ip_addr *, unsigned flags);
void neigh_dump(neighbor *); void neigh_dump(neighbor *);
void neigh_dump_all(void); void neigh_dump_all(void);
void neigh_prune(void);
/* /*
* Interface Pattern Lists * Interface Pattern Lists

View file

@ -330,6 +330,7 @@ proto_flush_all(void *unused)
struct proto *p; struct proto *p;
rt_prune(&master_table); rt_prune(&master_table);
neigh_prune();
while ((p = HEAD(flush_proto_list))->n.next) while ((p = HEAD(flush_proto_list))->n.next)
{ {
DBG("Flushing protocol %s\n", p->name); DBG("Flushing protocol %s\n", p->name);