]> git.puffer.fish Git - mirror/frr.git/commitdiff
vtysh, zebra: print exit-vrf at end of vrf context
authorQuentin Young <qlyoung@cumulusnetworks.com>
Wed, 11 Apr 2018 15:23:23 +0000 (11:23 -0400)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 17 Apr 2018 18:26:25 +0000 (14:26 -0400)
Need to explicitly exit this context otherwise we risk ambiguities
between global and vrf context commands

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
vtysh/vtysh.c
vtysh/vtysh_config.c
zebra/zebra_vrf.c

index 24009081839c684fb4c48168ba8679e57b82ec65..73164778911c4444b4a13f74396f93557a680feb 100644 (file)
@@ -671,7 +671,7 @@ int vtysh_mark_file(const char *filename)
                        } else if ((prev_node == BGP_EVPN_VNI_NODE)
                                   && (tried == 1)) {
                                fprintf(outputfile, "exit-vni\n");
-                       } else if (prev_node == VRF_NODE) {
+                       } else if (prev_node == VRF_NODE && (tried == 1)) {
                                fprintf(outputfile, "exit-vrf\n");
                        } else if ((prev_node == KEYCHAIN_KEY_NODE)
                                   && (tried == 1)) {
index 3748fef54c2af870e5502894a0c619f448e8a25c..6f3b6a826751cbe02b46db8fc877adafc7416769 100644 (file)
@@ -185,6 +185,12 @@ void vtysh_config_parse_line(void *arg, const char *line)
                                              == 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(config->line, line);
+                               config->index = CONFIG_NODE;
                        } else if (config->index == RMAP_NODE
                                   || config->index == INTERFACE_NODE
                                   || config->index == LOGICALROUTER_NODE
index 76dc5657d41cd3ba2092fab2292ddf5b1a80b8ce..18d53292b1b6d12a28da4aeab5b1b8aeb05ad04a 100644 (file)
@@ -524,10 +524,8 @@ static int vrf_config_write(struct vty *vty)
                        if (zvrf->l3vni)
                                vty_out(vty, "vni %u\n", zvrf->l3vni);
                        vty_out(vty, "!\n");
-               }
-
-               if (vrf_is_user_cfged(vrf)) {
-                       vty_out(vty, "vrf %s\n", zvrf_name(zvrf));
+               } else {
+                       vty_frame(vty, "vrf %s\n", zvrf_name(zvrf));
                        if (zvrf->l3vni)
                                vty_out(vty, " vni %u%s\n", zvrf->l3vni,
                                        is_l3vni_for_prefix_routes_only(
@@ -535,14 +533,15 @@ static int vrf_config_write(struct vty *vty)
                                                ? " prefix-routes-only"
                                                : "");
                        zebra_ns_config_write(vty, (struct ns *)vrf->ns_ctxt);
+
                }
 
                static_config(vty, zvrf, AFI_IP, SAFI_UNICAST, "ip route");
                static_config(vty, zvrf, AFI_IP, SAFI_MULTICAST, "ip mroute");
                static_config(vty, zvrf, AFI_IP6, SAFI_UNICAST, "ipv6 route");
 
-               if (vrf->vrf_id != VRF_DEFAULT)
-                       vty_out(vty, "!\n");
+               if (zvrf_id(zvrf) != VRF_DEFAULT)
+                       vty_endframe(vty, " exit-vrf\n!\n");
        }
        return 0;
 }