diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 2400908183..7316477891 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -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)) { diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 3748fef54c..6f3b6a8267 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -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 diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 76dc5657d4..18d53292b1 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -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; }