Ehm, my (B)DR election was based on router id, but RFC says ip!
This commit is contained in:
parent
17e29574bc
commit
423230f2f1
3 changed files with 40 additions and 42 deletions
|
@ -53,7 +53,7 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
|
||||||
u32 nrid, *pnrid;
|
u32 nrid, *pnrid;
|
||||||
struct ospf_neighbor *neigh,*n;
|
struct ospf_neighbor *neigh,*n;
|
||||||
u8 i,twoway,oldpriority;
|
u8 i,twoway,oldpriority;
|
||||||
u32 olddr,oldbdr;
|
ip_addr olddr,oldbdr;
|
||||||
char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
|
char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
|
||||||
|
|
||||||
nrid=ntohl(((struct ospf_packet *)ps)->routerid);
|
nrid=ntohl(((struct ospf_packet *)ps)->routerid);
|
||||||
|
@ -153,21 +153,22 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
|
||||||
if(n->priority!=oldpriority) ospf_int_sm(ifa, ISM_NEICH);
|
if(n->priority!=oldpriority) ospf_int_sm(ifa, ISM_NEICH);
|
||||||
|
|
||||||
/* Router is declaring itself ad DR and there is no BDR */
|
/* Router is declaring itself ad DR and there is no BDR */
|
||||||
if((n->rid==n->dr) && (n->bdr==0) && (n->state!=NEIGHBOR_FULL))
|
if((ipa_compare(n->ip,n->dr)==0) && (ipa_to_u32(n->bdr)==0)
|
||||||
|
&& (n->state!=NEIGHBOR_FULL))
|
||||||
ospf_int_sm(ifa, ISM_BACKS);
|
ospf_int_sm(ifa, ISM_BACKS);
|
||||||
|
|
||||||
/* Neighbor is declaring itself as BDR */
|
/* Neighbor is declaring itself as BDR */
|
||||||
if((n->rid==n->bdr) && (n->state!=NEIGHBOR_FULL))
|
if((ipa_compare(n->ip,n->bdr)==0) && (n->state!=NEIGHBOR_FULL))
|
||||||
ospf_int_sm(ifa, ISM_BACKS);
|
ospf_int_sm(ifa, ISM_BACKS);
|
||||||
|
|
||||||
/* Neighbor is newly declaring itself as DR or BDR */
|
/* Neighbor is newly declaring itself as DR or BDR */
|
||||||
if(((n->rid==n->dr) && (n->dr!=olddr)) || ((n->rid==n->bdr) &&
|
if(((ipa_compare(n->ip,n->dr)==0) && (ipa_compare(n->dr,olddr)!=0))
|
||||||
(n->bdr!=oldbdr)))
|
|| ((ipa_compare(n->ip,n->bdr)==0) && (ipa_compare(n->bdr,oldbdr)!=0)))
|
||||||
ospf_int_sm(ifa, ISM_NEICH);
|
ospf_int_sm(ifa, ISM_NEICH);
|
||||||
|
|
||||||
/* Neighbor is no more declaring itself as DR or BDR */
|
/* Neighbor is no more declaring itself as DR or BDR */
|
||||||
if(((n->rid==olddr) && (n->dr!=olddr)) || ((n->rid==oldbdr) &&
|
if(((ipa_compare(n->ip,olddr)==0) && (ipa_compare(n->dr,olddr)!=0))
|
||||||
(n->bdr!=oldbdr)))
|
|| ((ipa_compare(n->ip,oldbdr)==0) && (ipa_compare(n->bdr,oldbdr)!=0)))
|
||||||
ospf_int_sm(ifa, ISM_NEICH);
|
ospf_int_sm(ifa, ISM_NEICH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +213,8 @@ hello_timer_hook(timer *timer)
|
||||||
pkt->options=ifa->options;
|
pkt->options=ifa->options;
|
||||||
pkt->priority=ifa->priority;
|
pkt->priority=ifa->priority;
|
||||||
pkt->deadint=htonl(ifa->deadc*ifa->helloint);
|
pkt->deadint=htonl(ifa->deadc*ifa->helloint);
|
||||||
pkt->dr=htonl(ifa->drid);
|
pkt->dr=htonl(ifa->drip);
|
||||||
pkt->bdr=htonl(ifa->bdrid);
|
pkt->bdr=htonl(ifa->bdrip);
|
||||||
|
|
||||||
/* Fill all neighbors */
|
/* Fill all neighbors */
|
||||||
i=0;
|
i=0;
|
||||||
|
|
|
@ -100,9 +100,9 @@ electbdr(list nl)
|
||||||
{
|
{
|
||||||
if(neigh->state>=NEIGHBOR_2WAY) /* Higher than 2WAY */
|
if(neigh->state>=NEIGHBOR_2WAY) /* Higher than 2WAY */
|
||||||
if(neigh->priority>0) /* Eligible */
|
if(neigh->priority>0) /* Eligible */
|
||||||
if(neigh->rid!=neigh->dr) /* And not declaring itself DR */
|
if(ipa_compare(neigh->ip,neigh->dr)!=0) /* And not decl. itself DR */
|
||||||
{
|
{
|
||||||
if(neigh->rid==neigh->bdr) /* Declaring BDR */
|
if(ipa_compare(neigh->ip,neigh->bdr)==0) /* Declaring BDR */
|
||||||
{
|
{
|
||||||
if(n1!=NULL)
|
if(n1!=NULL)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ electdr(list nl)
|
||||||
{
|
{
|
||||||
if(neigh->state>=NEIGHBOR_2WAY) /* Higher than 2WAY */
|
if(neigh->state>=NEIGHBOR_2WAY) /* Higher than 2WAY */
|
||||||
if(neigh->priority>0) /* Eligible */
|
if(neigh->priority>0) /* Eligible */
|
||||||
if(neigh->rid==neigh->dr) /* And declaring itself DR */
|
if(ipa_compare(neigh->ip,neigh->dr)==0) /* And declaring itself DR */
|
||||||
{
|
{
|
||||||
if(n!=NULL)
|
if(n!=NULL)
|
||||||
{
|
{
|
||||||
|
@ -331,19 +331,20 @@ void
|
||||||
bdr_election(struct ospf_iface *ifa)
|
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;
|
||||||
|
ip_addr ndrip, nbdrip;
|
||||||
int doadj;
|
int doadj;
|
||||||
struct proto *p=&ifa->proto->proto;
|
struct proto *p=&ifa->proto->proto;
|
||||||
|
|
||||||
DBG("%s: (B)DR election.\n",p->name);
|
DBG("(B)DR election.\n");
|
||||||
|
|
||||||
myid=p->cf->global->router_id;
|
myid=p->cf->global->router_id;
|
||||||
|
|
||||||
me.state=NEIGHBOR_2WAY;
|
me.state=NEIGHBOR_2WAY;
|
||||||
me.rid=myid;
|
me.rid=myid;
|
||||||
me.priority=ifa->priority;
|
me.priority=ifa->priority;
|
||||||
me.dr=ifa->drid;
|
me.dr=ifa->drip;
|
||||||
me.bdr=ifa->bdrid;
|
me.bdr=ifa->bdrip;
|
||||||
me.ip=ifa->iface->addr->ip;
|
me.ip=ifa->iface->addr->ip;
|
||||||
|
|
||||||
add_tail(&ifa->neigh_list, NODE &me);
|
add_tail(&ifa->neigh_list, NODE &me);
|
||||||
|
@ -358,53 +359,49 @@ bdr_election(struct ospf_iface *ifa)
|
||||||
|| ((ifa->bdrid==myid) && (nbdr!=&me))
|
|| ((ifa->bdrid==myid) && (nbdr!=&me))
|
||||||
|| ((ifa->bdrid!=myid) && (nbdr==&me)))
|
|| ((ifa->bdrid!=myid) && (nbdr==&me)))
|
||||||
{
|
{
|
||||||
if(ndr==NULL) ifa->drid=me.dr=0;
|
if(ndr==NULL) ifa->drip=me.dr=ipa_from_u32(0);
|
||||||
else ifa->drid=me.dr=ndr->rid;
|
else ifa->drip=me.dr=ndr->ip;
|
||||||
|
|
||||||
if(nbdr==NULL) ifa->bdrid=me.bdr=0;
|
if(nbdr==NULL) ifa->bdrip=me.bdr=ipa_from_u32(0);
|
||||||
else ifa->bdrid=me.bdr=nbdr->rid;
|
else ifa->bdrip=me.bdr=nbdr->ip;
|
||||||
|
|
||||||
nbdr=electbdr(ifa->neigh_list);
|
nbdr=electbdr(ifa->neigh_list);
|
||||||
ndr=electdr(ifa->neigh_list);
|
ndr=electdr(ifa->neigh_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ndr==NULL) ifa->drid=0;
|
if(ndr==NULL) ndrip=ipa_from_u32(0);
|
||||||
if(ndr==NULL) ndrid=0;
|
else ndrip=ndr->ip;
|
||||||
else ndrid=ndr->rid;
|
|
||||||
|
|
||||||
if(nbdr==NULL) nbdrid=0;
|
if(nbdr==NULL) nbdrip=ipa_from_u32(0);
|
||||||
else nbdrid=nbdr->rid;
|
else nbdrip=nbdr->ip;
|
||||||
|
|
||||||
doadj=0;
|
doadj=0;
|
||||||
if((ifa->drid!=ndrid) || (ifa->bdrid!=nbdrid)) doadj=1;
|
if((ipa_compare(ifa->drip,ndrip)!=0) || (ipa_compare(ifa->bdrip,nbdrip)!=0))
|
||||||
ifa->drid=ndrid;
|
doadj=1;
|
||||||
if(ndrid==0)
|
|
||||||
|
if(ndr==NULL)
|
||||||
{
|
{
|
||||||
ifa->drid=0;
|
ifa->drid=0;
|
||||||
ifa->drip=ipa_from_u32(0);
|
ifa->drip=ipa_from_u32(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((tmp=find_neigh(ifa,ndrid))==NULL)
|
ifa->drid=ndr->rid;
|
||||||
bug("Error in DR election.");
|
ifa->drip=ndr->ip;
|
||||||
ifa->drid=ndrid;
|
|
||||||
ifa->drip=tmp->ip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(nbdrid==0)
|
if(nbdr==NULL)
|
||||||
{
|
{
|
||||||
ifa->bdrid=0;
|
ifa->bdrid=0;
|
||||||
ifa->bdrip=ipa_from_u32(0);
|
ifa->bdrip=ipa_from_u32(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if((tmp=find_neigh(ifa,nbdrid))==NULL)
|
ifa->bdrid=nbdr->rid;
|
||||||
bug("Error in BDR election.");
|
ifa->bdrip=nbdr->ip;
|
||||||
ifa->bdrid=nbdrid;
|
|
||||||
ifa->bdrip=tmp->ip;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG("%s: DR=%I, BDR=%I\n",p->name, ifa->drid, ifa->bdrid);
|
DBG("DR=%I, BDR=%I\n", ifa->drid, ifa->bdrid);
|
||||||
|
|
||||||
if(myid==ifa->drid) iface_chstate(ifa, OSPF_IS_DR);
|
if(myid==ifa->drid) iface_chstate(ifa, OSPF_IS_DR);
|
||||||
else
|
else
|
||||||
|
|
|
@ -154,8 +154,8 @@ struct ospf_hello_packet {
|
||||||
u8 options;
|
u8 options;
|
||||||
u8 priority;
|
u8 priority;
|
||||||
u32 deadint;
|
u32 deadint;
|
||||||
u32 dr;
|
ip_addr dr;
|
||||||
u32 bdr;
|
ip_addr bdr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct immsb {
|
struct immsb {
|
||||||
|
@ -305,8 +305,8 @@ struct ospf_neighbor
|
||||||
ip_addr ip; /* IP of it's interface */
|
ip_addr ip; /* IP of it's interface */
|
||||||
u8 priority; /* Priority */
|
u8 priority; /* Priority */
|
||||||
u8 options; /* Options received */
|
u8 options; /* Options received */
|
||||||
u32 dr; /* Neigbour's idea of DR */
|
ip_addr dr; /* Neigbour's idea of DR */
|
||||||
u32 bdr; /* Neigbour's idea of BDR */
|
ip_addr bdr; /* Neigbour's idea of BDR */
|
||||||
u8 adj; /* built adjacency? */
|
u8 adj; /* built adjacency? */
|
||||||
siterator dbsi; /* Database summary list iterator */
|
siterator dbsi; /* Database summary list iterator */
|
||||||
slist lsrql; /* Link state request */
|
slist lsrql; /* Link state request */
|
||||||
|
|
Loading…
Reference in a new issue