]> git.puffer.fish Git - matthieu/frr.git/commitdiff
sharp: Allow the specification of instance when adding/deleting routes
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 17 May 2018 14:56:45 +0000 (10:56 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 17 May 2018 14:59:17 +0000 (10:59 -0400)
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
sharpd/sharp_vty.c
sharpd/sharp_zebra.c
sharpd/sharp_zebra.h

index 4d19484a64172191d24818ff277677c114011459..956da9d4edd44baa4b13a4bcae40432346d0f987 100644 (file)
@@ -81,14 +81,16 @@ DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd,
 
 DEFPY (install_routes,
        install_routes_cmd,
-       "sharp install routes A.B.C.D$start nexthop A.B.C.D$nexthop (1-1000000)$routes",
+       "sharp install routes A.B.C.D$start nexthop A.B.C.D$nexthop (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp routing Protocol\n"
        "install some routes\n"
        "Routes to install\n"
        "Address to start /32 generation at\n"
        "Nexthop to use\n"
        "Nexthop address\n"
-       "How many to create\n")
+       "How many to create\n"
+       "Instance to use\n"
+       "Instance\n")
 {
        int i;
        struct prefix p;
@@ -112,7 +114,7 @@ DEFPY (install_routes,
 
        temp = ntohl(p.u.prefix4.s_addr);
        for (i = 0; i < routes; i++) {
-               route_add(&p, &nhop);
+               route_add(&p, (uint8_t)instance, &nhop);
                p.u.prefix4.s_addr = htonl(++temp);
        }
 
@@ -151,17 +153,18 @@ DEFPY(vrf_label, vrf_label_cmd,
 
 DEFPY (remove_routes,
        remove_routes_cmd,
-       "sharp remove routes A.B.C.D$start (1-1000000)$routes",
+       "sharp remove routes A.B.C.D$start (1-1000000)$routes [instance (0-255)$instance]",
        "Sharp Routing Protocol\n"
        "Remove some routes\n"
        "Routes to remove\n"
        "Starting spot\n"
-       "Routes to uniinstall\n")
+       "Routes to uniinstall\n"
+       "instance to use\n"
+       "Value of instance\n")
 {
        int i;
        struct prefix p;
        uint32_t temp;
-
        total_routes = routes;
        removed_routes = 0;
 
@@ -175,7 +178,7 @@ DEFPY (remove_routes,
 
        temp = ntohl(p.u.prefix4.s_addr);
        for (i = 0; i < routes; i++) {
-               route_delete(&p);
+               route_delete(&p, (uint8_t)instance);
                p.u.prefix4.s_addr = htonl(++temp);
        }
 
index 999255e9254e08f812ab649da3f03326b9ec2093..fcb555170b8870d94c6422da6b370456d5a59db5 100644 (file)
@@ -176,7 +176,7 @@ void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label)
        zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP);
 }
 
-void route_add(struct prefix *p, struct nexthop *nh)
+void route_add(struct prefix *p, uint8_t instance, struct nexthop *nh)
 {
        struct zapi_route api;
        struct zapi_nexthop *api_nh;
@@ -184,6 +184,7 @@ void route_add(struct prefix *p, struct nexthop *nh)
        memset(&api, 0, sizeof(api));
        api.vrf_id = VRF_DEFAULT;
        api.type = ZEBRA_ROUTE_SHARP;
+       api.instance = instance;
        api.safi = SAFI_UNICAST;
        memcpy(&api.prefix, p, sizeof(*p));
 
@@ -200,7 +201,7 @@ void route_add(struct prefix *p, struct nexthop *nh)
        zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
 }
 
-void route_delete(struct prefix *p)
+void route_delete(struct prefix *p, uint8_t instance)
 {
        struct zapi_route api;
 
@@ -208,6 +209,7 @@ void route_delete(struct prefix *p)
        api.vrf_id = VRF_DEFAULT;
        api.type = ZEBRA_ROUTE_SHARP;
        api.safi = SAFI_UNICAST;
+       api.instance = instance;
        memcpy(&api.prefix, p, sizeof(*p));
        zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
 
index 0c906fc4ffd10fc97ed7ae2121fefb46527b50c1..58438ed01d821b2f9b8c1f9eda64062e493254e5 100644 (file)
@@ -25,7 +25,7 @@
 extern void sharp_zebra_init(void);
 
 extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label);
-extern void route_add(struct prefix *p, struct nexthop *nh);
-extern void route_delete(struct prefix *p);
+extern void route_add(struct prefix *p, uint8_t instance, struct nexthop *nh);
+extern void route_delete(struct prefix *p, uint8_t instance);
 extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch);
 #endif