]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: explicitly print "exit" at the end of every node config 9331/head
authorIgor Ryzhov <iryzhov@nfware.com>
Sun, 8 Aug 2021 19:38:50 +0000 (22:38 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Mon, 23 Aug 2021 19:08:20 +0000 (22:08 +0300)
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
39 files changed:
babeld/babel_interface.c
babeld/babeld.c
bfdd/bfdd_cli.c
bgpd/bgp_bmp.c
bgpd/bgp_rpki.c
bgpd/bgp_vty.c
bgpd/rfapi/bgp_rfapi_cfg.c
eigrpd/eigrp_cli.c
isisd/isis_circuit.c
isisd/isis_cli.c
isisd/isis_nb.c
isisd/isis_nb.h
isisd/isisd.c
ldpd/ldp_vty_conf.c
lib/if.c
lib/keychain.c
lib/nexthop_group.c
lib/routemap_cli.c
lib/vty.c
nhrpd/nhrp_vty.c
ospf6d/ospf6_interface.c
ospf6d/ospf6_top.c
ospfd/ospf_vty.c
pathd/path_cli.c
pathd/path_nb.c
pathd/path_nb.h
pathd/path_pcep_cli.c
pbrd/pbr_vty.c
pimd/pim_instance.c
pimd/pim_vty.c
ripd/ripd.c
ripngd/ripngd.c
staticd/static_vrf.c
tests/lib/cli/test_cli.refout.in
vtysh/vtysh_config.c
zebra/interface.c
zebra/zebra_pw.c
zebra/zebra_srv6_vty.c
zebra/zebra_vrf.c

index c1e5ffde3c9191c91e46e683096c3e1ec93c689e..615ed9fee31a6837b9d442a5dcae308be62c86bd 100644 (file)
@@ -1362,7 +1362,7 @@ interface_config_write (struct vty *vty)
                 write++;
             }
         }
-        vty_endframe (vty, "!\n");
+        vty_endframe (vty, "exit\n!\n");
         write++;
     }
     return write;
index b9623b64b5fa56dd97f8c21e8028dbc77f70a3af..b9037423b48c1386c90b85c4880ad5f9d8eade70 100644 (file)
@@ -132,6 +132,8 @@ babel_config_write (struct vty *vty)
 
     lines += config_write_distribute (vty, babel_routing_process->distribute_ctx);
 
+    vty_out (vty, "exit\n");
+
     return lines;
 }
 
index 26ff4a758a03a3ac10277007eec78a277a2dab58..384bb26fd7d30295a91a60c834b599602d549d1d 100644 (file)
@@ -101,6 +101,7 @@ void bfd_cli_show_header(struct vty *vty,
 void bfd_cli_show_header_end(struct vty *vty,
                             struct lyd_node *dnode __attribute__((__unused__)))
 {
+       vty_out(vty, "exit\n");
        vty_out(vty, "!\n");
 }
 
@@ -275,6 +276,7 @@ void bfd_cli_show_multi_hop_peer(struct vty *vty,
 void bfd_cli_show_peer_end(struct vty *vty,
                           struct lyd_node *dnode __attribute__((__unused__)))
 {
+       vty_out(vty, " exit\n");
        vty_out(vty, " !\n");
 }
 
index dbc35de80bd1ccbed6d8a08412cec8ac9ddf3ddb..1bc3fd0dbae7226f5f78cfd2735b37b52345fe25 100644 (file)
@@ -2400,6 +2400,8 @@ static int bmp_config_write(struct bgp *bgp, struct vty *vty)
                frr_each (bmp_actives, &bt->actives, ba)
                        vty_out(vty, "  bmp connect %s port %u min-retry %u max-retry %u\n",
                                ba->hostname, ba->port, ba->minretry, ba->maxretry);
+
+               vty_out(vty, " exit\n");
        }
 
        return 0;
index 286612da15be6b1f6e4fd8e4ad9a50643dcb12df..ca3f93899b19d8ecccba0592fec297a337d80dc7 100644 (file)
@@ -932,7 +932,7 @@ static int config_write(struct vty *vty)
 
                vty_out(vty, "preference %hhu\n", cache->preference);
        }
-       vty_out(vty, " exit\n");
+       vty_out(vty, "exit\n");
 
        return 1;
 }
