diff options
author | Hiroki Shirokura <slank.dev@gmail.com> | 2020-12-06 09:13:19 +0100 |
---|---|---|
committer | Mark Stapp <mjs@voltanet.io> | 2021-06-02 16:24:47 +0200 |
commit | c27b47d7916d0abd558fed46ba2c6e11d2573b3f (patch) | |
tree | 2a7c3160b5051dfc40c27ce991a67261502b78df /sharpd | |
parent | zebra: parse non-zebra seg6local configuration via netlink (step1) (diff) | |
download | frr-c27b47d7916d0abd558fed46ba2c6e11d2573b3f.tar.xz frr-c27b47d7916d0abd558fed46ba2c6e11d2573b3f.zip |
sharpd: install_routes_helper support ZAPI_ROUTE flags (step1)
current route addition mechanism on shaprd support only ipv4/v6 nexthop
routes simply. so It doesn't need to ensure flags of zapi_routes.
Then when we want to configure more complicated routing feature (like a
srv6), we will want to control flags of zapi_route. In this patch, it
will supports to configure flags of zapi_route when sharpd calls
ZEBRA_ROUTE_ADD.
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Diffstat (limited to 'sharpd')
-rw-r--r-- | sharpd/sharp_globals.h | 3 | ||||
-rw-r--r-- | sharpd/sharp_vty.c | 3 | ||||
-rw-r--r-- | sharpd/sharp_zebra.c | 20 | ||||
-rw-r--r-- | sharpd/sharp_zebra.h | 2 |
4 files changed, 19 insertions, 9 deletions
diff --git a/sharpd/sharp_globals.h b/sharpd/sharp_globals.h index 0b3776cd9..b050ba85c 100644 --- a/sharpd/sharp_globals.h +++ b/sharpd/sharp_globals.h @@ -40,6 +40,9 @@ struct sharp_routes { uint32_t removed_routes; int32_t repeat; + /* ZAPI_ROUTE's flag */ + uint32_t flags; + uint8_t inst; vrf_id_t vrf_id; diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 1ff0591d5..de2d092c3 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -219,6 +219,7 @@ DEFPY (install_routes, struct prefix prefix; uint32_t rts; uint32_t nhgid = 0; + uint32_t route_flags = 0; sg.r.total_routes = routes; sg.r.installed_routes = 0; @@ -332,7 +333,7 @@ DEFPY (install_routes, rts = routes; sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid, &sg.r.nhop_group, &sg.r.backup_nhop_group, - rts, sg.r.opaque); + rts, route_flags, sg.r.opaque); return CMD_SUCCESS; } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 128cfe2de..da056160b 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -230,6 +230,7 @@ struct buffer_delay { vrf_id_t vrf_id; uint8_t instance; uint32_t nhgid; + uint32_t flags; const struct nexthop_group *nhg; const struct nexthop_group *backup_nhg; enum where_to_restart restart; @@ -244,7 +245,8 @@ struct buffer_delay { */ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t nhgid, const struct nexthop_group *nhg, - const struct nexthop_group *backup_nhg, char *opaque) + const struct nexthop_group *backup_nhg, uint32_t flags, + char *opaque) { struct zapi_route api; struct zapi_nexthop *api_nh; @@ -258,6 +260,7 @@ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance, api.safi = SAFI_UNICAST; memcpy(&api.prefix, p, sizeof(*p)); + api.flags = flags; SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); @@ -335,7 +338,7 @@ static void sharp_install_routes_restart(struct prefix *p, uint32_t count, uint32_t nhgid, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg, - uint32_t routes, char *opaque) + uint32_t routes, uint32_t flags, char *opaque) { uint32_t temp, i; bool v4 = false; @@ -348,7 +351,7 @@ static void sharp_install_routes_restart(struct prefix *p, uint32_t count, for (i = count; i < routes; i++) { bool buffered = route_add(p, vrf_id, (uint8_t)instance, nhgid, - nhg, backup_nhg, opaque); + nhg, backup_nhg, flags, opaque); if (v4) p->u.prefix4.s_addr = htonl(++temp); else @@ -362,6 +365,7 @@ static void sharp_install_routes_restart(struct prefix *p, uint32_t count, wb.instance = instance; wb.nhgid = nhgid; wb.nhg = nhg; + wb.flags = flags; wb.backup_nhg = backup_nhg; wb.opaque = opaque; wb.restart = SHARP_INSTALL_ROUTES_RESTART; @@ -375,7 +379,7 @@ void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t nhgid, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg, - uint32_t routes, char *opaque) + uint32_t routes, uint32_t flags, char *opaque) { zlog_debug("Inserting %u routes", routes); @@ -385,7 +389,7 @@ void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id, monotime(&sg.r.t_start); sharp_install_routes_restart(p, 0, vrf_id, instance, nhgid, nhg, - backup_nhg, routes, opaque); + backup_nhg, routes, flags, opaque); } static void sharp_remove_routes_restart(struct prefix *p, uint32_t count, @@ -451,7 +455,8 @@ static void handle_repeated(bool installed) sharp_install_routes_helper(&p, sg.r.vrf_id, sg.r.inst, sg.r.nhgid, &sg.r.nhop_group, &sg.r.backup_nhop_group, - sg.r.total_routes, sg.r.opaque); + sg.r.total_routes, sg.r.flags, + sg.r.opaque); } } @@ -461,7 +466,8 @@ static void sharp_zclient_buffer_ready(void) case SHARP_INSTALL_ROUTES_RESTART: sharp_install_routes_restart( &wb.p, wb.count, wb.vrf_id, wb.instance, wb.nhgid, - wb.nhg, wb.backup_nhg, wb.routes, wb.opaque); + wb.nhg, wb.backup_nhg, wb.routes, wb.flags, + wb.opaque); return; case SHARP_DELETE_ROUTES_RESTART: sharp_remove_routes_restart(&wb.p, wb.count, wb.vrf_id, diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 4355f49a2..495ce6ec5 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -39,7 +39,7 @@ extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t nhgid, const struct nexthop_group *nhg, const struct nexthop_group *backup_nhg, - uint32_t routes, char *opaque); + uint32_t routes, uint32_t flags, char *opaque); extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id, uint8_t instance, uint32_t routes); |