]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: Add error code if daemon is not running
authorYaroslav Fedoriachenko <yar.fed99@gmail.com>
Tue, 17 Aug 2021 15:30:03 +0000 (18:30 +0300)
committerYaroslav Fedoriachenko <yar.fed99@gmail.com>
Tue, 21 Sep 2021 14:51:04 +0000 (17:51 +0300)
After `<daemon_name> is not running` message vtysh does not return
error. For example if you disable ospf in `/etc/frr/daemons` and run
`vtysh -c configure -c "router ospf"` it prints the message to stderr,
but returns 0.

This commit will make vtysh return error when not in interractive mode.

But if you run commands from vtysh, you will still be able to enter
views and exit them if daemon is not running.

Signed-off-by: Yaroslav Fedoriachenko <yar.fed99@gmail.com>
lib/command.h
vtysh/vtysh.c

index c76fc1e8eb5a68d1190446a9a97ab56e91e23e37..8a7c9a2048b47ef2c6cadcbe0ed9d5e1a4da42e4 100644 (file)
@@ -229,6 +229,7 @@ struct cmd_node {
 #define CMD_WARNING_CONFIG_FAILED 13
 #define CMD_NOT_MY_INSTANCE    14
 #define CMD_NO_LEVEL_UP 15
+#define CMD_ERR_NO_DAEMON 16
 
 /* Argc max counts. */
 #define CMD_ARGC_MAX   256
index b74360c75fc13d830169f9201d0554d41bbd8394..beb7045a7d43870da2cef8d3b09f62437a4bb9a7 100644 (file)
@@ -602,7 +602,8 @@ static int vtysh_execute_func(const char *line, int pager)
                                                fprintf(stderr,
                                                        "%s is not running\n",
                                                        vtysh_client[i].name);
-                                               continue;
+                                               cmd_stat = CMD_ERR_NO_DAEMON;
+                                               break;
                                        }
                                }
                                cmd_stat = vtysh_client_execute(
@@ -611,7 +612,7 @@ static int vtysh_execute_func(const char *line, int pager)
                                        break;
                        }
                }
-               if (cmd_stat != CMD_SUCCESS)
+               if (cmd_stat != CMD_SUCCESS && cmd_stat != CMD_ERR_NO_DAEMON)
                        break;
 
                if (cmd->func)