index 27f147a4aaf9b0040dafae7414128f1740218a09..dd4a776a21c78468bdee8f4088f6347535058283 100644 (file)
@@ -17213,6 +17213,7 @@ int bgp_config_write(struct vty *vty)
                bgp_rfapi_cfg_write(vty, bgp);
 #endif
 
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
        }
        return 0;
index cc64261388c6f09bbdf9f89785636a27663b0890..2437bd8cfee8269685bb92c2a8c522b4c294b240 100644 (file)
@@ -4043,7 +4043,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
                                        rfg->routemap_redist_name
                                                [ZEBRA_ROUTE_BGP_DIRECT_EXT]);
                        }
-                       vty_out(vty, "  exit-vrf-policy\n");
+                       vty_out(vty, " exit-vrf-policy\n");
                        vty_out(vty, "!\n");
                }
        if (hc->flags & BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP) {
@@ -4121,7 +4121,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
                                                vty, bgp->rfapi->rfp,
                                                RFAPI_RFP_CFG_GROUP_L2,
                                                rfgc->name, rfgc->rfp_cfg);
-                               vty_out(vty, "   exit-vnc\n");
+                               vty_out(vty, " exit-vnc\n");
                                vty_out(vty, "!\n");
                        }
                }
@@ -4199,7 +4199,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
                                        vty, bgp->rfapi->rfp,
                                        RFAPI_RFP_CFG_GROUP_DEFAULT, NULL,
                                        bgp->rfapi_cfg->default_rfp_cfg);
-                       vty_out(vty, "  exit-vnc\n");
+                       vty_out(vty, " exit-vnc\n");
                        vty_out(vty, "!\n");
                }
 
@@ -4364,7 +4364,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
                                                vty, bgp->rfapi->rfp,
                                                RFAPI_RFP_CFG_GROUP_NVE,
                                                rfg->name, rfg->rfp_cfg);
-                               vty_out(vty, "  exit-vnc\n");
+                               vty_out(vty, " exit-vnc\n");
                                vty_out(vty, "!\n");
                        }
        } /* have listen ports */
index 35536979ea7f014e8d4302aa8b5a5b88ff860c26..d61f43586f131590abb1fb14941dfa18d541f84b 100644 (file)
@@ -96,6 +96,7 @@ void eigrp_cli_show_header(struct vty *vty, struct lyd_node *dnode,
 
 void eigrp_cli_show_end_header(struct vty *vty, struct lyd_node *dnode)
 {
+       vty_out(vty, "exit\n");
        vty_out(vty, "!\n");
 }
 
index a78e4996b4a857bbf2a84281600ab78e9bcfeae4..6f4a91be67d377391cbb3eb246c9c80ac32c6181 100644 (file)
@@ -1290,7 +1290,7 @@ static int isis_interface_config_write(struct vty *vty)
                        write += hook_call(isis_circuit_config_write,
                                           circuit, vty);
                }
-               vty_endframe(vty, "!\n");
+               vty_endframe(vty, "exit\n!\n");
        }
 
        return write;
index ef86d47b2298da0ce935cf90e543ad2251b5c215..70ec66fd7feb661a629d4d3cfd6f82ec46158fed 100644 (file)
@@ -146,6 +146,11 @@ void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, "\n");
 }
 
+void cli_show_router_isis_end(struct vty *vty, struct lyd_node *dnode)
+{
+       vty_out(vty, "exit\n");
+}
+
 /*
  * XPath: /frr-interface:lib/interface/frr-isisd:isis/
  * XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing
index ecad16229c18b63c2b0aadc9638618fc6c6cc443..f62a8d481335175772ed80111ad279734d409ac6 100644 (file)
@@ -32,6 +32,7 @@ const struct frr_yang_module_info frr_isisd_info = {
                        .xpath = "/frr-isisd:isis/instance",
                        .cbs = {
                                .cli_show = cli_show_router_isis,
+                               .cli_show_end = cli_show_router_isis_end,
                                .create = isis_instance_create,
                                .destroy = isis_instance_destroy,
                        },
index 0c2f7b6b7e5acecace3d54c560be82429d6fb50c..4680dd5ded9cb455253d875a57b5a858e4bac3e1 100644 (file)
@@ -415,6 +415,7 @@ void isis_instance_segment_routing_prefix_sid_map_prefix_sid_apply_finish(
 /* Optional 'cli_show' callbacks. */
 void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
                          bool show_defaults);
