vtysh, zebra: print exit-vrf at end of vrf context

Need to explicitly exit this context otherwise we risk ambiguities
between global and vrf context commands

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2018-04-11 11:23:23 -04:00
parent 30568a7d7c
commit c319e19dbd
3 changed files with 12 additions and 7 deletions

View 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)) {

View 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

View 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;
}