From 0fa9ee396b06028eaf611e9ab892cf033d00f558 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 8 Feb 2024 11:30:30 -0500 Subject: [PATCH] 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 --- zebra/zebra_nhg.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 1c6bfc970f..6ae39fdde4 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -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; } } }