+void cli_show_router_isis_end(struct vty *vty, struct lyd_node *dnode);
 void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
                           bool show_defaults);
 void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
index 43efa0164daf5fecb801e90c45e268c0d941773c..ebcc9985b40ba02a4a44b2a25935dcf1496b5449 100644 (file)
@@ -3011,6 +3011,8 @@ static int isis_config_write(struct vty *vty)
 
                        write += area_write_mt_settings(area, vty);
                        write += fabricd_write_settings(area, vty);
+
+                       vty_out(vty, "exit\n");
                }
        }
 
index b35d3dfa00793e6d5e2b9bafa0a8049d3d892417..fbd718bb099d86eed46e9f5fc4d4b9ffdda0e3e9 100644 (file)
@@ -133,6 +133,8 @@ ldp_af_iface_config_write(struct vty *vty, int af)
                    ia->hello_interval != 0)
                        vty_out (vty, "   discovery hello interval %u\n",
                            ia->hello_interval);
+
+               vty_out (vty, "  exit\n");
        }
 }
 
@@ -314,6 +316,7 @@ ldp_config_write(struct vty *vty)
        ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4);
        ldp_af_config_write(vty, AF_INET6, ldpd_conf, &ldpd_conf->ipv6);
        vty_out (vty, " !\n");
+       vty_out (vty, "exit\n");
        vty_out (vty, "!\n");
 
        return (1);
@@ -353,6 +356,8 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw)
                          "  ! Incomplete config, specify a neighbor lsr-id\n");
        if (missing_pwid)
                vty_out (vty,"  ! Incomplete config, specify a pw-id\n");
+
+       vty_out (vty, " exit\n");
 }
 
 static int
@@ -383,6 +388,7 @@ ldp_l2vpn_config_write(struct vty *vty)
                        ldp_l2vpn_pw_config_write(vty, pw);
 
                vty_out (vty, " !\n");
+               vty_out (vty, "exit\n");
                vty_out (vty, "!\n");
        }
 
index 6c57855ca1f973b195303b73ebc2892de80dddac..424880ff425a3a21e852f4a359f76b0682151efc 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -1291,6 +1291,11 @@ static void cli_show_interface(struct vty *vty, struct lyd_node *dnode,
        vty_out(vty, "\n");
 }
 
+static void cli_show_interface_end(struct vty *vty, struct lyd_node *dnode)
+{
+       vty_out(vty, "exit\n");
+}
+
 /*
  * XPath: /frr-interface:lib/interface/description
  */
@@ -1652,6 +1657,7 @@ const struct frr_yang_module_info frr_interface_info = {
                                .create = lib_interface_create,
                                .destroy = lib_interface_destroy,
                                .cli_show = cli_show_interface,
+                               .cli_show_end = cli_show_interface_end,
                                .get_next = lib_interface_get_next,
                                .get_keys = lib_interface_get_keys,
                                .lookup_entry = lib_interface_lookup_entry,
index db5c23b1bae4c203cb180dd31aad61aa469deeba..02f83ef0a834f50ff06ce2f50a65c73a8b1c7333 100644 (file)
@@ -1044,6 +1044,7 @@ static int keychain_config_write(struct vty *vty)
 
                        vty_out(vty, " exit\n");
                }
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
        }
 
index 4fee9bde3c2cd06c141ba142ce89afd1feebdcf6..97d70189ff5f41567e04dcaccaa20cde0ce2dd5a 100644 (file)
@@ -1156,6 +1156,7 @@ static int nexthop_group_write(struct vty *vty)
                        nexthop_group_write_nexthop_internal(vty, nh);
                }
 
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
        }
 
