]> git.proxmox.com Git - mirror_frr.git/commitdiff
sharpd: Add some infrastructure to allow test of ZEBRA_VRF_LABEL
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 30 Jan 2018 18:54:38 +0000 (13:54 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 9 Feb 2018 01:31:37 +0000 (20:31 -0500)
Add some infrastructure to allow the testing of ZEBRA_VRF_LABEL

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

index a35157faa19ef82dce174acb2a15b7b9ddeaa8f4..efbe989721dfc945cb887ae701eb27461282a3d1 100644 (file)
@@ -26,6 +26,8 @@
 #include "prefix.h"
 #include "nexthop.h"
 #include "log.h"
+#include "vrf.h"
+#include "zclient.h"
 
 #include "sharpd/sharp_zebra.h"
 #include "sharpd/sharp_vty.h"
@@ -76,6 +78,30 @@ DEFPY (install_routes,
        return CMD_SUCCESS;
 }
 
+DEFPY(vrf_label,
+      vrf_label_cmd,
+      "label vrf NAME$name label (0-100000)$label",
+      "Give a vrf a label\n"
+      VRF_CMD_HELP_STR
+      "The label to use\n"
+      "Specified range to use\n")
+{
+       struct vrf *vrf;
+
+       if (strcmp(name, "default") == 0)
+               vrf = vrf_lookup_by_id(VRF_DEFAULT);
+       else
+               vrf = vrf_lookup_by_name(name);
+
+       if (!vrf) {
+               vty_out(vty, "Unable to find vrf you silly head");
+               return CMD_WARNING_CONFIG_FAILED;
+       }
+
+       vrf_label_add(vrf->vrf_id, label);
+       return CMD_SUCCESS;
+}
+
 DEFPY (remove_routes,
        remove_routes_cmd,
        "remove routes A.B.C.D$start (1-1000000)$routes",
@@ -112,5 +138,6 @@ void sharp_vty_init(void)
 {
        install_element(ENABLE_NODE, &install_routes_cmd);
        install_element(ENABLE_NODE, &remove_routes_cmd);
+       install_element(ENABLE_NODE, &vrf_label_cmd);
        return;
 }
index 10e48ac6287e3444e32e8fb4a5bfb51521bbd2e8..5dffd4ab9b492a8d82f185f5bb57a9348818aacf 100644 (file)
@@ -152,6 +152,11 @@ static void zebra_connected(struct zclient *zclient)
        zclient_send_reg_requests(zclient, VRF_DEFAULT);
 }
 
+void vrf_label_add(vrf_id_t vrf_id, mpls_label_t label)
+{
+       zclient_send_vrf_label(zclient, vrf_id, label);
+}
+
 void route_add(struct prefix *p, struct nexthop *nh)
 {
        struct zapi_route api;
index 97100f61a64a47509462a25e7357ce763e8b1a72..281c67ff9467bbe5a438e3413d3846e4c588715e 100644 (file)
@@ -24,6 +24,7 @@
 
 extern void sharp_zebra_init(void);
 
+extern void vrf_label_add(vrf_id_t vrf_id, mpls_label_t label);
 extern void route_add(struct prefix *p, struct nexthop *nh);
 extern void route_delete(struct prefix *p);
 #endif