]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Another bugfix in neighbor state machine.
authorOndrej Filip <feela@network.cz>
Tue, 9 May 2000 11:27:31 +0000 (11:27 +0000)
committerOndrej Filip <feela@network.cz>
Tue, 9 May 2000 11:27:31 +0000 (11:27 +0000)
proto/ospf/hello.c
proto/ospf/neighbor.c
proto/ospf/topology.c

index 2d1cdaaab0110952020ba453740dc3f46b011f34..74ae43abf5921b8248b754d0238639f3d5ea62dd 100644 (file)
@@ -52,7 +52,8 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
 {
   u32 nrid, *pnrid;
   struct ospf_neighbor *neigh,*n;
-  u8 i,twoway;
+  u8 i,twoway,oldpriority;
+  u32 olddr,oldbdr;
   char *beg=": Bad OSPF hello packet from ", *rec=" received: ";
 
   nrid=ntohl(((struct ospf_packet *)ps)->routerid);
@@ -136,42 +137,34 @@ ospf_hello_rx(struct ospf_hello_packet *ps, struct proto *p,
 
   if(!twoway) ospf_neigh_sm(n, INM_1WAYREC);
 
+  olddr = n->dr;
+  n->dr = ntohl(ps->dr);
+  oldbdr = n->bdr;
+  n->bdr = ntohl(ps->bdr);
+  oldpriority = n->priority;
+  n->priority = ps->priority;
+
   /* Check priority change */
-  if(n->priority!=(n->priority=ps->priority))
+  if(n->state>=NEIGHBOR_2WAY)
   {
-    ospf_int_sm(ifa, ISM_NEICH);
-  }
+    if(n->priority!=oldpriority) ospf_int_sm(ifa, ISM_NEICH);
 
-  /* Check neighbor's designed router idea */
-  if((n->rid!=ntohl(ps->dr)) && (ntohl(ps->bdr)==0) &&
-    (n->state>=NEIGHBOR_2WAY))
-  {
-    ospf_int_sm(ifa, ISM_BACKS);
-  }
-  if((n->rid==ntohl(ps->dr)) && (n->dr!=ntohl(ps->dr)))
-  {
-    ospf_int_sm(ifa, ISM_NEICH);
-  }
-  if((n->rid==n->dr) && (n->dr!=ntohl(ps->dr)))
-  {
-    ospf_int_sm(ifa, ISM_NEICH);
-  }
-  n->dr=ntohl(ps->dr); /* And update it */
+    /* Router is declaring itself ad DR and there is no BDR */
+    if((n->rid==n->dr) && (n->bdr==0)) ospf_int_sm(ifa, ISM_BACKS);
 
-  /* Check neighbor's backup designed router idea */
-  if((n->rid==ntohl(ps->bdr)) && (n->state>=NEIGHBOR_2WAY))
-  {
-    ospf_int_sm(ifa, ISM_BACKS);
-  }
-  if((n->rid==ntohl(ps->bdr)) && (n->bdr!=ntohl(ps->bdr)))
-  {
-    ospf_int_sm(ifa, ISM_NEICH);
-  }
-  if((n->rid==n->bdr) && (n->bdr!=ntohl(ps->bdr)))
-  {
-    ospf_int_sm(ifa, ISM_NEICH);
+    /* Neighbor is declaring itself as BDR */
+    if(n->rid==n->bdr) 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)))
+      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==olbddr) &&
+      (n->dr!=oldbdr)))
+      ospf_int_sm(ifa, ISM_NEICH);
   }
-  n->bdr=ntohl(ps->bdr);       /* And update it */
 
   ospf_neigh_sm(n, INM_HELLOREC);
 }
index 317da36d5d2f281e5f9f8e028c414799e9e2d30d..466c7ad57be2fa4b83f13f2247a608310cd59720 100644 (file)
@@ -29,6 +29,8 @@ neigh_chstate(struct ospf_neighbor *n, u8 state)
   {
     ifa=n->ifa;
     n->state=state;
+    if(state==2WAY && oldstate<2WAY) ospf_int_sm(n->ifa, ISM_NEICH);
+    if(state<2WAY && oldstate>=2WAY) ospf_int_sm(n->ifa, ISM_NEICH);
     if(oldstate==NEIGHBOR_FULL)        /* Decrease number of adjacencies */
     {
       ifa->fadj--;
@@ -227,7 +229,6 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
         {
           neigh_chstate(n,NEIGHBOR_EXSTART);
         }
-       ospf_int_sm(n->ifa, ISM_NEICH);
       }
       break;
     case INM_NEGDONE:
@@ -283,14 +284,9 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
     case INM_LLDOWN:
     case INM_INACTTIM:
       neigh_chstate(n,NEIGHBOR_DOWN);
-      ospf_int_sm(n->ifa, ISM_NEICH);
       break;
     case INM_1WAYREC:
-      if(n->state>=NEIGHBOR_2WAY)
-      {
-        neigh_chstate(n,NEIGHBOR_INIT);
-       ospf_int_sm(n->ifa, ISM_NEICH);
-      }
+      neigh_chstate(n,NEIGHBOR_INIT);
       break;
     default:
       die("%s: INM - Unknown event?",p->name);
index 4a41e3231fbf36c67cc9b47b49c247d0012b682e..81d95785699ec6610c487797e79e97fb4509910f 100644 (file)
@@ -284,11 +284,11 @@ originate_net_lsa(struct ospf_iface *ifa, struct proto_ospf *po)
   struct top_hash_entry *en;
   void *body;
 
-  DBG("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name, ifa->iface->name);
-  DBG("%s: State is:\"%u\" Fadj=%u.\n", po->proto.name, ifa->state,ifa->fadj);
 
   if(ifa->state!=OSPF_IS_DR) return;
 
+  DBG("%s: Originating Net lsa for iface \"%s\".\n", po->proto.name, ifa->iface->name);
+
   if(ifa->fadj==0)
   {
     if(ifa->nlsa==NULL) return;