]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Revert "bgpd: don't use operational state in "router bgp" command"
authorIgor Ryzhov <iryzhov@nfware.com>
Thu, 13 May 2021 22:39:24 +0000 (01:39 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 3 Aug 2021 19:14:19 +0000 (22:14 +0300)
This reverts commit 4062b455a6eacfe3f5107daa68351b18cc0ca7e7.

bgpd/bgp_vty.c

index fb01d16b97d2b14ba7138f54bcc3480fd558af02..6acce23d5498bfe2e2c9fd5338a5a88fdcb6fdc0 100644 (file)
@@ -1388,19 +1388,16 @@ DEFUN_YANG_NOSH(router_bgp,
        as_t as;
        struct bgp *bgp;
        const char *name = NULL;
+       char as_str[12] = {'\0'};
        enum bgp_instance_type inst_type;
        char base_xpath[XPATH_MAXLEN];
-       const struct lyd_node *bgp_glb_dnode;
 
        // "router bgp" without an ASN
        if (argc == 2) {
                // Pending: Make VRF option available for ASN less config
-               snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
-                        "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME);
+               bgp = bgp_get_default();
 
-               bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode,
-                                              base_xpath);
-               if (!bgp_glb_dnode) {
+               if (bgp == NULL) {
                        vty_out(vty, "%% No BGP process is configured\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }
@@ -1410,19 +1407,31 @@ DEFUN_YANG_NOSH(router_bgp,
                        return CMD_WARNING_CONFIG_FAILED;
                }
 
-               as = yang_dnode_get_uint32(bgp_glb_dnode, "./global/local-as");
+               snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH,
+                        "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME);
 
-               VTY_PUSH_XPATH(BGP_NODE, base_xpath);
+               nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
+               snprintf(as_str, 12, "%d", bgp->as);
+               nb_cli_enqueue_change(vty, "./global/local-as", NB_OP_MODIFY,
+                                     as_str);
+               if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) {
+                       nb_cli_enqueue_change(vty,
+                                             "./global/instance-type-view",
+                                             NB_OP_MODIFY, "true");
+               }
 
-               /*
-                * For backward compatibility with old commands we still
-                * need to use the qobj infrastructure.
-                */
-               bgp = bgp_lookup(as, NULL);
-               if (bgp)
-                       VTY_PUSH_CONTEXT(BGP_NODE, bgp);
+               nb_cli_pending_commit_check(vty);
+               ret = nb_cli_apply_changes(vty, base_xpath);
+               if (ret == CMD_SUCCESS) {
+                       VTY_PUSH_XPATH(BGP_NODE, base_xpath);
 
-               return CMD_SUCCESS;
+                       /*
+                        * For backward compatibility with old commands we still
+                        * need to use the qobj infrastructure.
+                        */
+                       VTY_PUSH_CONTEXT(BGP_NODE, bgp);
+               }
+               return ret;
        }
 
        // "router bgp X"