[quagga-dev 4177] Re: ospfd log-adjacency-changes

Andrew J. Schorr aschorr at telemetry-investments.com
Wed Jun 28 21:15:09 BST 2006


How does the attached patch look?  I added the optional detail argument,
and I updated the syntax (newer IOS does not have "ospf" as the 1st
word of the log-adjacency-changes subcommand).  I also changed
to show regressions in all cases, not just transitions to full or down
(when detail is omitted).  As you note, with "detail" is basically
too verbose and more of a debugging tool.

And any thoughts on whether it is OK to commit this to 0.99?  Or do
we need to wait until after 1.0?

Regards,
Andy
-------------- next part --------------
Index: ospfd/ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/ospfd/ChangeLog,v
retrieving revision 1.193
diff -b -u -p -r1.193 ChangeLog
--- ospfd/ChangeLog	27 Jun 2006 08:01:43 -0000	1.193
+++ ospfd/ChangeLog	28 Jun 2006 20:07:59 -0000
@@ -1,3 +1,17 @@
+2006-06-28 Erik Muller <erikm at internap.com>
+
+	* ospfd.h: Define 2 new struct ospf config flags:
+	  OSPF_LOG_ADJACENCY_CHANGES and OSPF_LOG_ADJACENCY_DETAIL
+	* ospf_nsm.c (nsm_change_state): Log adjacency changes if
+	  requested.
+	* ospf_vty.c (ospf_log_adjacency_changes): New command function
+	  to implement ospf subcommand "log-adjacency-changes [detail]".
+	  (no_ospf_log_adjacency_changes) Turn off log-adjacency-changes.
+	  (show_ip_ospf) Show whether adjacency changes are logged.
+	  (ospf_config_write) Add "log-adjacency-changes [detail]" to config.
+	  (ospf_vty_init) Add ospf_log_adjacency_changes and
+	  no_ospf_log_adjacency_changes.
+
 2006-06-26 Paul Jakma <paul.jakma at sun.com>
 
 	* ospf_abr.c: (general) NSSA translate-candidate ABRs need to
Index: ospfd/ospfd.h
===================================================================
RCS file: /var/cvsroot/quagga/ospfd/ospfd.h,v
retrieving revision 1.23
diff -b -u -p -r1.23 ospfd.h
--- ospfd/ospfd.h	26 Nov 2005 13:31:11 -0000	1.23
+++ ospfd/ospfd.h	28 Jun 2006 20:07:59 -0000
@@ -181,6 +181,8 @@ struct ospf
   u_char config;
 #define OSPF_RFC1583_COMPATIBLE         (1 << 0)
 #define OSPF_OPAQUE_CAPABLE		(1 << 2)
+#define OSPF_LOG_ADJACENCY_CHANGES	(1 << 3)
+#define OSPF_LOG_ADJACENCY_DETAIL	(1 << 4)
 
 #ifdef HAVE_OPAQUE_LSA
   /* Opaque-LSA administrative flags. */
Index: ospfd/ospf_nsm.c
===================================================================
RCS file: /var/cvsroot/quagga/ospfd/ospf_nsm.c,v
retrieving revision 1.14
diff -b -u -p -r1.14 ospf_nsm.c
--- ospfd/ospf_nsm.c	3 Apr 2006 21:25:32 -0000	1.14
+++ ospfd/ospf_nsm.c	28 Jun 2006 20:08:00 -0000
@@ -698,6 +698,16 @@ nsm_change_state (struct ospf_neighbor *
   if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
     vl_area = ospf_area_lookup_by_area_id (oi->ospf, oi->vl_data->vl_area_id);
   
+  /* Optionally notify about adjacency changes */
+  if (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_CHANGES) &&
+      (old_state != state) &&
+      (CHECK_FLAG(oi->ospf->config, OSPF_LOG_ADJACENCY_DETAIL) ||
+       (state == NSM_Full) || (state < old_state)))
+    zlog_notice("AdjChg: Nbr %s on %s: %s -> %s",
+		inet_ntoa (nbr->router_id), IF_NAME (nbr->oi),
+		LOOKUP (ospf_nsm_state_msg, old_state),
+		LOOKUP (ospf_nsm_state_msg, state));
+
 #ifdef HAVE_SNMP
   /* Terminal state or regression */ 
   if ((state == NSM_Full) || (state == NSM_TwoWay) || (state < old_state))