index 77455d991ab98aad7857fdfe93ed1a91d6d072bb..8747c37f16b42d54fd7081b10c5965d8ba372b2b 100644 (file)
@@ -125,6 +125,7 @@ void route_map_instance_show(struct vty *vty, struct lyd_node *dnode,
 
 void route_map_instance_show_end(struct vty *vty, struct lyd_node *dnode)
 {
+       vty_out(vty, "exit\n");
        vty_out(vty, "!\n");
 }
 
index f64ab83847af3695ce9121b86492fc4d2198000c..fef16f1ee7a6e3dab92bbd5eb4ee9a270f5a1d92 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -3040,7 +3040,7 @@ DEFPY (log_commands,
 /* Display current configuration. */
 static int vty_config_write(struct vty *vty)
 {
-       vty_out(vty, "line vty\n");
+       vty_frame(vty, "line vty\n");
 
        if (vty_accesslist_name)
                vty_out(vty, " access-class %s\n", vty_accesslist_name);
@@ -3058,6 +3058,8 @@ static int vty_config_write(struct vty *vty)
        if (no_password_check)
                vty_out(vty, " no login\n");
 
+       vty_endframe(vty, "exit\n");
+
        if (do_log_commands)
                vty_out(vty, "log commands\n");
 
index 60ce1e652325a7cf5606e5c1dfe8226c147c9808..a77121448e2c93fdf04b0aa1570f4707ca9e5e1c 100644 (file)
@@ -1225,7 +1225,7 @@ static int interface_config_write(struct vty *vty)
                        }
                }
 
-               vty_endframe(vty, "!\n");
+               vty_endframe(vty, "exit\n!\n");
        }
 
        return 0;
index bbb474ba1a183b248b677553dde25d6a6a33ab41..b427a0c9bde3ed34cb966487df1e4560e445f407 100644 (file)
@@ -2593,7 +2593,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
 
                ospf6_bfd_write_config(vty, oi);
 
-               vty_endframe(vty, "!\n");
+               vty_endframe(vty, "exit\n!\n");
        }
        return 0;
 }
index fc181a6d188a3d97014fdecf05546dcccce32354..b159f11396fcca917dae6ecda9d62484a912e24c 100644 (file)
@@ -2237,6 +2237,8 @@ static int config_write_ospf6(struct vty *vty)
                ospf6_distribute_config_write(vty, ospf6);
                ospf6_asbr_summary_config_write(vty, ospf6);
                config_write_ospf6_gr_helper(vty, ospf6);
+
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
        }
        return 0;
index 4c248c0df31f2c8549d2b2b4aa7ab9c156873fac..1843947dbabd0b3086fbabb9cfd2297382319658 100644 (file)
@@ -11970,7 +11970,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
 
                ospf_opaque_config_write_if(vty, ifp);
 
-               vty_endframe(vty, NULL);
+               vty_endframe(vty, "exit\n!\n");
        }
 
        return write;
@@ -12546,6 +12546,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
        /* LDP-Sync print */
        ospf_ldp_sync_write_config(vty, ospf);
 
+       vty_out(vty, "exit\n");
+
        write++;
        return write;
 }
index 68baa61fa99a27e67dd48969c1dc8d2d1abbb11e..bd629a2b7048feaa4e3fdca249cdce7bbfd3be0e 100644 (file)
@@ -305,6 +305,11 @@ void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
                yang_dnode_get_string(dnode, "./name"));
 }
 
+void cli_show_srte_segment_list_end(struct vty *vty, struct lyd_node *dnode)
+{
+       vty_out(vty, "  exit\n");
+}
+
 static int segment_list_has_src_dst(
        struct vty *vty, char *xpath, long index, const char *index_str,
        struct in_addr adj_src_ipv4, struct in_addr adj_dst_ipv4,
@@ -662,6 +667,11 @@ void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
                yang_dnode_get_string(dnode, "./endpoint"));
 }
 
+void cli_show_srte_policy_end(struct vty *vty, struct lyd_node *dnode)
+{
+       vty_out(vty, "  exit\n");
+}
+
 /*
  * XPath: /frr-pathd:pathd/srte/policy/name
  */
@@ -1233,6 +1243,15 @@ void cli_show_srte_policy_candidate_path(struct vty *vty,
        }
 }
 
+void cli_show_srte_policy_candidate_path_end(struct vty *vty,
+                                            struct lyd_node *dnode)
+{
+       const char *type = yang_dnode_get_string(dnode, "./type");
+
+       if (strmatch(type, "dynamic"))
+               vty_out(vty, "   exit\n");
+}
+
 static int config_write_dnode(const struct lyd_node *dnode, void *arg)
 {
        struct vty *vty = arg;
@@ -1256,6 +1275,9 @@ int config_write_segment_routing(struct vty *vty)
 
        hook_call(pathd_srte_config_write, vty);
 
+       vty_out(vty, " exit\n");
+       vty_out(vty, "exit\n");
+
        return 1;
 }
 
