]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pbrd: Be a bit more lenient with `set nexthop A.B.C.D <intf>`
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 30 Jun 2020 15:16:36 +0000 (11:16 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 2 Jul 2020 00:01:24 +0000 (20:01 -0400)
When specifying an interface in a pbr-map `set nexthop ..` command
be a bit more lenient about the interface.

a) If the interface does not exist bail on the command
    (this is the same)
b) If the interface exists but is in a different vrf
   than specified use the vrf it is actually in.
    (this is new behavior)

Ticket: CM-30187
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pbrd/pbr_vty.c

index 54029206ccbf10735609d563ca746cdf8a8b6ee9..cd9096cbc88620e5d54c5c5bcdb9a1ffffc084c3 100644 (file)
@@ -312,7 +312,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
                vrf = vrf_lookup_by_id(VRF_DEFAULT);
 
        if (!vrf) {
-               vty_out(vty, "Specified: %s is non-existent\n", vrf_name);
+               vty_out(vty, "Specified VRF: %s is non-existent\n", vrf_name);
                return CMD_WARNING_CONFIG_FAILED;
        }
 
@@ -320,13 +320,24 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
        nhop.vrf_id = vrf->vrf_id;
 
        if (intf) {
-               nhop.ifindex = ifname2ifindex(intf, vrf->vrf_id);
-               if (nhop.ifindex == IFINDEX_INTERNAL) {
-                       vty_out(vty,
-                               "Specified Intf %s does not exist in vrf: %s\n",
-                               intf, vrf->name);
+               struct interface *ifp;
+
+               ifp = if_lookup_by_name_all_vrf(intf);
+               if (!ifp) {
+                       vty_out(vty, "Specified Intf %s does not exist\n",
+                               intf);
                        return CMD_WARNING_CONFIG_FAILED;
                }
+               if (ifp->vrf_id != vrf->vrf_id) {
+                       struct vrf *actual;
+
+                       actual = vrf_lookup_by_id(ifp->vrf_id);
+                       vty_out(vty,
+                               "Specified Intf %s is not in vrf %s but is in vrf %s, using actual vrf\n",
+                               ifp->name, vrf->name, actual->name);
+               }
+               nhop.ifindex = ifp->ifindex;
+               nhop.vrf_id = ifp->vrf_id;
        }
 
        if (addr) {