From cc933ef9f6a6104f287415d97e22bf6e34f193d4 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 27 Sep 2016 16:53:25 +0200 Subject: [PATCH] lib, isisd: enable concurrent configuration editing Finally, this disables the config editing lock for isisd. It also enables deprecation warnings for the lib/ and isisd/ to catch accidental uses of vty->index. Signed-off-by: David Lamparter --- isisd/Makefile.am | 2 +- isisd/isis_main.c | 1 + lib/Makefile.am | 3 ++- lib/vty.c | 11 +++++++++++ lib/vty.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/isisd/Makefile.am b/isisd/Makefile.am index c14351ca3a..69624dced3 100644 --- a/isisd/Makefile.am +++ b/isisd/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in. AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \ - @ISIS_TOPOLOGY_INCLUDES@ + @ISIS_TOPOLOGY_INCLUDES@ -DVTY_DEPRECATE_INDEX DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 LIBS = @LIBS@ diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 6110c4026b..44c7840022 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -342,6 +342,7 @@ main (int argc, char **argv, char **envp) */ signal_init (master, array_size (isisd_signals), isisd_signals); cmd_init (1); + vty_config_lockless (); vty_init (master); memory_init (); access_list_init(); diff --git a/lib/Makefile.am b/lib/Makefile.am index b57e9eb4d5..e95e6f34b7 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,7 @@ ## Process this file with automake to produce Makefile.in. -AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib +AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib \ + -DVTY_DEPRECATE_INDEX AM_CFLAGS = $(WERROR) DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" diff --git a/lib/vty.c b/lib/vty.c index 14ef7e6e4a..cc30def303 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -83,6 +83,7 @@ char *vty_cwd = NULL; /* Configure lock. */ static int vty_config; +static int vty_config_is_lockless = 0; /* Login password check. */ static int no_password_check = 0; @@ -2634,6 +2635,8 @@ vty_log_fixed (char *buf, size_t len) int vty_config_lock (struct vty *vty) { + if (vty_config_is_lockless) + return 1; if (vty_config == 0) { vty->config = 1; @@ -2645,6 +2648,8 @@ vty_config_lock (struct vty *vty) int vty_config_unlock (struct vty *vty) { + if (vty_config_is_lockless) + return 0; if (vty_config == 1 && vty->config == 1) { vty->config = 0; @@ -2653,6 +2658,12 @@ vty_config_unlock (struct vty *vty) return vty->config; } +void +vty_config_lockless (void) +{ + vty_config_is_lockless = 1; +} + /* Master of the threads. */ static struct thread_master *vty_master; diff --git a/lib/vty.h b/lib/vty.h index 468b29d955..3870e59b72 100644 --- a/lib/vty.h +++ b/lib/vty.h @@ -353,6 +353,7 @@ extern void vty_log (const char *level, const char *proto, const char *fmt, struct timestamp_control *, va_list); extern int vty_config_lock (struct vty *); extern int vty_config_unlock (struct vty *); +extern void vty_config_lockless (void); extern int vty_shell (struct vty *); extern int vty_shell_serv (struct vty *); extern void vty_hello (struct vty *);