index 9c622883bc21db17361a14abc4c1dfa0d91b41a3..1ab8b7f39bc494597c17f07c50c26f527e410ea9 100644 (file)
@@ -56,6 +56,7 @@ const struct frr_yang_module_info frr_pathd_info = {
                        .cbs = {
                                .create = pathd_srte_segment_list_create,
                                .cli_show = cli_show_srte_segment_list,
+                               .cli_show_end = cli_show_srte_segment_list_end,
                                .destroy = pathd_srte_segment_list_destroy,
                                .get_next = pathd_srte_segment_list_get_next,
                                .get_keys = pathd_srte_segment_list_get_keys,
@@ -136,6 +137,7 @@ const struct frr_yang_module_info frr_pathd_info = {
                        .cbs = {
                                .create = pathd_srte_policy_create,
                                .cli_show = cli_show_srte_policy,
+                               .cli_show_end = cli_show_srte_policy_end,
                                .destroy = pathd_srte_policy_destroy,
                                .get_next = pathd_srte_policy_get_next,
                                .get_keys = pathd_srte_policy_get_keys,
@@ -169,6 +171,7 @@ const struct frr_yang_module_info frr_pathd_info = {
                        .cbs = {
                                .create = pathd_srte_policy_candidate_path_create,
                                .cli_show = cli_show_srte_policy_candidate_path,
+                               .cli_show_end = cli_show_srte_policy_candidate_path_end,
                                .destroy = pathd_srte_policy_candidate_path_destroy,
                                .get_next = pathd_srte_policy_candidate_path_get_next,
                                .get_keys = pathd_srte_policy_candidate_path_get_keys,
index caeadd9cccc1fc63f98a977fc88d6df7f362607b..6a918b8b824d693abceee9df5b8a0851aa0b8e3e 100644 (file)
@@ -112,10 +112,12 @@ void pathd_apply_finish(struct nb_cb_apply_finish_args *args);
 /* Optional 'cli_show' callbacks. */
 void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
                                bool show_defaults);
+void cli_show_srte_segment_list_end(struct vty *vty, struct lyd_node *dnode);
 void cli_show_srte_segment_list_segment(struct vty *vty, struct lyd_node *dnode,
                                        bool show_defaults);
 void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
                          bool show_defaults);
+void cli_show_srte_policy_end(struct vty *vty, struct lyd_node *dnode);
 void cli_show_srte_policy_name(struct vty *vty, struct lyd_node *dnode,
                               bool show_defaults);
 void cli_show_srte_policy_binding_sid(struct vty *vty, struct lyd_node *dnode,
@@ -123,6 +125,8 @@ void cli_show_srte_policy_binding_sid(struct vty *vty, struct lyd_node *dnode,
 void cli_show_srte_policy_candidate_path(struct vty *vty,
                                         struct lyd_node *dnode,
                                         bool show_defaults);
+void cli_show_srte_policy_candidate_path_end(struct vty *vty,
+                                            struct lyd_node *dnode);
 
 /* Utility functions */
 typedef void (*of_pref_cp_t)(enum objfun_type type, void *arg);
index e602fd22df37be06c11949563fb00ee31d230879..829df3179c267d7baf2712279a7b1e5fcd92ad9c 100644 (file)
@@ -1443,6 +1443,7 @@ int pcep_cli_pcep_config_write(struct vty *vty)
        pcep_cli_pcep_pce_config_write(vty);
        pcep_cli_pce_config_write(vty);
        pcep_cli_pcc_config_write(vty);
+       vty_out(vty, "  exit\n");
        return 1;
 }
 
@@ -1467,7 +1468,7 @@ int pcep_cli_pcc_config_write(struct vty *vty)
        }
 
        if (pce_connections_g.num_connections == 0) {
-               return lines;
+               goto exit;
        }
 
        buf[0] = 0;
@@ -1494,6 +1495,8 @@ int pcep_cli_pcc_config_write(struct vty *vty)
                lines++;
                buf[0] = 0;
        }
+exit:
+       vty_out(vty, "   exit\n");
 
        return lines;
 }
@@ -1654,6 +1657,8 @@ int pcep_cli_pce_config_write(struct vty *vty)
 
                vty_out(vty, "%s", buf);
                buf[0] = '\0';
+
+               vty_out(vty, "   exit\n");
        }
 
        return lines;
@@ -1678,6 +1683,8 @@ int pcep_cli_pcep_pce_config_write(struct vty *vty)
                        pcep_cli_print_pce_config(group_opts, buf, sizeof(buf));
                vty_out(vty, "%s", buf);
                buf[0] = 0;
+
+               vty_out(vty, "   exit\n");
        }
 
        return lines;
