zebra: Cleanup error handling of nexthop vrf and vrf

The error handling of the nexthop vrf and the vrf
for what was specified on the cli was not as clean
as it should have been.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-01-29 15:18:28 -05:00
parent e6149ab4b8
commit e65dfe7e56

View File

@ -475,20 +475,21 @@ DEFPY(ip_route_address_interface,
ifname = NULL;
}
if (nexthop_vrf) {
nh_zvrf = zebra_vrf_lookup_by_name(nexthop_vrf);
if (!nh_zvrf) {
vty_out(vty, "%% nexthop vrf %s is not defined\n",
nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
} else
nh_zvrf = zebra_vrf_lookup_by_name(vrf);
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!zvrf) {
vty_out(vty, "%% vrf %s is not defined\n",
vrf);
return CMD_WARNING_CONFIG_FAILED;
}
if (nexthop_vrf)
nh_zvrf = zebra_vrf_lookup_by_name(nexthop_vrf);
else
nh_zvrf = zvrf;
if (!nh_zvrf) {
vty_out(vty, "%% nexthop vrf %s is not defined\n",
vrf);
nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
@ -582,23 +583,25 @@ DEFPY(ip_route,
ifname = NULL;
}
if (nexthop_vrf) {
nh_zvrf = zebra_vrf_lookup_by_name(nexthop_vrf);
if (!nh_zvrf) {
vty_out(vty, "%% nexthop vrf %s is not defined\n",
nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
} else
nh_zvrf = zebra_vrf_lookup_by_name(vrf);
zvrf = zebra_vrf_lookup_by_name(vrf);
if (!nh_zvrf) {
vty_out(vty, "%% nexthop vrf %s is not defined\n",
if (!zvrf) {
vty_out(vty, "%% vrf %s is not defined\n",
vrf);
return CMD_WARNING_CONFIG_FAILED;
}
if (nexthop_vrf)
nh_zvrf = zebra_vrf_lookup_by_name(nexthop_vrf);
else
nh_zvrf = zvrf;
if (!nh_zvrf) {
vty_out(vty, "%% nexthop vrf %s is not defined\n",
nexthop_vrf);
return CMD_WARNING_CONFIG_FAILED;
}
return zebra_static_route_leak(vty, zvrf, nh_zvrf,
AFI_IP, SAFI_UNICAST, no, prefix,
mask_str, NULL, gate_str, ifname, flag,