Skip to content

Commit d9fe390

Browse files
frr: configure blackhole NH
Using the new blackole nexthop, remove current limitation about FRR not able to configure a blackhole route. blackhole configured from grout are displayed as following in zebra: grout# add nexthop id 666 blackhole ID: 666 (kernel) RefCnt: 0 Uptime: 00:00:05 VRF: default(IPv4) Nexthop Count: 1 Valid, Installed unreachable (blackhole), weight 1 We don't support yet the blackhole type. Signed-off-by: Christophe Fontaine <[email protected]>
1 parent 1a694d8 commit d9fe390

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

frr/rt_grout.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ static int
190190
grout_gr_nexthop_to_frr_nexthop(struct gr_nexthop *gr_nh, struct nexthop *nh, int *nh_family) {
191191
size_t sz;
192192

193+
if (gr_nh->type == GR_NH_T_BLACKHOLE) {
194+
nh->vrf_id = gr_nh->vrf_id;
195+
nh->type = NEXTHOP_TYPE_BLACKHOLE;
196+
nh->bh_type = BLACKHOLE_NULL;
197+
*nh_family = AF_UNSPEC;
198+
nh->weight = 1;
199+
return 0;
200+
}
201+
193202
if (gr_nh->type != GR_NH_T_L3) {
194203
gr_log_err("sync nexthop not L3 from grout is not supported");
195204
return -1;
@@ -781,10 +790,6 @@ enum zebra_dplane_result grout_add_del_nexthop(struct zebra_dplane_ctx *ctx) {
781790
}
782791

783792
nh = dplane_ctx_get_nhe_ng(ctx)->nexthop;
784-
if (nh->type == NEXTHOP_TYPE_BLACKHOLE) {
785-
gr_log_err("impossible to add/del blackhole nexthop (not supported)");
786-
return ZEBRA_DPLANE_REQUEST_FAILURE;
787-
}
788793
if (nh->nh_srv6) {
789794
gr_log_err("impossible to add/del srv6 nexthop (not supported)");
790795
return ZEBRA_DPLANE_REQUEST_SUCCESS;
@@ -820,11 +825,12 @@ enum zebra_dplane_result grout_add_del_nexthop(struct zebra_dplane_ctx *ctx) {
820825
else
821826
gr_nh->af = GR_AF_IP6;
822827

823-
if (!nh->ifindex) {
828+
if (nh->type != NEXTHOP_TYPE_BLACKHOLE && !nh->ifindex) {
824829
gr_log_err("impossible to add/del nexthop in grout that does not have an ifindex");
825830
return ZEBRA_DPLANE_REQUEST_FAILURE;
831+
} else {
832+
gr_nh->iface_id = nh->ifindex;
826833
}
827-
gr_nh->iface_id = nh->ifindex;
828834

829835
switch (nh->type) {
830836
case NEXTHOP_TYPE_IPV4:
@@ -843,6 +849,9 @@ enum zebra_dplane_result grout_add_del_nexthop(struct zebra_dplane_ctx *ctx) {
843849
gr_nh->af = GR_AF_UNSPEC;
844850
gr_log_debug("add nexthop id %u with ifindex %u", nh_id, gr_nh->iface_id);
845851
break;
852+
case NEXTHOP_TYPE_BLACKHOLE:
853+
gr_nh->type = GR_NH_T_BLACKHOLE;
854+
break;
846855
default:
847856
gr_log_err("impossible to add nexthop %u (type %u not supported)", nh_id, nh->type);
848857
return ZEBRA_DPLANE_REQUEST_FAILURE;

0 commit comments

Comments
 (0)