index 2936d1e3461719f5ed85b1b4b0d0640de001ec8c..6c007acb5cdec83d3d5c1ae7852c2bea8b5e8a14 100644 (file)
@@ -1118,7 +1118,7 @@ static int pbr_interface_config_write(struct vty *vty)
 
                        pbr_map_write_interfaces(vty, ifp);
 
-                       vty_endframe(vty, "!\n");
+                       vty_endframe(vty, "exit\n!\n");
                }
        }
 
@@ -1184,6 +1184,7 @@ static int pbr_vty_map_config_write_sequence(struct vty *vty,
                pbrms_nexthop_group_write_individual_nexthop(vty, pbrms);
        }
 
+       vty_out(vty, "exit\n");
        vty_out(vty, "!\n");
        return 1;
 }
index 6dda66b79a689efd3791db3ce1cc6cd1ce71a766..8a9527d7c005972c63e8ff7c451be99cfdf77891 100644 (file)
@@ -220,7 +220,7 @@ static int pim_vrf_config_write(struct vty *vty)
                pim_global_config_write_worker(pim, vty);
 
                if (vrf->vrf_id != VRF_DEFAULT)
-                       vty_endframe(vty, " exit-vrf\n!\n");
+                       vty_endframe(vty, "exit-vrf\n!\n");
        }
 
        return 0;
index 95882cf58f96e464b4dca7cb2296d84dbae5418c..e4dec9ee8eef311a52be02ff58a92179b55872e8 100644 (file)
@@ -451,7 +451,7 @@ int pim_interface_config_write(struct vty *vty)
                                pim_bfd_write_config(vty, ifp);
                                ++writes;
                        }
-                       vty_endframe(vty, "!\n");
+                       vty_endframe(vty, "exit\n!\n");
                        ++writes;
                }
        }
index 3d1427c3b6b327f67e2b45b00246ceb03817d994..97edd1c38ef43bcd7869af18122491e99715d652 100644 (file)
@@ -3281,6 +3281,8 @@ static int config_write_rip(struct vty *vty)
                /* Interface routemap configuration */
                config_write_if_rmap(vty, rip->if_rmap_ctx);
 
+               vty_out(vty, "exit\n");
+
                write = 1;
        }
 
index cbd2c22893adc4cbcd40ae04a302c97c83a34c79..1f52abd0bfe3aa29c15011d3b137e9bf6ef0af02 100644 (file)
@@ -2270,6 +2270,8 @@ static int ripng_config_write(struct vty *vty)
                config_write_distribute(vty, ripng->distribute_ctx);
                config_write_if_rmap(vty, ripng->if_rmap_ctx);
 
+               vty_out(vty, "exit\n");
+
                write = 1;
        }
 
index 96e5d37d68d91221c4e4e904c337fa50b4bb43b3..0b3efd0b43299af5079da5032b4a77349dd273df 100644 (file)
@@ -164,7 +164,7 @@ static int static_vrf_config_write(struct vty *vty)
                              SAFI_UNICAST, "ipv6 route");
 
                if (vrf->vrf_id != VRF_DEFAULT)
-                       vty_endframe(vty, " exit-vrf\n!\n");
+                       vty_endframe(vty, "exit-vrf\n!\n");
        }
 
        return 0;
index 8f9959cc47ded6ded34e46cc1c8dc62d42a11370..1f38e08b209ee19e2a9c54f2f2c0e4262fa25c83 100644 (file)
@@ -315,7 +315,6 @@ domainname test.domain
 !\r
 !\r
 !\r
-line vty\r
 !\r
 end\r
 test# conf t\r
@@ -332,7 +331,6 @@ domainname test.domain
 !\r
 !\r
 !\r
-line vty\r
 !\r
 end\r
 foohost(config)# 
