[quagga-dev 4170] Re: minor patch to ospfd config_write_debug

Erik Muller erikm at internap.com
Fri Jun 23 15:42:21 BST 2006


On Fri, 23 Jun 2006, Andrew J. Schorr wrote:

> Also, does anybody have any thoughts about implementing
> a log-adjacency-changes ospf subcommand?  Or is the thinking
> that saying "debug ospf nsm status" is sufficient to accomplish
> approximately the same thing?  I guess the problem might be
> that the debug command logs all state changes, whereas the
> log-adjacency-changes command (without the optional "detail" argument)
> just shows on/off transitions...

I wrote up a patch to do just that a while back (just never got around to 
submitting it for inclusion, attached patch is against 0.99.1, haven't 
checked if it still applies to current cvs).  I think that having these 
notifications is useful, and just on principle I prefer not to enable 
debuging on a production system.

-e
------------------------------------------------------------------------
Erik Muller                                           erikm at internap.com
Network Architect, Internap Network Services
NOC: noc at internap.com, 1.877.THE.INOC
-------------- next part --------------
# http://buh.org/zebra/0.99.1/11ospf-log
diff -urp quagga-0.99.1-dist/doc/ospfd.texi quagga-0.99.1/doc/ospfd.texi
--- quagga-0.99.1-dist/doc/ospfd.texi	Sat Nov  6 12:13:09 2004
+++ quagga-0.99.1/doc/ospfd.texi	Fri May 27 11:04:22 2005
@@ -72,6 +72,11 @@ paths and intra-area path are now of equ
 preferred to external paths.
 @end deffn
 
+ at deffn {OSPF Command} {ospf log-adjacency-changes} {}
+ at deffnx {OSPF Command} {no ospf log-adjacency-changes} {}
+Configures ospfd to log changes of fully adjacent neighbors.
+ at end deffn
+
 @deffn {OSPF Command} {passive interface @var{interface}} {}
 @deffnx {OSPF Command} {no passive interface @var{interface}} {}
 @end deffn
diff -urp quagga-0.99.1-dist/ospfd/ChangeLog quagga-0.99.1/ospfd/ChangeLog
--- quagga-0.99.1-dist/ospfd/ChangeLog	Fri Apr 15 08:10:17 2005
+++ quagga-0.99.1/ospfd/ChangeLog	Fri May 27 11:07:54 2005
@@ -1,3 +1,9 @@
+2005-05-27 Erik Muller <erikm at internap.com>
+
+	* ospf_vty.c: Add "ospf log-adjacency-changes".
+	* ospf_nsm.c: ditto.
+	* ospfd.h: ditto.
+
 2005-04-15 Zhipeng Gong <zpgong at cdc.3upsystems.com>
 
 	* ospf_abr.c: (ospf_abr_announce_network_to_area) dont forget
