summaryrefslogtreecommitdiff
path: root/ospfd/ospf_vty.c
diff options
context:
space:
mode:
authorpaul <paul>2005-10-29 12:50:09 +0000
committerpaul <paul>2005-10-29 12:50:09 +0000
commit88d6cf37f66c3b7d1abdaa20875418192d5219b8 (patch)
tree4843e77f622d3bf9e5df5c75de381e06e3126d6b /ospfd/ospf_vty.c
parent92779fe51dd061ab1502a9acdc0cf5241748e0c7 (diff)
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support * ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define. (struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for options, to allow shutdown to distinguish between complete shutdown and shutdown of a subset of ospf instances. (struct ospf) Add stub_router_{startup,shutdown_}time, configuration of startup and shutdown time for stub-router. Add t_graceful_shutdown struct thread, timer for graceful shutdown, if needed. (struct ospf_area) Add stub_router_state - run time state of stub-router for an area. Add flags for ADMIN, IS and WAS states. Add t_stub_router, timer thread to resend router-lsa for an area. * ospf_lsa.c: (ospf_link_cost) new simple function to spit out either the given lnks cost or infinite cost if stub-router is in effect. (lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use previous function for transit-links. (ospf_stub_router_timer) timer thread for end of startup stub router. Change state as required for the area and setup re-origination of router-lsa. (ospf_stub_router_check) Check/do whether stub-router should be enabled, and whether it requires timer to be setup. (ospf_router_lsa_new) call previous function at top. (ospf_router_lsa_originate) no external callers, made static. * ospf_lsa.h: (ospf_router_lsa_originate) removed. * ospf_main.c: (sigint) make static. remove call to exit, as ospf_terminate now deals with exiting. * ospf_route.c: (ospf_terminate) removed, now in ospfd.c. * ospf_vty.c: (show_ip_ospf_area) print out state of stub-router, if active. (show_ip_ospf) print out configuration of stub-router support, and details of graceful-shutdown if the timer is active. ((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new commands to (de-)?configure stub-router support. (config_write_stub_router) write out config of stub-router. (ospf_config_write) call previous. (ospf_vty_init) install the new stub-router commands. * ospfd.c: various functions made static. (ospf_new) Set defaults for stub-router. Graceful shutdown is made to default on, just to be adventerous. (ospf_graceful_shutdown_finish) new function, final part of shutdown. (ospf_graceful_shutdown_timer) timer thread wrapper for graceful-shutdown. (ospf_graceful_shutdown_check) check whether to setup timer for shutdown or proceed directly to final shutdown. (ospf_terminate) moved here from ospf_route.c, call ospf_finish for each instance. (ospf_finish) renamed to ospf_finish_final and made static. (ospf_finish) new function, exported wrapper around ospf_graceful_shutdown_check. (ospf_finish_final) complete shutdown of an instance. Add missing TIMER_OFF's of two timer threads. (ospf_area_free) opaque self lsa timer should be turned off.
Diffstat (limited to 'ospfd/ospf_vty.c')
-rw-r--r--ospfd/ospf_vty.c223
1 files changed, 217 insertions, 6 deletions
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index e56027be..c3cc4cb4 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2517,7 +2517,21 @@ show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
VTY_NEWLINE);
}
}
-
+ /* Stub-router state for this area */
+ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
+ {
+ char timebuf[9];
+ vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
+ VTY_NEWLINE);
+ if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
+ vty_out (vty, " Administratively activated (indefinitely)%s",
+ VTY_NEWLINE);
+ if (area->t_stub_router)
+ vty_out (vty, " Active from startup, %s remaining%s",
+ ospf_timer_dump (area->t_stub_router, timebuf,
+ sizeof(timebuf)), VTY_NEWLINE);
+ }
+
/* Show number of fully adjacent neighbors. */
vty_out (vty, " Number of fully adjacent neighbors in this area:"
" %d%s", area->full_nbrs, VTY_NEWLINE);
@@ -2592,7 +2606,12 @@ DEFUN (show_ip_ospf,
vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
inet_ntoa (ospf->router_id),
VTY_NEWLINE);
-
+
+ /* Graceful shutdown */
+ if (ospf->t_graceful_shutdown)
+ vty_out (vty, " Graceful shutdown in progress, %s remaining%s",
+ ospf_timer_dump (ospf->t_graceful_shutdown,
+ timebuf, sizeof (timebuf)), VTY_NEWLINE);
/* Show capability. */
vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
@@ -2607,7 +2626,21 @@ DEFUN (show_ip_ospf,
" (origination blocked)" : "",
VTY_NEWLINE);
#endif /* HAVE_OPAQUE_LSA */
-
+
+ /* Show stub-router configuration */
+ if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
+ || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
+ {
+ vty_out (vty, " Stub router advertisement is configured%s",
+ VTY_NEWLINE);
+ if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
+ vty_out (vty, " Enabled for %us after start-up%s",
+ ospf->stub_router_startup_time, VTY_NEWLINE);
+ if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
+ vty_out (vty, " Enabled for %us prior to full shutdown%s",
+ ospf->stub_router_shutdown_time, VTY_NEWLINE);
+ }
+
/* Show SPF timers. */
vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
" Minimum hold time between consecutive SPFs %d millisec(s)%s"
@@ -6771,7 +6804,171 @@ ALIAS (no_ip_ospf_mtu_ignore,
"IP Information\n"
"OSPF interface commands\n"
"Disable mtu mismatch detection\n")
+
+DEFUN (ospf_max_metric_router_lsa_admin,
+ ospf_max_metric_router_lsa_admin_cmd,
+ "max-metric router-lsa administrative",
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Administratively applied, for an indefinite period\n")
+{
+ struct listnode *ln;
+ struct ospf_area *area;
+ struct ospf *ospf = vty->index;
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
+ {
+ SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
+
+ if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
+ ospf_router_lsa_timer_add (area);
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_max_metric_router_lsa_admin,
+ no_ospf_max_metric_router_lsa_admin_cmd,
+ "no max-metric router-lsa administrative",
+ NO_STR
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Administratively applied, for an indefinite period\n")
+{
+ struct listnode *ln;
+ struct ospf_area *area;
+ struct ospf *ospf = vty->index;
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
+ {
+ UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
+
+ /* Don't trample on the start-up stub timer */
+ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
+ && !area->t_stub_router)
+ {
+ UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
+ ospf_router_lsa_timer_add (area);
+ }
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN (ospf_max_metric_router_lsa_startup,
+ ospf_max_metric_router_lsa_startup_cmd,
+ "max-metric router-lsa on-startup <5-86400>",
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Automatically advertise stub Router-LSA on startup of OSPF\n"
+ "Time (seconds) to advertise self as stub-router\n")
+{
+ unsigned int seconds;
+ struct ospf *ospf = vty->index;
+
+ if (argc != 1)
+ {
+ vty_out (vty, "%% Must supply stub-router period");
+ return CMD_WARNING;
+ }
+
+ VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
+
+ ospf->stub_router_startup_time = seconds;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_max_metric_router_lsa_startup,
+ no_ospf_max_metric_router_lsa_startup_cmd,
+ "no max-metric router-lsa on-startup",
+ NO_STR
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Automatically advertise stub Router-LSA on startup of OSPF\n")
+{
+ struct listnode *ln;
+ struct ospf_area *area;
+ struct ospf *ospf = vty->index;
+
+ ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
+
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
+ {
+ SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
+ OSPF_TIMER_OFF (area->t_stub_router);
+
+ /* Don't trample on admin stub routed */
+ if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
+ {
+ UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
+ ospf_router_lsa_timer_add (area);
+ }
+ }
+ return CMD_SUCCESS;
+}
+
+DEFUN (ospf_max_metric_router_lsa_shutdown,
+ ospf_max_metric_router_lsa_shutdown_cmd,
+ "max-metric router-lsa on-shutdown <5-86400>",
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Advertise stub-router prior to full shutdown of OSPF\n"
+ "Time (seconds) to wait till full shutdown\n")
+{
+ unsigned int seconds;
+ struct ospf *ospf = vty->index;
+
+ if (argc != 1)
+ {
+ vty_out (vty, "%% Must supply stub-router shutdown period");
+ return CMD_WARNING;
+ }
+
+ VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
+
+ ospf->stub_router_shutdown_time = seconds;
+
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_max_metric_router_lsa_shutdown,
+ no_ospf_max_metric_router_lsa_shutdown_cmd,
+ "no max-metric router-lsa on-shutdown",
+ NO_STR
+ "OSPF maximum / infinite-distance metric\n"
+ "Advertise own Router-LSA with infinite distance (stub router)\n"
+ "Advertise stub-router prior to full shutdown of OSPF\n")
+{
+ struct ospf *ospf = vty->index;
+
+ ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
+
+ return CMD_SUCCESS;
+}
+
+static void
+config_write_stub_router (struct vty *vty, struct ospf *ospf)
+{
+ struct listnode *ln;
+ struct ospf_area *area;
+
+ if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
+ vty_out (vty, " max-metric router-lsa on-startup %u%s",
+ ospf->stub_router_startup_time, VTY_NEWLINE);
+ if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
+ vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
+ ospf->stub_router_shutdown_time, VTY_NEWLINE);
+ for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
+ {
+ if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
+ {
+ vty_out (vty, " max-metric router-lsa administrative%s",
+ VTY_NEWLINE);
+ break;
+ }
+ }
+ return;
+}
+
static void
show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
{
@@ -7612,9 +7809,12 @@ ospf_config_write (struct vty *vty)
ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
vty_out (vty, " timers throttle spf %d %d %d%s",
- ospf->spf_delay, ospf->spf_holdtime,
+ ospf->spf_delay, ospf->spf_holdtime,
ospf->spf_max_holdtime, VTY_NEWLINE);
-
+
+ /* Max-metric router-lsa print */
+ config_write_stub_router (vty, ospf);
+
/* SPF refresh parameters print. */
if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
vty_out (vty, " refresh timer %d%s",
@@ -8052,16 +8252,27 @@ ospf_vty_init (void)
install_element (OSPF_NODE, &ospf_area_import_list_cmd);
install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
-
+
+ /* SPF timer commands */
install_element (OSPF_NODE, &ospf_timers_spf_cmd);
install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
+ /* refresh timer commands */
install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
+ /* max-metric commands */
+ install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
+ install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
+ install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
+ install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
+ install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
+ install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
+
+ /* reference bandwidth commands */
install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);