]> git.puffer.fish Git - mirror/frr.git/commitdiff
[ospfd] Apply some simplifications to ospf_nsm, from Andrew's suggestions
authorPaul Jakma <paul.jakma@sun.com>
Tue, 4 Jul 2006 13:57:49 +0000 (13:57 +0000)
committerPaul Jakma <paul.jakma@sun.com>
Tue, 4 Jul 2006 13:57:49 +0000 (13:57 +0000)
2006-07-04 Paul Jakma <paul.jakma@sun.com>

* ospf_nsm.c: (general) Various small cleanups from Andrew's
  review of last set of patches.
  (nsm_timer_set) Loading, Full and default can share
  same code too.
  (nsm_should_adj) Can just be one big OR.
  (nsm_twoway_received) Collapse into return statement.

ospfd/ChangeLog
ospfd/ospf_nsm.c

index eff71fca4b38294cc2c748ea62bfcd8fae8aa1df..054935b30f1dc9914ce20bde4b205b2cc3dcac66 100644 (file)
@@ -1,3 +1,12 @@
+2006-07-04 Paul Jakma <paul.jakma@sun.com>
+
+       * ospf_nsm.c: (general) Various small cleanups from Andrew's
+         review of last set of patches.
+         (nsm_timer_set) Loading, Full and default can share
+         same code too.
+         (nsm_should_adj) Can just be one big OR.
+         (nsm_twoway_received) Collapse into return statement.
+
 2006-07-02 Paul Jakma <paul.jakma@sun.com>
 
        * ospf_nsm.c: (nsm_should_adj) New function, just consolidate the
index 149ff7cbd5cce3eef052cd5a6f37758aeb930c83..11da503e46dd338b1d0e3c2d8bc2bbfdcf9d856b 100644 (file)
@@ -125,11 +125,7 @@ nsm_timer_set (struct ospf_neighbor *nbr)
        OSPF_NSM_TIMER_OFF (nbr->t_db_desc);
       break;
     case NSM_Loading:
-      OSPF_NSM_TIMER_OFF (nbr->t_db_desc);
-      break;
     case NSM_Full:
-      OSPF_NSM_TIMER_OFF (nbr->t_db_desc);
-      break;
     default:
       OSPF_NSM_TIMER_OFF (nbr->t_db_desc);
       break;
@@ -142,23 +138,17 @@ nsm_timer_set (struct ospf_neighbor *nbr)
 static int
 nsm_should_adj (struct ospf_neighbor *nbr)
 {
-  struct ospf_interface *oi;
-
-  oi = nbr->oi;
+  struct ospf_interface *oi = nbr->oi;
 
-  /* These network types must always form adjacencies. */
+      /* These network types must always form adjacencies. */
   if (oi->type == OSPF_IFTYPE_POINTOPOINT
       || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT
-      || oi->type == OSPF_IFTYPE_VIRTUALLINK)
-    return 1;
-
-  /* Router itself is the DRouter or the BDRouter. */
-  if (IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))
-      || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi)))
-    return 1;
-
-  /* Neighboring Router is the DRouter or the BDRouter. */
-  if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi))
+      || oi->type == OSPF_IFTYPE_VIRTUALLINK
+      /* Router itself is the DRouter or the BDRouter. */
+      || IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))
+      || IPV4_ADDR_SAME (&oi->address->u.prefix4, &BDR (oi))
+      /* Neighboring Router is the DRouter or the BDRouter. */
+      || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi))
       || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi)))
     return 1;
 
@@ -211,12 +201,7 @@ nsm_start (struct ospf_neighbor *nbr)
 static int
 nsm_twoway_received (struct ospf_neighbor *nbr)
 {
-  int next_state = NSM_TwoWay;
-
-  if (nsm_should_adj (nbr))
-    next_state = NSM_ExStart;
-
-  return next_state;
+  return (nsm_should_adj (nbr) ? NSM_ExStart : NSM_TwoWay);
 }
 
 int