index d22ec3113f010f4a159ef92bd6070febf47f5058..2e1d7c5bad828fdf34dcb6b3d55f697d03e1a46a 100644 (file)
@@ -272,16 +272,11 @@ void vtysh_config_parse_line(void *arg, const char *line)
                                           strlen(" ip igmp query-interval")) == 0) {
                                config_add_line_uniq_end(config->line, line);
                        } else if (config->index == LINK_PARAMS_NODE
-                                  && strncmp(line, "  exit-link-params",
-                                             strlen("  exit"))
+                                  && strncmp(line, " exit-link-params",
+                                             strlen(" exit"))
                                              == 0) {
                                config_add_line(config->line, line);
                                config->index = INTERFACE_NODE;
-                       } else if (config->index == VRF_NODE
-                                  && strncmp(line, " exit-vrf",
-                                             strlen(" exit-vrf"))
-                                             == 0) {
-                               config_add_line_uniq_end(config->line, line);
                        } else if (!strncmp(line, " vrrp", strlen(" vrrp"))
                                   || !strncmp(line, " no vrrp",
                                               strlen(" no vrrp"))) {
@@ -300,7 +295,10 @@ void vtysh_config_parse_line(void *arg, const char *line)
                        config_add_line(config_top, line);
                break;
        default:
-               if (strncmp(line, "interface", strlen("interface")) == 0)
+               if (strncmp(line, "exit", strlen("exit")) == 0) {
+                       if (config)
+                               config_add_line_uniq_end(config->line, line);
+               } else if (strncmp(line, "interface", strlen("interface")) == 0)
                        config = config_get(INTERFACE_NODE, line);
                else if (strncmp(line, "pseudowire", strlen("pseudowire")) == 0)
                        config = config_get(PW_NODE, line);
@@ -496,7 +494,9 @@ void vtysh_config_dump(void)
                                 * are not under the VRF node.
                                 */
                                if (config->index == INTERFACE_NODE
-                                   && list_isempty(config->line)) {
+                                   && (listcount(config->line) == 1)
+                                   && (line = listnode_head(config->line))
+                                   && strmatch(line, "exit")) {
                                        config_del(config);
                                        continue;
                                }
index 21eeb2054312c4a0ecc7be03922238b68d7d98b2..18f7503f82fa26d266f209f285cf3a244c8cae78 100644 (file)
@@ -4096,7 +4096,7 @@ static int link_params_config_write(struct vty *vty, struct interface *ifp)
        if (IS_PARAM_SET(iflp, LP_RMT_AS))
                vty_out(vty, "  neighbor %pI4 as %u\n", &iflp->rmt_ip,
                        iflp->rmt_as);
-       vty_out(vty, "  exit-link-params\n");
+       vty_out(vty, " exit-link-params\n");
        return 0;
 }
 
@@ -4188,7 +4188,7 @@ static int if_config_write(struct vty *vty)
                        zebra_evpn_mh_if_write(vty, ifp);
                        link_params_config_write(vty, ifp);
 
-                       vty_endframe(vty, "!\n");
+                       vty_endframe(vty, "exit\n!\n");
                }
        return 0;
 }
index 6b4a815151c3b70389ea32dec6fca2622c4702c0..d5083d4cbef1b3c9a9d9294e600754d4e94b7173 100644 (file)
@@ -836,6 +836,7 @@ static int zebra_pw_config(struct vty *vty)
                if (!(pw->flags & F_PSEUDOWIRE_CWORD))
                        vty_out(vty, " control-word exclude\n");
 
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
                write = 1;
        }
index 97935f126e8399b9eb295a4e76f20166b800ed7f..d2b91b6c07e1e71d373f004c217db77ee445b78b 100644 (file)
@@ -320,10 +320,14 @@ static int zebra_sr_config(struct vty *vty)
                        vty_out(vty, "   locator %s\n", locator->name);
                        vty_out(vty, "    prefix %s/%u\n", str,
                                locator->prefix.prefixlen);
+                       vty_out(vty, "   exit\n");
                        vty_out(vty, "   !\n");
                }
+               vty_out(vty, "  exit\n");
                vty_out(vty, "  !\n");
+               vty_out(vty, " exit\n");
                vty_out(vty, " !\n");
+               vty_out(vty, "exit\n");
                vty_out(vty, "!\n");
        }
        return 0;
index 2430b519892b476128b62dbb81c285e34dd0001e..c6737e83f8c5409539dc786c352ffb389a7bd240 100644 (file)
@@ -521,7 +521,7 @@ static int vrf_config_write(struct vty *vty)
                router_id_write(vty, zvrf);
 
                if (zvrf_id(zvrf) != VRF_DEFAULT)
-                       vty_endframe(vty, " exit-vrf\n!\n");
+                       vty_endframe(vty, "exit-vrf\n!\n");
                else
                        vty_out(vty, "!\n");
        }