summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-07-04 13:35:24 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-07-04 13:35:24 +0000
commitd7b0fb62ec78cfd31ff8d905490a5c929c44e971 (patch)
tree887a83d76e59217fd1e84f4feb1aa4ff7312a70e /ospfd
parent08942da588b78f41916ebd6c75fa668b18160ee7 (diff)
[ospfd] consolidate adjacency check logic
2006-07-02 Paul Jakma <paul.jakma@sun.com> * ospf_nsm.c: (nsm_should_adj) New function, just consolidate the 10.4 adjacency check from nsm_twoway_received/nsm_adj_ok. (nsm_twoway_received/nsm_adj_ok) Use former.
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ChangeLog6
-rw-r--r--ospfd/ospf_nsm.c73
2 files changed, 39 insertions, 40 deletions
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index e4dfbee5..7486b073 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-02 Paul Jakma <paul.jakma@sun.com>
+
+ * ospf_nsm.c: (nsm_should_adj) New function, just consolidate the
+ 10.4 adjacency check from nsm_twoway_received/nsm_adj_ok.
+ (nsm_twoway_received/nsm_adj_ok) Use former.
+
2006-06-30 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* ospf_vty.c: (show_ip_ospf_neighbor_id) Should show all instances
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index df9a5251..c5a55367 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -139,6 +139,34 @@ nsm_timer_set (struct ospf_neighbor *nbr)
}
}
+/* 10.4 of RFC2328, indicate whether an adjacency is appropriate with
+ * the given neighbour
+ */
+static int
+nsm_should_adj (struct ospf_neighbor *nbr)
+{
+ struct ospf_interface *oi;
+
+ oi = nbr->oi;
+
+ /* 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))
+ || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi)))
+ return 1;
+
+ return 0;
+}
/* OSPF NSM functions. */
static int
@@ -186,25 +214,9 @@ nsm_start (struct ospf_neighbor *nbr)
static int
nsm_twoway_received (struct ospf_neighbor *nbr)
{
- struct ospf_interface *oi;
int next_state = NSM_TwoWay;
- oi = nbr->oi;
-
- /* These netowork types must be adjacency. */
- if (oi->type == OSPF_IFTYPE_POINTOPOINT ||
- oi->type == OSPF_IFTYPE_POINTOMULTIPOINT ||
- oi->type == OSPF_IFTYPE_VIRTUALLINK)
- next_state = NSM_ExStart;
-
- /* 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)))
- next_state = NSM_ExStart;
-
- /* Neighboring Router is the DRouter or the BDRouter. */
- if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR(oi)) ||
- IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR(oi)))
+ if (nsm_should_adj (nbr))
next_state = NSM_ExStart;
return next_state;
@@ -359,31 +371,12 @@ nsm_bad_ls_req (struct ospf_neighbor *nbr)
static int
nsm_adj_ok (struct ospf_neighbor *nbr)
{
- struct ospf_interface *oi;
- int next_state;
- int flag = 0;
-
- oi = nbr->oi;
- next_state = nbr->state;
-
- /* These netowork types must be adjacency. */
- if (oi->type == OSPF_IFTYPE_POINTOPOINT
- || oi->type == OSPF_IFTYPE_POINTOMULTIPOINT
- || oi->type == OSPF_IFTYPE_VIRTUALLINK)
- flag = 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)))
- flag = 1;
-
- if (IPV4_ADDR_SAME (&nbr->address.u.prefix4, &DR (oi))
- || IPV4_ADDR_SAME (&nbr->address.u.prefix4, &BDR (oi)))
- flag = 1;
+ int next_state = nbr->state;
+ int adj = nsm_should_adj (nbr);
- if (nbr->state == NSM_TwoWay && flag == 1)
+ if (nbr->state == NSM_TwoWay && adj == 1)
next_state = NSM_ExStart;
- else if (nbr->state >= NSM_ExStart && flag == 0)
+ else if (nbr->state >= NSM_ExStart && adj == 0)
next_state = NSM_TwoWay;
return next_state;