]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Ehm, my (B)DR election was based on router id, but RFC says ip!
authorOndrej Filip <feela@network.cz>
Thu, 8 Jun 2000 01:49:19 +0000 (01:49 +0000)
committerOndrej Filip <feela@network.cz>
Thu, 8 Jun 2000 01:49:19 +0000 (01:49 +0000)
proto/ospf/hello.c
proto/ospf/neighbor.c
proto/ospf/ospf.h

index de1669f03e2a4b0fe4dd82487170668f5db9ef09..09dbfae1b2cced6556cea67bad18f0f04a3c5ddc 100644 (file)
@@ -53,7 +53,7 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
   u32 nrid, *pnrid;
   struct ospf_neighbor *neigh,*n;
   u8 i,twoway,oldpriority;
-  u32 olddr,oldbdr;
+  ip_addr olddr,oldbdr;
   char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
 
   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);
 
     /* 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);
 
     /* 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);
 
     /* Neighbor is newly declaring itself as DR or BDR */
-    if(((n->rid==n->dr) && (n->dr!=olddr)) || ((n->rid==n->bdr) &&
-      (n->bdr!=oldbdr)))
+    if(((ipa_compare(n->ip,n->dr)==0) && (ipa_compare(n->dr,olddr)!=0))
+      || ((ipa_compare(n->ip,n->bdr)==0) && (ipa_compare(n->bdr,oldbdr)!=0)))
       ospf_int_sm(ifa, ISM_NEICH);
 
     /* Neighbor is no more declaring itself as DR or BDR */
-    if(((n->rid==olddr) && (n->dr!=olddr)) || ((n->rid==oldbdr) &&
-      (n->bdr!=oldbdr)))
+    if(((ipa_compare(n->ip,olddr)==0) && (ipa_compare(n->dr,olddr)!=0))
+      || ((ipa_compare(n->ip,oldbdr)==0) && (ipa_compare(n->bdr,oldbdr)!=0)))
       ospf_int_sm(ifa, ISM_NEICH);
   }
 
@@ -212,8 +213,8 @@ hello_timer_hook(timer *timer)
   pkt->options=ifa->options;
   pkt->priority=ifa->priority;
   pkt->deadint=htonl(ifa->deadc*ifa->helloint);
-  pkt->dr=htonl(ifa->drid);
-  pkt->bdr=htonl(ifa->bdrid);
+  pkt->dr=htonl(ifa->drip);
+  pkt->bdr=htonl(ifa->bdrip);
 
   /* Fill all neighbors */
   i=0;
index ddc2e62565818e362f81e9fd8803c8d6f4f47e37..d22a60efd36c554c2492f77cce5c2a5c21649e3f 100644 (file)
@@ -100,9 +100,9 @@ electbdr(list nl)
   {
     if(neigh->state>=NEIGHBOR_2WAY)    /* Higher than 2WAY */
       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)
             {
@@ -145,7 +145,7 @@ electdr(list nl)
   {
     if(neigh->state>=NEIGHBOR_2WAY)    /* Higher than 2WAY */
       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)
           {
@@ -331,19 +331,20 @@ void
 bdr_election(struct ospf_iface *ifa)
 {
   struct ospf_neighbor *neigh,*ndr,*nbdr,me,*tmp;
-  u32 myid, ndrid, nbdrid;
+  u32 myid;
+  ip_addr ndrip, nbdrip;
   int doadj;
   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;
 
   me.state=NEIGHBOR_2WAY;
   me.rid=myid;
   me.priority=ifa->priority;
-  me.dr=ifa->drid;
-  me.bdr=ifa->bdrid;
+  me.dr=ifa->drip;
+  me.bdr=ifa->bdrip;
   me.ip=ifa->iface->addr->ip;
 
   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)))
   {
-    if(ndr==NULL) ifa->drid=me.dr=0;
-    else ifa->drid=me.dr=ndr->rid;
+    if(ndr==NULL) ifa->drip=me.dr=ipa_from_u32(0);
+    else ifa->drip=me.dr=ndr->ip;
 
-    if(nbdr==NULL) ifa->bdrid=me.bdr=0;
-    else ifa->bdrid=me.bdr=nbdr->rid;
+    if(nbdr==NULL) ifa->bdrip=me.bdr=ipa_from_u32(0);
+    else ifa->bdrip=me.bdr=nbdr->ip;
 
     nbdr=electbdr(ifa->neigh_list);
     ndr=electdr(ifa->neigh_list);
   }
 
-  if(ndr==NULL) ifa->drid=0;
-  if(ndr==NULL) ndrid=0;
-  else ndrid=ndr->rid;
+  if(ndr==NULL) ndrip=ipa_from_u32(0);
+  else ndrip=ndr->ip;
 
-  if(nbdr==NULL) nbdrid=0;
-  else nbdrid=nbdr->rid;
+  if(nbdr==NULL) nbdrip=ipa_from_u32(0);
+  else nbdrip=nbdr->ip;
 
   doadj=0;
-  if((ifa->drid!=ndrid) || (ifa->bdrid!=nbdrid)) doadj=1;
-  ifa->drid=ndrid;
-  if(ndrid==0)
+  if((ipa_compare(ifa->drip,ndrip)!=0) || (ipa_compare(ifa->bdrip,nbdrip)!=0))
+    doadj=1;
+
+  if(ndr==NULL)
   {
     ifa->drid=0;
     ifa->drip=ipa_from_u32(0);
   }
   else
   {
-    if((tmp=find_neigh(ifa,ndrid))==NULL)
-      bug("Error in DR election.");
-    ifa->drid=ndrid;
-    ifa->drip=tmp->ip;
+    ifa->drid=ndr->rid;
+    ifa->drip=ndr->ip;
   }
 
-  if(nbdrid==0)
+  if(nbdr==NULL)
   {
     ifa->bdrid=0;
     ifa->bdrip=ipa_from_u32(0);
   }
   else
   {
-    if((tmp=find_neigh(ifa,nbdrid))==NULL)
-      bug("Error in BDR election.");
-    ifa->bdrid=nbdrid;
-    ifa->bdrip=tmp->ip;
+    ifa->bdrid=nbdr->rid;
+    ifa->bdrip=nbdr->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);
   else
index d22b617c2006d8a885919db895c3df68a7715e2b..8854d8daa3c0bb530bbf3d7955182e1fcc7e38e0 100644 (file)
@@ -154,8 +154,8 @@ struct ospf_hello_packet {
   u8 options;
   u8 priority;
   u32 deadint;
-  u32 dr;
-  u32 bdr;
+  ip_addr dr;
+  ip_addr bdr;
 };
 
 struct immsb {
@@ -305,8 +305,8 @@ struct ospf_neighbor
   ip_addr ip;          /* IP of it's interface */
   u8 priority;         /* Priority */
   u8 options;          /* Options received */
-  u32 dr;              /* Neigbour's idea of DR */
-  u32 bdr;             /* Neigbour's idea of BDR */
+  ip_addr dr;          /* Neigbour's idea of DR */
+  ip_addr bdr;         /* Neigbour's idea of BDR */
   u8 adj;              /* built adjacency? */
   siterator dbsi;      /* Database summary list iterator */
   slist lsrql;         /* Link state request */