[quagga-dev 7428] [PATCH 1/5] ospfd: ospf_hello() should only kick state machine once.

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Sun Nov 29 12:08:36 GMT 2009


The 2 last bullets in RFC 2328, section 10.5 are mutually
exclusive, make is so.
---
 ospfd/ospf_packet.c |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 8f61ed1..8990e45 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -902,10 +902,7 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh,
       (old_state == NSM_Down || old_state == NSM_Attempt))
     {
       OSPF_NSM_EVENT_EXECUTE (nbr, NSM_OneWayReceived);
-      nbr->priority = hello->priority;
-      nbr->d_router = hello->d_router;
-      nbr->bd_router = hello->bd_router;
-      return;
+      goto done;
     }
 
   if (ospf_nbr_bidirectional (&oi->ospf->router_id, hello->neighbors,
@@ -917,42 +914,50 @@ ospf_hello (struct ip *iph, struct ospf_header *ospfh,
   else
     {
       OSPF_NSM_EVENT_EXECUTE (nbr, NSM_OneWayReceived);
-      /* Set neighbor information. */
-      nbr->priority = hello->priority;
-      nbr->d_router = hello->d_router;
-      nbr->bd_router = hello->bd_router;
-      return;
+      goto done;
     }
 
+  /* Neighbor priority check. */
+  if (nbr->priority >= 0 && nbr->priority != hello->priority)
+    OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
+
   /* If neighbor itself declares DR and no BDR exists,
      cause event BackupSeen */
-  if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router))
-    if (hello->bd_router.s_addr == 0 && oi->state == ISM_Waiting)
-      OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen);
-
-  /* neighbor itself declares BDR. */
   if (oi->state == ISM_Waiting &&
-      IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router))
-    OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen);
-
+      IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router) &&
+      hello->bd_router.s_addr == 0)
+    {
+      OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen);
+      goto done;
+    }
   /* had not previously. */
   if ((IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->d_router) &&
        IPV4_ADDR_CMP (&nbr->address.u.prefix4, &nbr->d_router)) ||
       (IPV4_ADDR_CMP (&nbr->address.u.prefix4, &hello->d_router) &&
        IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->d_router)))
-    OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
+    {
+      OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
+      goto done;
+    }
 
+  /* neighbor itself declares BDR. */
+  if (oi->state == ISM_Waiting &&
+      IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router))
+    {
+      OSPF_ISM_EVENT_SCHEDULE (oi, ISM_BackupSeen);
+      goto done;
+    }
   /* had not previously. */
   if ((IPV4_ADDR_SAME (&nbr->address.u.prefix4, &hello->bd_router) &&
        IPV4_ADDR_CMP (&nbr->address.u.prefix4, &nbr->bd_router)) ||
       (IPV4_ADDR_CMP (&nbr->address.u.prefix4, &hello->bd_router) &&
        IPV4_ADDR_SAME (&nbr->address.u.prefix4, &nbr->bd_router)))
-    OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
-
-  /* Neighbor priority check. */
-  if (nbr->priority >= 0 && nbr->priority != hello->priority)
-    OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
+    {
+      OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
+      goto done;
+    }
 
+ done:
   /* Set neighbor information. */
   nbr->priority = hello->priority;
   nbr->d_router = hello->d_router;
-- 
1.6.4.4




More information about the Quagga-dev mailing list