[quagga-dev 4239] vty patch to prevent infinitely recursing error messages

Andrew J. Schorr aschorr at telemetry-investments.com
Fri Jul 7 19:48:31 IST 2006


We had the following problem today: if a telnet client vty session
exits abnormally while monitoring is enabled, then the warning message
that is issued will result in the logging system trying to write that
message to the very vty session that triggered the problem in the
first place.  Then vty_log_out will issue its own warning message
which in turn will also get logged to that very terminal.  This
recurses infinitely until the daemon dies. :-)

A possible patch is attached.  Make sense?

Regards,
Andy
-------------- next part --------------
Index: lib/vty.c
===================================================================
RCS file: /var/cvsroot/quagga/lib/vty.c,v
retrieving revision 1.53
diff -b -u -p -r1.53 vty.c
--- lib/vty.c	3 Jul 2006 20:58:29 -0000	1.53
+++ lib/vty.c	7 Jul 2006 22:43:16 -0000
@@ -182,6 +182,7 @@ vty_log_out (struct vty *vty, const char
 	   drop the data and ignore. */
 	return -1;
       /* Fatal I/O error. */
+      vty->monitor = 0; /* disable monitoring to avoid infinite recursion */
       zlog_warn("%s: write failed to vty client fd %d, closing: %s",
 		__func__, vty->fd, safe_strerror(errno));
       buffer_reset(vty->obuf);
@@ -1349,6 +1350,7 @@ vty_read (struct thread *thread)
 	      vty_event (VTY_READ, vty_sock, vty);
 	      return 0;
 	    }
+	  vty->monitor = 0; /* disable monitoring to avoid infinite recursion */
 	  zlog_warn("%s: read error on vty client fd %d, closing: %s",
 		    __func__, vty->fd, safe_strerror(errno));
 	}
@@ -1571,6 +1573,7 @@ vty_flush (struct thread *thread)
   switch (flushrc)
     {
     case BUFFER_ERROR:
+      vty->monitor = 0; /* disable monitoring to avoid infinite recursion */
       zlog_warn("buffer_flush failed on vty client fd %d, closing",
 		vty->fd);
       buffer_reset(vty->obuf);
@@ -2018,6 +2021,7 @@ vtysh_flush(struct vty *vty)
       vty_event(VTYSH_WRITE, vty->fd, vty);
       break;
     case BUFFER_ERROR:
+      vty->monitor = 0; /* disable monitoring to avoid infinite recursion */
       zlog_warn("%s: write error to fd %d, closing", __func__, vty->fd);
       buffer_reset(vty->obuf);
       vty_close(vty);
@@ -2053,6 +2057,7 @@ vtysh_read (struct thread *thread)
 	      vty_event (VTYSH_READ, sock, vty);
 	      return 0;
 	    }
+	  vty->monitor = 0; /* disable monitoring to avoid infinite recursion */
 	  zlog_warn("%s: read failed on vtysh client fd %d, closing: %s",
 		    __func__, sock, safe_strerror(errno));
 	}


More information about the Quagga-dev mailing list