]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Cleanup error handling of nexthop vrf and vrf 1684/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 29 Jan 2018 20:18:28 +0000 (15:18 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 29 Jan 2018 20:18:28 +0000 (15:18 -0500)
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>
zebra/zebra_vty.c

index 7b5ab1ef5c3ec81e826b27708004763ca68c1ae3..f0be862221de01cfed28d8da9073c4d4b5311dd8 100644 (file)
@@ -475,20 +475,21 @@ DEFPY(ip_route_address_interface,
                ifname = NULL;
        }
 
-       if (nexthop_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);
-               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);
+       else
+               nh_zvrf = zvrf;
 
-       zvrf = zebra_vrf_lookup_by_name(vrf);
        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) {
+       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);
-               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);
+       else
+               nh_zvrf = zvrf;
 
-       zvrf = zebra_vrf_lookup_by_name(vrf);
        if (!nh_zvrf) {
                vty_out(vty, "%% nexthop vrf %s is not defined\n",
-                       vrf);
+                       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,