summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ospfd/ospf_abr.c3
-rw-r--r--ospfd/ospf_asbr.c3
-rw-r--r--ospfd/ospf_lsa.c19
-rw-r--r--ospfd/ospf_spf.c73
-rw-r--r--ospfd/ospf_spf.h28
-rw-r--r--ospfd/ospf_vty.c6
6 files changed, 63 insertions, 69 deletions
diff --git a/ospfd/ospf_abr.c b/ospfd/ospf_abr.c
index 3f3f5356d..4c31bad0a 100644
--- a/ospfd/ospf_abr.c
+++ b/ospfd/ospf_abr.c
@@ -556,8 +556,7 @@ ospf_check_abr_status (struct ospf *ospf)
if (new_flags != ospf->flags)
{
- ospf_flag_spf_reason (SPF_FLAG_ABR_STATUS_CHANGE);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_ABR_STATUS_CHANGE);
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("ospf_check_abr_status(): new router flags: %x",new_flags);
ospf->flags = new_flags;
diff --git a/ospfd/ospf_asbr.c b/ospfd/ospf_asbr.c
index 397ab6037..ddb26dd54 100644
--- a/ospfd/ospf_asbr.c
+++ b/ospfd/ospf_asbr.c
@@ -291,8 +291,7 @@ ospf_asbr_status_update (struct ospf *ospf, u_char status)
}
/* Transition from/to status ASBR, schedule timer. */
- ospf_flag_spf_reason (SPF_FLAG_ASBR_STATUS_CHANGE);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_ASBR_STATUS_CHANGE);
ospf_router_lsa_update (ospf);
}
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index aa4d7ab16..b2c738f14 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -2468,10 +2468,7 @@ ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
ospf_refresher_register_lsa (ospf, new);
}
if (rt_recalc)
- {
- ospf_flag_spf_reason (SPF_FLAG_ROUTER_LSA_INSTALL);
- ospf_spf_calculate_schedule (ospf);
- }
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_ROUTER_LSA_INSTALL);
return new;
}
@@ -2505,10 +2502,7 @@ ospf_network_lsa_install (struct ospf *ospf,
ospf_refresher_register_lsa (ospf, new);
}
if (rt_recalc)
- {
- ospf_flag_spf_reason (SPF_FLAG_NETWORK_LSA_INSTALL);
- ospf_spf_calculate_schedule (ospf);
- }
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_NETWORK_LSA_INSTALL);
return new;
}
@@ -2531,8 +2525,7 @@ ospf_summary_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
/* This doesn't exist yet... */
ospf_summary_incremental_update(new); */
#else /* #if 0 */
- ospf_flag_spf_reason (SPF_FLAG_SUMMARY_LSA_INSTALL);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_SUMMARY_LSA_INSTALL);
#endif /* #if 0 */
}
@@ -2563,8 +2556,7 @@ ospf_summary_asbr_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
- RFC 2328 Section 16.5 implies it should be */
/* ospf_ase_calculate_schedule(); */
#else /* #if 0 */
- ospf_flag_spf_reason (SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL);
#endif /* #if 0 */
}
@@ -3086,8 +3078,7 @@ ospf_lsa_maxage_walker_remover (struct ospf *ospf, struct ospf_lsa *lsa)
ospf_ase_incremental_update (ospf, lsa);
break;
default:
- ospf_flag_spf_reason (SPF_FLAG_MAXAGE);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_MAXAGE);
break;
}
ospf_lsa_maxage (ospf, lsa);
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index f50d82e2e..bcd5e6193 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -50,42 +50,41 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
static unsigned int spf_reason_flags = 0;
-static void ospf_clear_spf_reason_flags (void )
+static void
+ospf_clear_spf_reason_flags (void)
{
spf_reason_flags = 0;
}
-void ospf_flag_spf_reason (unsigned int reason)
+static void
+ospf_spf_set_reason (ospf_spf_reason_t reason)
{
- if (reason <= SPF_FLAG_MAX_VALUE)
- spf_reason_flags |= reason;
- else
- spf_reason_flags |= SPF_FLAG_MISC;
+ spf_reason_flags |= 1 << reason;
}
static void
ospf_get_spf_reason_str (char *buf)
{
- if (buf)
+ if (!buf)
+ return;
+
+ buf[0] = '\0';
+ if (spf_reason_flags)
{
- buf[0] = '\0';
- if (spf_reason_flags)
- {
- if (spf_reason_flags & SPF_FLAG_ROUTER_LSA_INSTALL)
- strcat (buf, "R, ");
- if (spf_reason_flags & SPF_FLAG_NETWORK_LSA_INSTALL)
- strcat (buf, "N, ");
- if (spf_reason_flags & SPF_FLAG_SUMMARY_LSA_INSTALL)
- strcat (buf, "S, ");
- if (spf_reason_flags & SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL)
- strcat (buf, "AS, ");
- if (spf_reason_flags & SPF_FLAG_ABR_STATUS_CHANGE)
- strcat (buf, "ABR, ");
- if (spf_reason_flags & SPF_FLAG_ASBR_STATUS_CHANGE)
- strcat (buf, "ASBR, ");
- if (spf_reason_flags & SPF_FLAG_MAXAGE)
- strcat (buf, "M, ");
- }
+ if (spf_reason_flags & SPF_FLAG_ROUTER_LSA_INSTALL)
+ strcat (buf, "R, ");
+ if (spf_reason_flags & SPF_FLAG_NETWORK_LSA_INSTALL)
+ strcat (buf, "N, ");
+ if (spf_reason_flags & SPF_FLAG_SUMMARY_LSA_INSTALL)
+ strcat (buf, "S, ");
+ if (spf_reason_flags & SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL)
+ strcat (buf, "AS, ");
+ if (spf_reason_flags & SPF_FLAG_ABR_STATUS_CHANGE)
+ strcat (buf, "ABR, ");
+ if (spf_reason_flags & SPF_FLAG_ASBR_STATUS_CHANGE)
+ strcat (buf, "ASBR, ");
+ if (spf_reason_flags & SPF_FLAG_MAXAGE)
+ strcat (buf, "M, ");
buf[strlen(buf)-2] = '\0'; /* skip the last ", " */
}
}
@@ -1307,7 +1306,7 @@ ospf_spf_calculate_timer (struct thread *thread)
unsigned long ia_time, prune_time, rt_time;
unsigned long abr_time, total_spf_time, spf_time;
char rbuf[32]; /* reason_buf */
-
+
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("SPF: Timer (SPF calculation expire)");
@@ -1399,12 +1398,18 @@ ospf_spf_calculate_timer (struct thread *thread)
ospf_get_spf_reason_str (rbuf);
- if (IS_OSPF_ABR (ospf))
- zlog_info ("SPF Processing Time(usecs): # Areas: %d, SPF Time: %ld, InterArea: %ld, Prune: %ld, RouteInstall: %ld, ABR: %ld, Total: %ld, Reason: %s\n",
- areas_processed, spf_time, ia_time, prune_time, rt_time, abr_time, total_spf_time, rbuf);
- else
- zlog_info ("SPF Processing Time(usecs): SPF Time: %ld, InterArea: %ld, Prune: %ld, RouteInstall: %ld, Total: %ld, Reason: %s\n",
- spf_time, ia_time, prune_time, rt_time, total_spf_time, rbuf);
+ if (IS_DEBUG_OSPF_EVENT)
+ {
+ zlog_info ("SPF Processing Time(usecs): %ld", total_spf_time);
+ zlog_info ("\t SPF Time: %ld", spf_time);
+ zlog_info ("\t InterArea: %ld", ia_time);
+ zlog_info ("\t Prune: %ld", prune_time);
+ zlog_info ("\tRouteInstall: %ld", rt_time);
+ if (IS_OSPF_ABR (ospf))
+ zlog_info ("\t ABR: %ld (%d areas)",
+ abr_time, areas_processed);
+ zlog_info ("Reason(s) for SPF: %s", rbuf);
+ }
ospf_clear_spf_reason_flags ();
@@ -1414,7 +1419,7 @@ ospf_spf_calculate_timer (struct thread *thread)
/* Add schedule for SPF calculation. To avoid frequenst SPF calc, we
set timer for SPF calc. */
void
-ospf_spf_calculate_schedule (struct ospf *ospf)
+ospf_spf_calculate_schedule (struct ospf *ospf, ospf_spf_reason_t reason)
{
unsigned long delay, elapsed, ht;
struct timeval result;
@@ -1426,6 +1431,8 @@ ospf_spf_calculate_schedule (struct ospf *ospf)
if (ospf == NULL)
return;
+ ospf_spf_set_reason (reason);
+
/* SPF calculation timer is already scheduled. */
if (ospf->t_spf_calc)
{
diff --git a/ospfd/ospf_spf.h b/ospfd/ospf_spf.h
index c9c539ad7..e33b3e5f5 100644
--- a/ospfd/ospf_spf.h
+++ b/ospfd/ospf_spf.h
@@ -59,22 +59,20 @@ struct vertex_parent
int backlink; /* index back to parent for router-lsa's */
};
-extern void ospf_spf_calculate_schedule (struct ospf *);
+/* What triggered the SPF ? */
+typedef enum {
+ SPF_FLAG_ROUTER_LSA_INSTALL = 1,
+ SPF_FLAG_NETWORK_LSA_INSTALL,
+ SPF_FLAG_SUMMARY_LSA_INSTALL,
+ SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL,
+ SPF_FLAG_MAXAGE,
+ SPF_FLAG_ABR_STATUS_CHANGE,
+ SPF_FLAG_ASBR_STATUS_CHANGE,
+ SPF_FLAG_CONFIG_CHANGE,
+} ospf_spf_reason_t;
+
+extern void ospf_spf_calculate_schedule (struct ospf *, ospf_spf_reason_t);
extern void ospf_rtrs_free (struct route_table *);
/* void ospf_spf_calculate_timer_add (); */
-
-/* What triggered the SPF ? Can have at most 32 reasons with this */
-#define SPF_FLAG_ROUTER_LSA_INSTALL 0x1
-#define SPF_FLAG_NETWORK_LSA_INSTALL 0x2
-#define SPF_FLAG_SUMMARY_LSA_INSTALL 0x4
-#define SPF_FLAG_ASBR_SUMMARY_LSA_INSTALL 0x8
-#define SPF_FLAG_MAXAGE 0x10
-#define SPF_FLAG_ABR_STATUS_CHANGE 0x20
-#define SPF_FLAG_ASBR_STATUS_CHANGE 0x40
-#define SPF_FLAG_MAX_VALUE 0x40 /* Update this when adding flags */
-#define SPF_FLAG_MISC 0x1000000 /* Keep this last */
-
-extern void ospf_flag_spf_reason (unsigned int reason);
-
#endif /* _QUAGGA_OSPF_SPF_H */
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 54d82da63..c7137ab52 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -900,7 +900,7 @@ ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
{
vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
ospf_vl_add (ospf, vl_data);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
}
}
return vl_data;
@@ -2408,7 +2408,7 @@ DEFUN (ospf_compatible_rfc1583,
if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
}
return CMD_SUCCESS;
}
@@ -2428,7 +2428,7 @@ DEFUN (no_ospf_compatible_rfc1583,
if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
{
UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
- ospf_spf_calculate_schedule (ospf);
+ ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
}
return CMD_SUCCESS;
}