]> git.puffer.fish Git - mirror/frr.git/commitdiff
sharpd: Add code to allow nexthops to be watched from non-default vrf
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 28 Feb 2019 13:24:20 +0000 (08:24 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 1 Mar 2019 21:30:31 +0000 (16:30 -0500)
Add a bit of code to the sharp cli to allow it to specify a non-default
vrf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
sharpd/sharp_vty.c

index 74550d82d48d6a0095d124abffe4517bfe49cf00..fbcbbe3fdca7119f940b168a69e12b4c4cc4111f 100644 (file)
 #endif
 
 DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
-      "sharp watch <nexthop$n|import$import> X:X::X:X$nhop [connected$connected]",
+      "sharp watch [vrf NAME$name] <nexthop$n|import$import> X:X::X:X$nhop [connected$connected]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
+      "The vrf we would like to watch if non-default\n"
+      "The NAME of the vrf\n"
       "Watch for nexthop changes\n"
       "Watch for import check changes\n"
       "The v6 nexthop to signal for watching\n"
       "Should the route be connected\n")
 {
+       struct vrf *vrf;
        struct prefix p;
        bool type_import;
 
+       if (!name)
+               name = VRF_DEFAULT_NAME;
+       vrf = vrf_lookup_by_name(name);
+       if (!vrf) {
+               vty_out(vty, "The vrf NAME specified: %s does not exist\n",
+                       name);
+               return CMD_WARNING;
+       }
 
        if (n)
                type_import = false;
@@ -63,24 +74,36 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd,
        p.family = AF_INET6;
 
        sharp_nh_tracker_get(&p);
-       sharp_zebra_nexthop_watch(&p, VRF_DEFAULT, type_import,
+       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
                                  true, !!connected);
 
        return CMD_SUCCESS;
 }
 
 DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
-      "sharp watch <nexthop$n|import$import> A.B.C.D$nhop [connected$connected]",
+      "sharp watch [vrf NAME$name] <nexthop$n|import$import> A.B.C.D$nhop [connected$connected]",
       "Sharp routing Protocol\n"
       "Watch for changes\n"
+      "The vrf we would like to watch if non-default\n"
+      "The NAME of the vrf\n"
       "Watch for nexthop changes\n"
       "Watch for import check changes\n"
       "The v4 nexthop to signal for watching\n"
       "Should the route be connected\n")
 {
+       struct vrf *vrf;
        struct prefix p;
        bool type_import;
 
+       if (!name)
+               name = VRF_DEFAULT_NAME;
+       vrf = vrf_lookup_by_name(name);
+       if (!vrf) {
+               vty_out(vty, "The vrf NAME specified: %s does not exist\n",
+                       name);
+               return CMD_WARNING;
+       }
+
        memset(&p, 0, sizeof(p));
 
        if (n)
@@ -93,7 +116,7 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
        p.family = AF_INET;
 
        sharp_nh_tracker_get(&p);
-       sharp_zebra_nexthop_watch(&p, VRF_DEFAULT, type_import,
+       sharp_zebra_nexthop_watch(&p, vrf->vrf_id, type_import,
                                  true, !!connected);
 
        return CMD_SUCCESS;
@@ -181,10 +204,13 @@ DEFPY (install_routes,
        }
        sg.r.orig_prefix = prefix;
 
-       vrf = vrf_lookup_by_name(name ? name : VRF_DEFAULT_NAME);
+       if (!name)
+               name = VRF_DEFAULT_NAME;
+
+       vrf = vrf_lookup_by_name(name);
        if (!vrf) {
                vty_out(vty, "The vrf NAME specified: %s does not exist\n",
-                       name ? name : VRF_DEFAULT_NAME);
+                       name);
                return CMD_WARNING;
        }