Downing of interface should work.

This commit is contained in:
Ondrej Filip 2000-05-16 23:59:38 +00:00
parent 8fb0c2c298
commit 18a0c0bb76
3 changed files with 64 additions and 30 deletions

View file

@ -67,7 +67,37 @@ iface_chstate(struct ospf_iface *ifa, u8 state)
void void
downint(struct ospf_iface *ifa) downint(struct ospf_iface *ifa)
{ {
/* FIXME: Delete all neighbors! */ struct ospf_neighbor *n;
struct proto *p=&ifa->proto->proto;
struct proto_ospf *po=ifa->proto;
WALK_LIST(n,ifa->neigh_list)
{
debug("%s: Removing neighbor %I", p->name, n->ip);
ospf_neigh_remove(n);
}
rem_node(NODE ifa);
if(ifa->hello_sk!=NULL)
{
sk_close(ifa->hello_sk);
rfree(ifa->hello_sk);
}
if(ifa->dr_sk!=NULL)
{
sk_close(ifa->dr_sk);
rfree(ifa->dr_sk);
}
if(ifa->ip_sk!=NULL)
{
sk_close(ifa->ip_sk);
rfree(ifa->ip_sk);
}
if(ifa->wait_timer!=NULL)
{
tm_stop(ifa->wait_timer);
rfree(ifa->wait_timer);
}
mb_free(ifa);
} }
void void
@ -150,11 +180,6 @@ ospf_open_mc_socket(struct ospf_iface *ifa)
p=(struct proto *)(ifa->proto); p=(struct proto *)(ifa->proto);
/* FIXME: No NBMA and PTP networks */
if(ifa->iface->flags & IF_MULTICAST)
{
mcsk=sk_new(p->pool); mcsk=sk_new(p->pool);
mcsk->type=SK_IP_MC; mcsk->type=SK_IP_MC;
mcsk->dport=OSPF_PROTO; mcsk->dport=OSPF_PROTO;
@ -177,8 +202,6 @@ ospf_open_mc_socket(struct ospf_iface *ifa)
DBG("%s: SK_OPEN: mc opened.\n",p->name); DBG("%s: SK_OPEN: mc opened.\n",p->name);
return(mcsk); return(mcsk);
} }
else return(NULL);
}
sock * sock *
ospf_open_ip_socket(struct ospf_iface *ifa) ospf_open_ip_socket(struct ospf_iface *ifa)
@ -323,7 +346,7 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface)
{ {
debug("%s: using interface %s.\n", p->name, iface->name); debug("%s: using interface %s.\n", p->name, iface->name);
/* FIXME: Latter I'll use config - this is incorrect */ /* FIXME: Latter I'll use config - this is incorrect */
ifa=mb_alloc(p->pool, sizeof(struct ospf_iface)); ifa=mb_allocz(p->pool, sizeof(struct ospf_iface));
ifa->proto=(struct proto_ospf *)p; ifa->proto=(struct proto_ospf *)p;
ifa->iface=iface; ifa->iface=iface;
ospf_iface_default(ifa); ospf_iface_default(ifa);

View file

@ -434,6 +434,17 @@ neighbor_timer_hook(timer *timer)
p=(struct proto *)(ifa->proto); p=(struct proto *)(ifa->proto);
debug("%s: Inactivity timer fired on interface %s for neighbor %I.\n", debug("%s: Inactivity timer fired on interface %s for neighbor %I.\n",
p->name, ifa->iface->name, n->rid); p->name, ifa->iface->name, n->rid);
ospf_neigh_remove(n);
}
void
ospf_neigh_remove(struct ospf_neighbor *n)
{
struct ospf_iface *ifa;
struct proto *p;
ifa=n->ifa;
p=(struct proto *)(ifa->proto);
neigh_chstate(n, NEIGHBOR_DOWN); neigh_chstate(n, NEIGHBOR_DOWN);
tm_stop(n->inactim); tm_stop(n->inactim);
rfree(n->inactim); rfree(n->inactim);
@ -468,4 +479,3 @@ neighbor_timer_hook(timer *timer)
mb_free(n); mb_free(n);
debug("%s: Deleting neigbor.\n", p->name); debug("%s: Deleting neigbor.\n", p->name);
} }

View file

@ -21,5 +21,6 @@ struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
struct ospf_neighbor *find_neigh_noifa(struct proto_ospf *po, u32 rid); struct ospf_neighbor *find_neigh_noifa(struct proto_ospf *po, u32 rid);
struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid); struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid);
void neighbor_timer_hook(timer *timer); void neighbor_timer_hook(timer *timer);
void ospf_neigh_remove(struct ospf_neighbor *n);
#endif /* _BIRD_OSPF_NEIGHBOR_H_ */ #endif /* _BIRD_OSPF_NEIGHBOR_H_ */