Index: ospfd/ospf_vty.c
===================================================================
RCS file: /var/cvsroot/quagga/ospfd/ospf_vty.c,v
retrieving revision 1.56
diff -b -u -p -r1.56 ospf_vty.c
--- ospfd/ospf_vty.c	27 Jun 2006 08:01:43 -0000	1.56
+++ ospfd/ospf_vty.c	28 Jun 2006 20:08:01 -0000
@@ -2056,6 +2056,56 @@ DEFUN (no_ospf_abr_type,
   return CMD_SUCCESS;
 }
 
+DEFUN (ospf_log_adjacency_changes,
+       ospf_log_adjacency_changes_cmd,
+       "log-adjacency-changes",
+       "Log changes in adjacency state\n")
+{
+  struct ospf *ospf = vty->index;
+
+  SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+  return CMD_SUCCESS;
+}
+
+DEFUN (ospf_log_adjacency_changes_detail,
+       ospf_log_adjacency_changes_detail_cmd,
+       "log-adjacency-changes detail",
+       "Log changes in adjacency state\n"
+       "Log all state changes\n")
+{
+  struct ospf *ospf = vty->index;
+
+  SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+  SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_log_adjacency_changes,
+       no_ospf_log_adjacency_changes_cmd,
+       "no log-adjacency-changes",
+       NO_STR
+       "Log changes in adjacency state\n")
+{
+  struct ospf *ospf = vty->index;
+
+  UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
+  UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_ospf_log_adjacency_changes_detail,
+       no_ospf_log_adjacency_changes_detail_cmd,
+       "no log-adjacency-changes detail",
+       NO_STR
+       "Log changes in adjacency state\n"
+       "Log all state changes\n")
+{
+  struct ospf *ospf = vty->index;
+
+  UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
+  return CMD_SUCCESS;
+}
+
 DEFUN (ospf_compatible_rfc1583,
        ospf_compatible_rfc1583_cmd,
        "compatible rfc1583",
@@ -2676,8 +2726,18 @@ 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))
+    {
+      if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
+	vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
+      else
+	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))
@@ -7752,6 +7812,15 @@ 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, " log-adjacency-changes");
+	  if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
+	    vty_out(vty, " detail");
+	  vty_out(vty, "%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);
@@ -8123,6 +8192,12 @@ ospf_vty_init (void)
   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, &ospf_log_adjacency_changes_detail_cmd);
+  install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
+  install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
+
   /* "ospf rfc1583-compatible" commands. */
   install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
   install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
Index: doc/ChangeLog
===================================================================
RCS file: /var/cvsroot/quagga/doc/ChangeLog,v
retrieving revision 1.61
diff -b -u -p -r1.61 ChangeLog
--- doc/ChangeLog	26 Jun 2006 12:55:58 -0000	1.61
+++ doc/ChangeLog	28 Jun 2006 20:08:01 -0000
@@ -1,3 +1,8 @@
+2006-06-28 Erik Muller <erikm at internap.com>
+
+	* ospfd.texi: Document new ospf router subcommand
+	  "log-adjacency-changes [detail]".
+
 2006-06-26 Paul Jakma <paul.jakma at sun.com>
 
 	* ospfd.texi: Document that MD5 keyid is part of the protocol.
Index: doc/ospfd.texi
===================================================================
RCS file: /var/cvsroot/quagga/doc/ospfd.texi,v
retrieving revision 1.13
diff -b -u -p -r1.13 ospfd.texi
--- doc/ospfd.texi	26 Jun 2006 12:55:58 -0000	1.13
+++ doc/ospfd.texi	28 Jun 2006 20:08:01 -0000
@@ -90,6 +90,13 @@ but still both preferred to external pat
 This command should NOT be set normally.
 @end deffn
 
+ at deffn {OSPF Command} {log-adjacency-changes [detail]} {}
+ at deffnx {OSPF Command} {no log-adjacency-changes [detail]} {}
+Configures ospfd to log changes in adjacency.  With the optional
+detail argument, all changes in adjacency status are shown.  Without detail,
+only changes to full or regressions are shown.
+ at end deffn
+
 @deffn {OSPF Command} {passive interface @var{interface}} {}
 @deffnx {OSPF Command} {no passive interface @var{interface}} {}
 


More information about the Quagga-dev mailing list