mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 03:00:24 +00:00
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>
This commit is contained in:
parent
d49e6c4afd
commit
c27b47d791
@ -40,6 +40,9 @@ struct sharp_routes {
|
|||||||
uint32_t removed_routes;
|
uint32_t removed_routes;
|
||||||
int32_t repeat;
|
int32_t repeat;
|
||||||
|
|
||||||
|
/* ZAPI_ROUTE's flag */
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
uint8_t inst;
|
uint8_t inst;
|
||||||
vrf_id_t vrf_id;
|
vrf_id_t vrf_id;
|
||||||
|
|
||||||
|
@ -219,6 +219,7 @@ DEFPY (install_routes,
|
|||||||
struct prefix prefix;
|
struct prefix prefix;
|
||||||
uint32_t rts;
|
uint32_t rts;
|
||||||
uint32_t nhgid = 0;
|
uint32_t nhgid = 0;
|
||||||
|
uint32_t route_flags = 0;
|
||||||
|
|
||||||
sg.r.total_routes = routes;
|
sg.r.total_routes = routes;
|
||||||
sg.r.installed_routes = 0;
|
sg.r.installed_routes = 0;
|
||||||
@ -332,7 +333,7 @@ DEFPY (install_routes,
|
|||||||
rts = routes;
|
rts = routes;
|
||||||
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid,
|
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid,
|
||||||
&sg.r.nhop_group, &sg.r.backup_nhop_group,
|
&sg.r.nhop_group, &sg.r.backup_nhop_group,
|
||||||
rts, sg.r.opaque);
|
rts, route_flags, sg.r.opaque);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,7 @@ struct buffer_delay {
|
|||||||
vrf_id_t vrf_id;
|
vrf_id_t vrf_id;
|
||||||
uint8_t instance;
|
uint8_t instance;
|
||||||
uint32_t nhgid;
|
uint32_t nhgid;
|
||||||
|
uint32_t flags;
|
||||||
const struct nexthop_group *nhg;
|
const struct nexthop_group *nhg;
|
||||||
const struct nexthop_group *backup_nhg;
|
const struct nexthop_group *backup_nhg;
|
||||||
enum where_to_restart restart;
|
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,
|
static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,
|
||||||
uint32_t nhgid, const struct nexthop_group *nhg,
|
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_route api;
|
||||||
struct zapi_nexthop *api_nh;
|
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;
|
api.safi = SAFI_UNICAST;
|
||||||
memcpy(&api.prefix, p, sizeof(*p));
|
memcpy(&api.prefix, p, sizeof(*p));
|
||||||
|
|
||||||
|
api.flags = flags;
|
||||||
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
|
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
|
||||||
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
|
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,
|
uint32_t nhgid,
|
||||||
const struct nexthop_group *nhg,
|
const struct nexthop_group *nhg,
|
||||||
const struct nexthop_group *backup_nhg,
|
const struct nexthop_group *backup_nhg,
|
||||||
uint32_t routes, char *opaque)
|
uint32_t routes, uint32_t flags, char *opaque)
|
||||||
{
|
{
|
||||||
uint32_t temp, i;
|
uint32_t temp, i;
|
||||||
bool v4 = false;
|
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++) {
|
for (i = count; i < routes; i++) {
|
||||||
bool buffered = route_add(p, vrf_id, (uint8_t)instance, nhgid,
|
bool buffered = route_add(p, vrf_id, (uint8_t)instance, nhgid,
|
||||||
nhg, backup_nhg, opaque);
|
nhg, backup_nhg, flags, opaque);
|
||||||
if (v4)
|
if (v4)
|
||||||
p->u.prefix4.s_addr = htonl(++temp);
|
p->u.prefix4.s_addr = htonl(++temp);
|
||||||
else
|
else
|
||||||
@ -362,6 +365,7 @@ static void sharp_install_routes_restart(struct prefix *p, uint32_t count,
|
|||||||
wb.instance = instance;
|
wb.instance = instance;
|
||||||
wb.nhgid = nhgid;
|
wb.nhgid = nhgid;
|
||||||
wb.nhg = nhg;
|
wb.nhg = nhg;
|
||||||
|
wb.flags = flags;
|
||||||
wb.backup_nhg = backup_nhg;
|
wb.backup_nhg = backup_nhg;
|
||||||
wb.opaque = opaque;
|
wb.opaque = opaque;
|
||||||
wb.restart = SHARP_INSTALL_ROUTES_RESTART;
|
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,
|
uint8_t instance, uint32_t nhgid,
|
||||||
const struct nexthop_group *nhg,
|
const struct nexthop_group *nhg,
|
||||||
const struct nexthop_group *backup_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);
|
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);
|
monotime(&sg.r.t_start);
|
||||||
sharp_install_routes_restart(p, 0, vrf_id, instance, nhgid, nhg,
|
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,
|
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,
|
sharp_install_routes_helper(&p, sg.r.vrf_id, sg.r.inst,
|
||||||
sg.r.nhgid, &sg.r.nhop_group,
|
sg.r.nhgid, &sg.r.nhop_group,
|
||||||
&sg.r.backup_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:
|
case SHARP_INSTALL_ROUTES_RESTART:
|
||||||
sharp_install_routes_restart(
|
sharp_install_routes_restart(
|
||||||
&wb.p, wb.count, wb.vrf_id, wb.instance, wb.nhgid,
|
&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;
|
return;
|
||||||
case SHARP_DELETE_ROUTES_RESTART:
|
case SHARP_DELETE_ROUTES_RESTART:
|
||||||
sharp_remove_routes_restart(&wb.p, wb.count, wb.vrf_id,
|
sharp_remove_routes_restart(&wb.p, wb.count, wb.vrf_id,
|
||||||
|
@ -39,7 +39,7 @@ extern void sharp_install_routes_helper(struct prefix *p, vrf_id_t vrf_id,
|
|||||||
uint8_t instance, uint32_t nhgid,
|
uint8_t instance, uint32_t nhgid,
|
||||||
const struct nexthop_group *nhg,
|
const struct nexthop_group *nhg,
|
||||||
const struct nexthop_group *backup_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,
|
extern void sharp_remove_routes_helper(struct prefix *p, vrf_id_t vrf_id,
|
||||||
uint8_t instance, uint32_t routes);
|
uint8_t instance, uint32_t routes);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user