mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 16:48:43 +00:00
Better shutdown. (Flush my own router LSA and send 1WAY to every neighbor.)
Ext LSA originating and flushing added.
This commit is contained in:
parent
e8085abaa7
commit
4bd28fb68e
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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_ */
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user