zebra: Use switch when handling return from dplane for nhgs

Convert the dplane results function for nhg's over to
using a switch for the result enum.  Let's specifically
call out the unexpected state and also set the nexthop
group as not installed when installation fails.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-02-08 11:30:30 -05:00
parent 8f76afd044
commit 0fa9ee396b

View File

@ -3174,7 +3174,8 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
}
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_QUEUED);
if (status == ZEBRA_DPLANE_REQUEST_SUCCESS) {
switch (status) {
case ZEBRA_DPLANE_REQUEST_SUCCESS:
SET_FLAG(nhe->flags, NEXTHOP_GROUP_VALID);
SET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
zebra_nhg_handle_install(nhe, true);
@ -3184,7 +3185,9 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
zsend_nhg_notify(nhe->type, nhe->zapi_instance,
nhe->zapi_session, nhe->id,
ZAPI_NHG_INSTALLED);
} else {
break;
case ZEBRA_DPLANE_REQUEST_FAILURE:
UNSET_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED);
/* If daemon nhg, send it an update */
if (PROTO_OWNED(nhe))
zsend_nhg_notify(nhe->type, nhe->zapi_instance,
@ -3197,6 +3200,12 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
EC_ZEBRA_DP_INSTALL_FAIL,
"Failed to install Nexthop (%pNG) into the kernel",
nhe);
break;
case ZEBRA_DPLANE_REQUEST_QUEUED:
flog_err(EC_ZEBRA_DP_INVALID_RC,
"Dplane returned an invalid result code for a result from the dplane for %pNG into the kernel",
nhe);
break;
}
}
}