Only in quagga-0.99.1/ospfd: ChangeLog.orig
diff -urp quagga-0.99.1-dist/ospfd/ospf_nsm.c quagga-0.99.1/ospfd/ospf_nsm.c
--- quagga-0.99.1-dist/ospfd/ospf_nsm.c	Sat Dec 11 13:00:06 2004
+++ quagga-0.99.1/ospfd/ospf_nsm.c	Fri May 27 11:04:22 2005
@@ -690,6 +690,13 @@ nsm_change_state (struct ospf_neighbor *
   if ((old_state != NSM_Full && state == NSM_Full) ||
       (old_state == NSM_Full && state != NSM_Full))
     {
+      /* Optionally notify when a neighbor enters or leaves Full */
+      if (CHECK_FLAG (oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
+        zlog_notice ("AdjChg Nbr %s via %s, %s -> %s",
+		    inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
+		    LOOKUP (ospf_nsm_state_msg, old_state),
+		    LOOKUP (ospf_nsm_state_msg, nbr->state));
+
       if (state == NSM_Full)
 	{
 	  oi->full_nbrs++;
diff -urp quagga-0.99.1-dist/ospfd/ospf_vty.c quagga-0.99.1/ospfd/ospf_vty.c
--- quagga-0.99.1-dist/ospfd/ospf_vty.c	Thu Apr  7 03:30:25 2005
+++ quagga-0.99.1/ospfd/ospf_vty.c	Fri May 27 11:04:22 2005
@@ -2048,6 +2048,37 @@ DEFUN (no_ospf_abr_type,
   return CMD_SUCCESS;
 }
 
+DEFUN (ospf_log_adjacency_changes,
+       ospf_log_adjacency_changes_cmd,
+       "ospf log-adjacency-changes",
+       "OSPF specific commands\n"
+       "log adjacency state changes\n")
+{
+  struct ospf *ospf = vty->index;
+
+  if (!CHECK_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
+    {
+      SET_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+    }
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_log_adjacency_changes,
+       no_ospf_log_adjacency_changes_cmd,
+       "no ospf log-adjacency-changes",
+       NO_STR
+       "OSPF specific commands\n"
+       "log adjacency state changes\n")
+{
+  struct ospf *ospf = vty->index;
+
+  if (CHECK_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
+    {
+      UNSET_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+    }
+  return CMD_SUCCESS;
+}
+
 DEFUN (ospf_compatible_rfc1583,
        ospf_compatible_rfc1583_cmd,
        "compatible rfc1583",
@@ -2560,8 +2591,13 @@ DEFUN (show_ip_ospf,
 	   ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
 #endif /* HAVE_OPAQUE_LSA */
   /* Show number of areas attached. */
-  vty_out (vty, " Number of areas attached to this router: %d%s%s",
-           listcount (ospf->areas), VTY_NEWLINE, VTY_NEWLINE);
+  vty_out (vty, " Number of areas attached to this router: %d%s",
+           listcount (ospf->areas), VTY_NEWLINE);
+
+  if (CHECK_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
+    vty_out (vty, " Adjacency changes are logged%s", VTY_NEWLINE);
+
+  vty_out (vty, "%s",VTY_NEWLINE);
 
   /* Show each area status. */
   for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
@@ -7296,6 +7332,10 @@ ospf_config_write (struct vty *vty)
         vty_out (vty, " ospf abr-type %s%s", 
                  ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
 
+      /* log-adjacency-changes flag print. */
+      if (CHECK_FLAG (ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
+        vty_out (vty, " ospf log-adjacency-changes%s", VTY_NEWLINE);
+
       /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
       if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
 	vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
@@ -7649,6 +7689,10 @@ ospf_vty_init ()
   /* "ospf abr-type" commands. */
   install_element (OSPF_NODE, &ospf_abr_type_cmd);
   install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
+
+  /* "ospf log-adjacency-changes" commands. */
+  install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
+  install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
 
   /* "ospf rfc1583-compatible" commands. */
   install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
Only in quagga-0.99.1/ospfd: ospf_vty.c.orig
diff -urp quagga-0.99.1-dist/ospfd/ospfd.h quagga-0.99.1/ospfd/ospfd.h
--- quagga-0.99.1-dist/ospfd/ospfd.h	Fri Mar 25 14:48:40 2005
+++ quagga-0.99.1/ospfd/ospfd.h	Fri May 27 11:04:22 2005
@@ -176,6 +176,7 @@ struct ospf
   u_char config;
 #define OSPF_RFC1583_COMPATIBLE         (1 << 0)
 #define OSPF_OPAQUE_CAPABLE		(1 << 2)
+#define OSPF_LOG_ADJACENCY_CHANGES	(1 << 3)
 
 #ifdef HAVE_OPAQUE_LSA
   /* Opaque-LSA administrative flags. */
Only in quagga-0.99.1/ospfd: ospfd.h.orig


More information about the Quagga-dev mailing list