summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-07-04 13:57:49 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-07-04 13:57:49 +0000
commitf7a76abf3078bac6251d4e27f0143a9c0b14dde7 (patch)
tree7046a50c712642cd8b6bf05f80d41b242007c7b3
parent5db95bc2dda90dc462f77dd2610c004db685252e (diff)
[ospfd] Apply some simplifications to ospf_nsm, from Andrew's suggestions
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.
-rw-r--r--ospfd/ChangeLog9
-rw-r--r--ospfd/ospf_nsm.c33
2 files changed, 18 insertions, 24 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index eff71fca..054935b3 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -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
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 149ff7cb..11da503e 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -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