mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 17:51:53 +00:00
Doc in neighbor.c and some tiny changes related to.
This commit is contained in:
parent
cadbb827f9
commit
7ab3ff6a28
@ -158,14 +158,14 @@ ospf_int_sm(struct ospf_iface *ifa, int event)
|
|||||||
case ISM_WAITF:
|
case ISM_WAITF:
|
||||||
if(ifa->state==OSPF_IS_WAITING)
|
if(ifa->state==OSPF_IS_WAITING)
|
||||||
{
|
{
|
||||||
bdr_election(ifa ,p);
|
bdr_election(ifa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ISM_NEICH:
|
case ISM_NEICH:
|
||||||
if((ifa->state==OSPF_IS_DROTHER) || (ifa->state==OSPF_IS_DR) ||
|
if((ifa->state==OSPF_IS_DROTHER) || (ifa->state==OSPF_IS_DR) ||
|
||||||
(ifa->state==OSPF_IS_BACKUP))
|
(ifa->state==OSPF_IS_BACKUP))
|
||||||
{
|
{
|
||||||
bdr_election(ifa ,p);
|
bdr_election(ifa);
|
||||||
schedule_rt_lsa(ifa->oa);
|
schedule_rt_lsa(ifa->oa);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
@ -22,6 +22,15 @@ const char *ospf_inm[]={ "hello received", "neighbor start", "2-way received",
|
|||||||
"adjacency ok?", "sequence mismatch", "1-way received", "kill neighbor",
|
"adjacency ok?", "sequence mismatch", "1-way received", "kill neighbor",
|
||||||
"inactivity timer", "line down" };
|
"inactivity timer", "line down" };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* neigh_chstate - handles changes related to new or lod state of neighbor
|
||||||
|
* @n: OSPF neighbor
|
||||||
|
* @state: new state
|
||||||
|
*
|
||||||
|
* Many actions has to be taken acording to state change of neighbor. It
|
||||||
|
* starts rxmt timers, call interface state machine etc.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
neigh_chstate(struct ospf_neighbor *n, u8 state)
|
neigh_chstate(struct ospf_neighbor *n, u8 state)
|
||||||
{
|
{
|
||||||
@ -49,14 +58,14 @@ neigh_chstate(struct ospf_neighbor *n, u8 state)
|
|||||||
{
|
{
|
||||||
ifa->fadj--;
|
ifa->fadj--;
|
||||||
schedule_rt_lsa(ifa->oa);
|
schedule_rt_lsa(ifa->oa);
|
||||||
originate_net_lsa(ifa,po);
|
originate_net_lsa(ifa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state==NEIGHBOR_FULL) /* Increase number of adjacencies */
|
if(state==NEIGHBOR_FULL) /* Increase number of adjacencies */
|
||||||
{
|
{
|
||||||
ifa->fadj++;
|
ifa->fadj++;
|
||||||
schedule_rt_lsa(ifa->oa);
|
schedule_rt_lsa(ifa->oa);
|
||||||
originate_net_lsa(ifa,po);
|
originate_net_lsa(ifa);
|
||||||
}
|
}
|
||||||
if(oldstate>=NEIGHBOR_EXSTART && state<NEIGHBOR_EXSTART)
|
if(oldstate>=NEIGHBOR_EXSTART && state<NEIGHBOR_EXSTART)
|
||||||
{
|
{
|
||||||
@ -203,9 +212,20 @@ can_do_adj(struct ospf_neighbor *n)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ospf_neigh_sm - ospf neighbor state machine
|
||||||
|
* @n: neighor
|
||||||
|
* @event: actual event
|
||||||
|
*
|
||||||
|
* This part implements neighbor state machine as described in 10.3 of
|
||||||
|
* RFC 2328. the only difference is that state %NEIGHBOR_ATTEMPT is not
|
||||||
|
* used. We discover neighbors on nonbroadcast networks using the
|
||||||
|
* same ways as on broadcast networks. The only difference is in
|
||||||
|
* sending hello packets. These are send to IPs listed in
|
||||||
|
* @ospf_iface->nbma_list .
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
||||||
/* Interface state machine */
|
|
||||||
{
|
{
|
||||||
struct proto *p=(struct proto *)(n->ifa->proto);
|
struct proto *p=(struct proto *)(n->ifa->proto);
|
||||||
struct proto_ospf *po=n->ifa->proto;
|
struct proto_ospf *po=n->ifa->proto;
|
||||||
@ -217,7 +237,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
|||||||
{
|
{
|
||||||
case INM_START:
|
case INM_START:
|
||||||
neigh_chstate(n,NEIGHBOR_ATTEMPT);
|
neigh_chstate(n,NEIGHBOR_ATTEMPT);
|
||||||
/* FIXME No NBMA now */
|
/* NBMA are used different way */
|
||||||
break;
|
break;
|
||||||
case INM_HELLOREC:
|
case INM_HELLOREC:
|
||||||
switch(n->state)
|
switch(n->state)
|
||||||
@ -298,14 +318,22 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* bdr_election - (Backup) Designed Router election
|
||||||
|
* @ifa: actual interface
|
||||||
|
*
|
||||||
|
* When wait time fires, it time to elect (Backup) Designed Router.
|
||||||
|
* Structure describing me is added to this list so every electing router
|
||||||
|
* has the same list. Backup Designed Router is elected before Designed
|
||||||
|
* Router. This process is described in 9.4 of RFC 2328.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
bdr_election(struct ospf_iface *ifa, struct proto *p)
|
bdr_election(struct ospf_iface *ifa)
|
||||||
{
|
{
|
||||||
struct ospf_neighbor *neigh,*ndr,*nbdr,me,*tmp;
|
struct ospf_neighbor *neigh,*ndr,*nbdr,me,*tmp;
|
||||||
u32 myid, ndrid, nbdrid;
|
u32 myid, ndrid, nbdrid;
|
||||||
int doadj;
|
int doadj;
|
||||||
|
struct proto *p=&ifa->proto->proto;
|
||||||
p=(struct proto *)(ifa->proto);
|
|
||||||
|
|
||||||
DBG("%s: (B)DR election.\n",p->name);
|
DBG("%s: (B)DR election.\n",p->name);
|
||||||
|
|
||||||
@ -323,7 +351,7 @@ bdr_election(struct ospf_iface *ifa, struct proto *p)
|
|||||||
nbdr=electbdr(ifa->neigh_list);
|
nbdr=electbdr(ifa->neigh_list);
|
||||||
ndr=electdr(ifa->neigh_list);
|
ndr=electdr(ifa->neigh_list);
|
||||||
|
|
||||||
if(ndr==NULL) ndr=nbdr; /* FIXME is this correct? */
|
if(ndr==NULL) ndr=nbdr;
|
||||||
|
|
||||||
if(((ifa->drid==myid) && (ndr!=&me))
|
if(((ifa->drid==myid) && (ndr!=&me))
|
||||||
|| ((ifa->drid!=myid) && (ndr==&me))
|
|| ((ifa->drid!=myid) && (ndr==&me))
|
||||||
@ -511,7 +539,6 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
|
|||||||
if(n->rid==ifa->bdrid) pos="bdr ";
|
if(n->rid==ifa->bdrid) pos="bdr ";
|
||||||
if(n->ifa->type==OSPF_IT_PTP) pos="ptp ";
|
if(n->ifa->type==OSPF_IT_PTP) pos="ptp ";
|
||||||
|
|
||||||
|
|
||||||
cli_msg(-1013,"%-18I\t%3u\t%s/%s\t%-5s\t%-18I\t%-10s",n->rid, n->priority,
|
cli_msg(-1013,"%-18I\t%3u\t%s/%s\t%-5s\t%-18I\t%-10s",n->rid, n->priority,
|
||||||
ospf_ns[n->state], pos, etime, n->ip,ifa->iface->name);
|
ospf_ns[n->state], pos, etime, n->ip,ifa->iface->name);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*
|
*
|
||||||
@ -16,7 +16,7 @@ struct ospf_neighbor *electdr(list nl);
|
|||||||
int can_do_adj(struct ospf_neighbor *n);
|
int can_do_adj(struct ospf_neighbor *n);
|
||||||
void tryadj(struct ospf_neighbor *n, struct proto *p);
|
void tryadj(struct ospf_neighbor *n, struct proto *p);
|
||||||
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
void ospf_neigh_sm(struct ospf_neighbor *n, int event);
|
||||||
void bdr_election(struct ospf_iface *ifa, struct proto *p);
|
void bdr_election(struct ospf_iface *ifa);
|
||||||
struct ospf_neighbor *find_neigh(struct ospf_iface *ifa, u32 rid);
|
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);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999-2000 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* BIRD -- OSPF
|
* BIRD -- OSPF
|
||||||
*
|
*
|
||||||
* (c) 1999-2000 Ondrej Filip <feela@network.cz>
|
* (c) 1999 - 2000 Ondrej Filip <feela@network.cz>
|
||||||
*
|
*
|
||||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||||
*/
|
*/
|
||||||
|
@ -169,6 +169,15 @@ addifa_rtlsa(struct ospf_iface *ifa)
|
|||||||
else ifa->oa=oa;
|
else ifa->oa=oa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* originate_rt_lsa - build new instance of router LSA
|
||||||
|
* @oa: ospf_area which is LSA built to
|
||||||
|
*
|
||||||
|
* It builds router LSA walking through all OSPF interfaces in
|
||||||
|
* specified OSPF area. This function is mostly called from
|
||||||
|
* area_disp(). Builds new LSA, increases sequence number (if old
|
||||||
|
* instance exists) and sets age of LSA to zero.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
originate_rt_lsa(struct ospf_area *oa)
|
originate_rt_lsa(struct ospf_area *oa)
|
||||||
{
|
{
|
||||||
@ -231,9 +240,19 @@ originate_net_lsa_body(struct ospf_iface *ifa, u16 *length,
|
|||||||
return net;
|
return net;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* originate_net_lsa - originates of deletes network LSA
|
||||||
|
* @ifa: interface which is LSA originated for
|
||||||
|
*
|
||||||
|
* Interface counts number of adjacent neighbor. If this number is
|
||||||
|
* lower then one or interface is not in state %OSPF_IS_DR it deletes
|
||||||
|
* and premature ages instance of network LSA for specified interface.
|
||||||
|
* In other case, new instance of network LSA is originated.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
|
originate_net_lsa(struct ospf_iface *ifa)
|
||||||
{
|
{
|
||||||
|
struct proto_ospf *po=ifa->proto;
|
||||||
struct ospf_lsa_header lsa;
|
struct ospf_lsa_header lsa;
|
||||||
u32 rtid=po->proto.cf->global->router_id;
|
u32 rtid=po->proto.cf->global->router_id;
|
||||||
struct top_hash_entry *en;
|
struct top_hash_entry *en;
|
||||||
@ -247,6 +266,8 @@ originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
|
|||||||
{
|
{
|
||||||
if(ifa->nlsa==NULL) return;
|
if(ifa->nlsa==NULL) return;
|
||||||
|
|
||||||
|
OSPF_TRACE(D_EVENTS, "Deleting Net lsa for iface \"%s\".",
|
||||||
|
ifa->iface->name);
|
||||||
ifa->nlsa->lsa.sn+=1;
|
ifa->nlsa->lsa.sn+=1;
|
||||||
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
ifa->nlsa->lsa.age=LSA_MAXAGE;
|
||||||
flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
|
flood_lsa(NULL,NULL,&ifa->nlsa->lsa,po,NULL,ifa->oa,0);
|
||||||
@ -257,6 +278,9 @@ originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSPF_TRACE(D_EVENTS, "Originating Net lsa for iface \"%s\".",
|
||||||
|
ifa->iface->name);
|
||||||
|
|
||||||
lsa.age=0;
|
lsa.age=0;
|
||||||
lsa.id=ipa_to_u32(ifa->iface->addr->ip);
|
lsa.id=ipa_to_u32(ifa->iface->addr->ip);
|
||||||
lsa.type=LSA_T_NET;
|
lsa.type=LSA_T_NET;
|
||||||
@ -317,6 +341,18 @@ originate_ext_lsa_body(net *n, rte *e, struct proto_ospf *po, struct ea_list *at
|
|||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* originate_ext_lsa - new route recived from nest and filters
|
||||||
|
* @n: network prefix and mask
|
||||||
|
* @e: rte
|
||||||
|
* @po: current instance of OSPF
|
||||||
|
* @attrs: list of extended attributes
|
||||||
|
*
|
||||||
|
* If I receive message that new route is installed, I try to originate an
|
||||||
|
* external LSA. LSA header of such LSA does not contain information about
|
||||||
|
* prefix lenght, so if I have to originate multiple LSAs for route with
|
||||||
|
* different prefixes I try to increment prefix id to find a "free" one.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs)
|
originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs)
|
||||||
{
|
{
|
||||||
@ -417,6 +453,13 @@ return (ospf_top_hash_u32(lsaid) + ospf_top_hash_u32((type==LSA_T_NET) ? lsaid :
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ospf_top_new - allocated new topology database
|
||||||
|
* @p: current instance of OSPF
|
||||||
|
*
|
||||||
|
* This dynamically hashed structure is often used for keeping LSAs. Mainly
|
||||||
|
* its used in @ospf_area structute.
|
||||||
|
*/
|
||||||
struct top_graph *
|
struct top_graph *
|
||||||
ospf_top_new(struct proto_ospf *p)
|
ospf_top_new(struct proto_ospf *p)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ struct top_hash_entry *ospf_hash_get(struct top_graph *, u32 lsa, u32 rtr, u32 t
|
|||||||
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
|
void ospf_hash_delete(struct top_graph *, struct top_hash_entry *);
|
||||||
void addifa_rtlsa(struct ospf_iface *ifa);
|
void addifa_rtlsa(struct ospf_iface *ifa);
|
||||||
void originate_rt_lsa(struct ospf_area *oa);
|
void originate_rt_lsa(struct ospf_area *oa);
|
||||||
void originate_net_lsa(struct ospf_iface *ifa,struct proto_ospf *po);
|
void originate_net_lsa(struct ospf_iface *ifa);
|
||||||
int can_flush_lsa(struct ospf_area *oa);
|
int can_flush_lsa(struct ospf_area *oa);
|
||||||
void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs);
|
void originate_ext_lsa(net *n, rte *e, struct proto_ospf *po, struct ea_list *attrs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user