Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions frr/if_grout.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,8 @@ void grout_link_change(struct gr_iface *gr_if, bool new, bool startup) {
dplane_ctx_set_ifp_zltype(ctx, link_type);
dplane_ctx_set_ifp_flags(ctx, gr_if_flags_to_netlink(gr_if, link_type));
dplane_ctx_set_ifp_protodown_set(ctx, false);

if (gr_if->base.vrf_id != 0) {
dplane_ctx_set_ifp_table_id(ctx, ifindex_grout_to_frr(gr_if->base.vrf_id));

// In Linux, vrf_id equals the interface index; in Grout we model a VRF
// with its gr‑vrf interface
// The gr‑vrf’s ifindex is guaranteed to match vrf_id
dplane_ctx_set_ifp_vrf_id(ctx, ifindex_grout_to_frr(gr_if->base.vrf_id));
} else {
dplane_ctx_set_ifp_table_id(ctx, 0);
dplane_ctx_set_ifp_vrf_id(ctx, 0);
}
dplane_ctx_set_ifp_table_id(ctx, gr_if->base.vrf_id);
dplane_ctx_set_ifp_vrf_id(ctx, gr_if->base.vrf_id);

if (mac)
dplane_ctx_set_ifp_hw_addr(
Expand Down
42 changes: 12 additions & 30 deletions frr/rt_grout.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static int grout_gr_nexthop_to_frr_nexthop(
int *nh_family
) {
nh->ifindex = ifindex_grout_to_frr(gr_nh->iface_id);
nh->vrf_id = ifindex_grout_to_frr(gr_nh->vrf_id);
nh->vrf_id = gr_nh->vrf_id;
nh->weight = 1;

switch (gr_nh->type) {
Expand Down Expand Up @@ -268,7 +268,7 @@ static int grout_gr_nexthop_to_frr_nexthop(
break;
}

ctx.table = ifindex_grout_to_frr(sr6->out_vrf_id);
ctx.table = sr6->out_vrf_id;
nexthop_add_srv6_seg6local(nh, action, &ctx);
break;
}
Expand All @@ -292,7 +292,7 @@ static int grout_gr_nexthop_to_frr_nexthop(
}
case GR_NH_T_GROUP:
nh->ifindex = ifindex_grout_to_frr(gr_nh->iface_id);
nh->vrf_id = ifindex_grout_to_frr(gr_nh->vrf_id);
nh->vrf_id = gr_nh->vrf_id;
*nh_family = AF_UNSPEC;
nh->weight = 1;
break;
Expand All @@ -314,7 +314,7 @@ static void grout_route_change(
uint8_t dest_prefixlen,
struct gr_nexthop *gr_nh
) {
uint32_t vrf_id = ifindex_grout_to_frr(gr_nh->vrf_id);
uint32_t vrf_id = gr_nh->vrf_id;
int proto = ZEBRA_ROUTE_KERNEL;
uint32_t nh_id = gr_nh->nh_id;
// Grout has no per‑VRF routing tables; table_id always equals vrf_id
Expand Down Expand Up @@ -464,7 +464,7 @@ enum zebra_dplane_result grout_add_del_route(struct zebra_dplane_ctx *ctx) {
struct gr_ip6_route_del_req r6_del;
} req;
uint32_t nh_id = dplane_ctx_get_nhe_id(ctx);
uint32_t vrf_id = ifindex_frr_to_grout(dplane_ctx_get_vrf(ctx));
uint32_t vrf_id = dplane_ctx_get_vrf(ctx);
const struct prefix *p;
gr_nh_origin_t origin;
uint32_t req_type;
Expand Down Expand Up @@ -668,7 +668,7 @@ grout_add_nexthop(uint32_t nh_id, gr_nh_origin_t origin, const struct nexthop *n
req->nh.nh_id = nh_id;
req->nh.origin = origin;
req->nh.type = type;
req->nh.vrf_id = ifindex_frr_to_grout(nh->vrf_id);
req->nh.vrf_id = nh->vrf_id;
req->nh.iface_id = ifindex_frr_to_grout(nh->ifindex);

switch (type) {
Expand Down Expand Up @@ -704,27 +704,19 @@ grout_add_nexthop(uint32_t nh_id, gr_nh_origin_t origin, const struct nexthop *n
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_T:
sr6_local->behavior = SR_BEHAVIOR_END_T;
sr6_local->out_vrf_id = ifindex_frr_to_grout(
nh->nh_srv6->seg6local_ctx.table
);
sr6_local->out_vrf_id = nh->nh_srv6->seg6local_ctx.table;
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_DT6:
sr6_local->behavior = SR_BEHAVIOR_END_DT6;
sr6_local->out_vrf_id = ifindex_frr_to_grout(
nh->nh_srv6->seg6local_ctx.table
);
sr6_local->out_vrf_id = nh->nh_srv6->seg6local_ctx.table;
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_DT4:
sr6_local->behavior = SR_BEHAVIOR_END_DT4;
sr6_local->out_vrf_id = ifindex_frr_to_grout(
nh->nh_srv6->seg6local_ctx.table
);
sr6_local->out_vrf_id = nh->nh_srv6->seg6local_ctx.table;
break;
case ZEBRA_SEG6_LOCAL_ACTION_END_DT46:
sr6_local->behavior = SR_BEHAVIOR_END_DT46;
sr6_local->out_vrf_id = ifindex_frr_to_grout(
nh->nh_srv6->seg6local_ctx.table
);
sr6_local->out_vrf_id = nh->nh_srv6->seg6local_ctx.table;
break;
default:
gr_log_err(
Expand Down Expand Up @@ -831,7 +823,7 @@ void grout_nexthop_change(bool new, struct gr_nexthop *gr_nh, bool startup) {
}

if (!new) {
zebra_nhg_kernel_del(gr_nh->nh_id, ifindex_grout_to_frr(gr_nh->vrf_id));
zebra_nhg_kernel_del(gr_nh->nh_id, gr_nh->vrf_id);
return;
}

Expand All @@ -850,17 +842,7 @@ void grout_nexthop_change(bool new, struct gr_nexthop *gr_nh, bool startup) {
type = origin2zebra(gr_nh->origin, family, false);
SET_FLAG(nh->flags, NEXTHOP_FLAG_ACTIVE);

zebra_nhg_kernel_find(
gr_nh->nh_id,
nh,
NULL,
0,
ifindex_grout_to_frr(gr_nh->vrf_id),
afi,
type,
startup,
NULL
);
zebra_nhg_kernel_find(gr_nh->nh_id, nh, NULL, 0, gr_nh->vrf_id, afi, type, startup, NULL);

// zebra_nhg_kernel_find() makes a *shallow* copy of the allocated nexthop.
// nexthop_free() must *NOT* be used to preserve the nh_srv6 context.
Expand Down
31 changes: 6 additions & 25 deletions modules/infra/control/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,13 @@ void iface_type_register(struct iface_type *type) {
// the first slot is wasted by GR_IFACE_ID_UNDEF
static struct iface **ifaces;

// Reserve a specific interface id.
// Returns 0 on success, -errno on failure.
static int reserve_ifid(uint16_t ifid) {
if (ifid >= MAX_IFACES)
return errno_set(EINVAL);

if (ifaces[ifid] == NULL)
return 0;

return errno_set(EBUSY);
}

// The slot 1 to 255 are reserved for gr_loopback
static int next_ifid(uint16_t *ifid) {
for (uint16_t i = GR_MAX_VRFS; i < MAX_IFACES; i++) {
if (reserve_ifid(i) < 0)
continue;

*ifid = i;
return 0;
for (uint16_t i = IFACE_ID_FIRST; i < MAX_IFACES; i++) {
if (ifaces[i] == NULL) {
*ifid = i;
return 0;
}
}

return errno_set(ENOSPC);
}

Expand Down Expand Up @@ -100,11 +85,7 @@ struct iface *iface_create(const struct gr_iface *conf, const void *api_info) {
vrf_incref(conf->vrf_id);
vrf_ref = true;
}
if (conf->type == GR_IFACE_TYPE_LOOPBACK && conf->vrf_id) {
ifid = conf->vrf_id;
if (reserve_ifid(ifid) < 0)
goto fail;
} else if (next_ifid(&ifid) < 0)
if (next_ifid(&ifid) < 0)
goto fail;

iface->base = conf->base;
Expand Down
4 changes: 3 additions & 1 deletion subprojects/frr.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ url = https://github.com/FRRouting/frr
revision = frr-10.5.0
depth = 1
diff_files =
frr/meson-add-dependency-definition.patch
frr/meson-add-dependency-definition.patch,
frr/0001-zebra-do-not-rely-on-dplane-table_id-for-VRF-delete.patch,
frr/0002-zebra-use-dplane-provided-vrf_id-instead-of-casting-.patch

[provide]
dependency_names = frr
Loading