From 8d78e148b852ee31399d9a66af948cf604016ebe Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 28 Oct 2021 10:35:51 -0400 Subject: [PATCH] zebra: return void for dplane_ctx_get_pbr_iptable The only time this function ever failed is when the developer does not pass in a usable pointer to place the data in. Change it to an assert to signify to the end developer that is what we want and then remove all the if checks for failure Signed-off-by: Donald Sharp --- zebra/zapi_msg.c | 3 +-- zebra/zebra_dplane.c | 13 ++++++------- zebra/zebra_dplane.h | 5 ++--- zebra/zebra_pbr.c | 13 ++++++------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 7cf248d08c..5bacf1f40a 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -871,8 +871,7 @@ void zsend_iptable_notify_owner(const struct zebra_dplane_ctx *ctx, struct zebra_pbr_iptable ipt; uint16_t cmd = ZEBRA_IPTABLE_NOTIFY_OWNER; - if (!dplane_ctx_get_pbr_iptable(ctx, &ipt)) - return; + dplane_ctx_get_pbr_iptable(ctx, &ipt); if (IS_ZEBRA_DEBUG_PACKET) zlog_debug("%s: Notifying %s id %u note %u", __func__, diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 9c17ab6892..d02d0178cc 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -2145,14 +2145,12 @@ dplane_ctx_get_br_port_backup_nhg_id(const struct zebra_dplane_ctx *ctx) } /* Accessors for PBR iptable information */ -bool -dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, - struct zebra_pbr_iptable *table) +void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, + struct zebra_pbr_iptable *table) { DPLANE_CTX_VALID(ctx); memcpy(table, &ctx->u.iptable, sizeof(struct zebra_pbr_iptable)); - return true; } void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx, @@ -5059,9 +5057,10 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx) case DPLANE_OP_IPTABLE_DELETE: { struct zebra_pbr_iptable ipt; - if (dplane_ctx_get_pbr_iptable(ctx, &ipt)) - zlog_debug("Dplane iptable update op %s, unique(%u), ctx %p", - dplane_op2str(dplane_ctx_get_op(ctx)), ipt.unique, ctx); + dplane_ctx_get_pbr_iptable(ctx, &ipt); + zlog_debug("Dplane iptable update op %s, unique(%u), ctx %p", + dplane_op2str(dplane_ctx_get_op(ctx)), ipt.unique, + ctx); } break; case DPLANE_OP_IPSET_ADD: case DPLANE_OP_IPSET_DELETE: { diff --git a/zebra/zebra_dplane.h b/zebra/zebra_dplane.h index d3a232c9da..ea408116ee 100644 --- a/zebra/zebra_dplane.h +++ b/zebra/zebra_dplane.h @@ -526,9 +526,8 @@ const struct prefix * dplane_ctx_rule_get_old_dst_ip(const struct zebra_dplane_ctx *ctx); /* Accessors for policy based routing iptable information */ struct zebra_pbr_iptable; -bool -dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, - struct zebra_pbr_iptable *table); +void dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx, + struct zebra_pbr_iptable *table); struct zebra_pbr_ipset; void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx, struct zebra_pbr_ipset *ipset); diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index b0d274e7c1..8b98cdc688 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -552,13 +552,12 @@ void zebra_pbr_process_iptable(struct zebra_dplane_ctx *ctx) else mode = 0; - if (dplane_ctx_get_pbr_iptable(ctx, &ipt)) { - ret = hook_call(zebra_pbr_iptable_update, mode, &ipt); - if (ret) - dplane_ctx_set_status(ctx, - ZEBRA_DPLANE_REQUEST_SUCCESS); - } - if (!ret) + dplane_ctx_get_pbr_iptable(ctx, &ipt); + + ret = hook_call(zebra_pbr_iptable_update, mode, &ipt); + if (ret) + dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS); + else dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE); }