]> git.proxmox.com Git - mirror_frr.git/commitdiff
sharpd: Setup route installation to be able to select vrf to use
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 28 Feb 2019 12:51:41 +0000 (07:51 -0500)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 1 Mar 2019 21:12:05 +0000 (16:12 -0500)
Modify the sharp code to allow for vrf route installation.  At
this point in time the code is nascent.  Future commits will turn
on this behavior.

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

index 065fb092d4e8f6dcc2e2c9d5fd7f2d45377ab521..4e5c933667acd367b501f029fe1aae0457b4c100 100644 (file)
@@ -38,6 +38,7 @@ struct sharp_routes {
        int32_t repeat;
 
        uint8_t inst;
+       vrf_id_t vrf_id;
 
        struct timeval t_start;
        struct timeval t_end;
index 9018cfb359986db22f9dadcbb05afcff15f1c249..72a46d5e6d82469d6e7b96e618e98f861fff7759 100644 (file)
@@ -195,12 +195,15 @@ DEFPY (install_routes,
                        sg.r.nhop.type = NEXTHOP_TYPE_IPV6;
                }
 
+               sg.r.nhop.vrf_id = VRF_DEFAULT;
                sg.r.nhop_group.nexthop = &sg.r.nhop;
        }
 
        sg.r.inst = instance;
+       sg.r.vrf_id = VRF_DEFAULT;
        rts = routes;
-       sharp_install_routes_helper(&prefix, sg.r.inst, &sg.r.nhop_group, rts);
+       sharp_install_routes_helper(&prefix, sg.r.vrf_id,
+                                   sg.r.inst, &sg.r.nhop_group, rts);
 
        return CMD_SUCCESS;
 }
@@ -266,8 +269,10 @@ DEFPY (remove_routes,
        }
 
        sg.r.inst = instance;
+       sg.r.vrf_id = VRF_DEFAULT;
        rts = routes;
-       sharp_remove_routes_helper(&prefix, sg.r.inst, rts);
+       sharp_remove_routes_helper(&prefix, sg.r.vrf_id,
+                                  sg.r.inst, rts);
 
        return CMD_SUCCESS;
 }
index 4682dbc73a4fd3e4e73602d880b9ef7765eb92b2..942040b8021b5317d943cf1fff31e94d9de0e7c4 100644 (file)
@@ -131,8 +131,8 @@ static int interface_state_down(int command, struct zclient *zclient,
        return 0;
 }
 
-void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
-                                struct nexthop_group *nhg,
+void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
+                                uint8_t instance, struct nexthop_group *nhg,
                                 uint32_t routes)
 {
        uint32_t temp, i;
@@ -148,7 +148,7 @@ void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
 
        monotime(&sg.r.t_start);
        for (i = 0; i < routes; i++) {
-               route_add(p, (uint8_t)instance, nhg);
+               route_add(p, vrf_id, (uint8_t)instance, nhg);
                if (v4)
                        p->u.prefix4.s_addr = htonl(++temp);
                else
@@ -156,8 +156,8 @@ void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
        }
 }
 
-void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
-                               uint32_t routes)
+void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
+                               uint8_t instance, uint32_t routes)
 {
        uint32_t temp, i;
        bool v4 = false;
@@ -172,7 +172,7 @@ void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
 
        monotime(&sg.r.t_start);
        for (i = 0; i < routes; i++) {
-               route_delete(p, (uint8_t)instance);
+               route_delete(p, vrf_id, (uint8_t)instance);
                if (v4)
                        p->u.prefix4.s_addr = htonl(++temp);
                else
@@ -190,12 +190,14 @@ static void handle_repeated(bool installed)
 
        if (installed) {
                sg.r.removed_routes = 0;
-               sharp_remove_routes_helper(&p, sg.r.inst, sg.r.total_routes);
+               sharp_remove_routes_helper(&p, sg.r.vrf_id,
+                                          sg.r.inst, sg.r.total_routes);
        }
 
        if (installed) {
                sg.r.installed_routes = 0;
-               sharp_install_routes_helper(&p, sg.r.inst, &sg.r.nhop_group,
+               sharp_install_routes_helper(&p, sg.r.vrf_id, sg.r.inst,
+                                           &sg.r.nhop_group,
                                            sg.r.total_routes);
        }
 }
@@ -255,7 +257,8 @@ 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, uint8_t instance, struct nexthop_group *nhg)
+void route_add(struct prefix *p, vrf_id_t vrf_id,
+              uint8_t instance, struct nexthop_group *nhg)
 {
        struct zapi_route api;
        struct zapi_nexthop *api_nh;
@@ -263,7 +266,7 @@ void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg)
        int i = 0;
 
        memset(&api, 0, sizeof(api));
-       api.vrf_id = VRF_DEFAULT;
+       api.vrf_id = vrf_id;
        api.type = ZEBRA_ROUTE_SHARP;
        api.instance = instance;
        api.safi = SAFI_UNICAST;
@@ -274,7 +277,7 @@ void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg)
 
        for (ALL_NEXTHOPS_PTR(nhg, nh)) {
                api_nh = &api.nexthops[i];
-               api_nh->vrf_id = VRF_DEFAULT;
+               api_nh->vrf_id = nh->vrf_id;
                api_nh->type = nh->type;
                switch (nh->type) {
                case NEXTHOP_TYPE_IPV4:
@@ -305,12 +308,12 @@ void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg)
        zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
 }
 
-void route_delete(struct prefix *p, uint8_t instance)
+void route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance)
 {
        struct zapi_route api;
 
        memset(&api, 0, sizeof(api));
-       api.vrf_id = VRF_DEFAULT;
+       api.vrf_id = vrf_id;
        api.type = ZEBRA_ROUTE_SHARP;
        api.safi = SAFI_UNICAST;
        api.instance = instance;
index b219022f028cd481d6afb296806589705da5d685..7c3c39c89269dbf947f3f5670c33429fc8b6ec46 100644 (file)
 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, uint8_t instance,
+extern void route_add(struct prefix *p, vrf_id_t, uint8_t instance,
                      struct nexthop_group *nhg);
-extern void route_delete(struct prefix *p, uint8_t instance);
+extern void route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance);
 extern void sharp_zebra_nexthop_watch(struct prefix *p, bool import,
                                      bool watch, bool connected);
 
-extern void sharp_install_routes_helper(struct prefix *p, uint8_t instance,
-                                        struct nexthop_group *nhg,
-                                        uint32_t routes);
-extern void sharp_remove_routes_helper(struct prefix *p, uint8_t instance,
-                                      uint32_t routes);
+extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
+                                       uint8_t instance,
+                                       struct nexthop_group *nhg,
+                                       uint32_t routes);
+extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
+                                      uint8_t instance, uint32_t routes);
 #endif