]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/lib_vty.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / lib_vty.c
index 128261a39ccce222ad395add496324e9ca6a34a6..c13d88a1e8216f877ba072eace5b499aef9a91ae 100644 (file)
@@ -1,22 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Assorted library VTY commands
  *
  * Copyright (C) 1998 Kunihiro Ishiguro
  * Copyright (C) 2016-2017  David Lamparter for NetDEF, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -37,6 +24,7 @@
 #include "module.h"
 #include "defaults.h"
 #include "lib_vty.h"
+#include "northbound_cli.h"
 
 /* Looking up memory status from vty interface. */
 #include "vector.h"
@@ -224,26 +212,25 @@ static struct call_back {
 } callback;
 
 
-DEFUN_HIDDEN (start_config,
-             start_config_cmd,
-             "XFRR_start_configuration",
-             "The Beginning of Configuration\n")
+DEFUN_NOSH(start_config, start_config_cmd, "XFRR_start_configuration",
+          "The Beginning of Configuration\n")
 {
        callback.readin_time = monotime(NULL);
 
+       vty->pending_allowed = 1;
+
        if (callback.start_config)
                (*callback.start_config)();
 
        return CMD_SUCCESS;
 }
 
-DEFUN_HIDDEN (end_config,
-             end_config_cmd,
-             "XFRR_end_configuration",
-             "The End of Configuration\n")
+DEFUN_NOSH(end_config, end_config_cmd, "XFRR_end_configuration",
+          "The End of Configuration\n")
 {
        time_t readin_time;
        char readin_time_str[MONOTIME_STRLEN];
+       int ret;
 
        readin_time = monotime(NULL);
        readin_time -= callback.readin_time;
@@ -251,12 +238,26 @@ DEFUN_HIDDEN (end_config,
        frrtime_to_interval(readin_time, readin_time_str,
                            sizeof(readin_time_str));
 
+       vty->pending_allowed = 0;
+       ret = nb_cli_pending_commit_check(vty);
+
        zlog_info("Configuration Read in Took: %s", readin_time_str);
+       zlog_debug("%s: VTY:%p, pending SET-CFG: %u", __func__, vty,
+                  (uint32_t)vty->mgmt_num_pending_setcfg);
+
+       /*
+        * If (and only if) we have sent any CLI config commands to MGMTd
+        * FE interface using vty_mgmt_send_config_data() without implicit
+        * commit before, should we need to send an explicit COMMIT-REQ now
+        * to apply all those commands at once.
+        */
+       if (vty->mgmt_num_pending_setcfg && vty_mgmt_fe_enabled())
+               vty_mgmt_send_commit_config(vty, false, false);
 
        if (callback.end_config)
                (*callback.end_config)();
 
-       return CMD_SUCCESS;
+       return ret;
 }
 
 void cmd_init_config_callbacks(void (*start_config_cb)(void),