]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: dplane_ctx_get_pbr_ipset should return void
authorDonald Sharp <sharpd@nvidia.com>
Thu, 28 Oct 2021 13:15:44 +0000 (09:15 -0400)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 17 Nov 2021 12:46:36 +0000 (07:46 -0500)
The function call dplane_ctx_get_pbr_ipset only
returns false when the calling function fails to
pass in a valid ipset pointer.  This should
be an assertion issue since it's a programming
issue as opposed to an actual run time issue.

Change the function call parameter to not return
a bool on success/fail for a compile time decision.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
zebra/zapi_msg.c
zebra/zebra_dplane.c
zebra/zebra_dplane.h
zebra/zebra_pbr.c

index 85721d7d7052a5f0ddeff04f334bf926d4fa4bc4..7cf248d08c6f735812a4f4571e966c3c8bb5c138 100644 (file)
@@ -906,8 +906,7 @@ void zsend_ipset_notify_owner(const struct zebra_dplane_ctx *ctx,
        struct zebra_pbr_ipset ipset;
        uint16_t cmd = ZEBRA_IPSET_NOTIFY_OWNER;
 
-       if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
-               return;
+       dplane_ctx_get_pbr_ipset(ctx, &ipset);
 
        if (IS_ZEBRA_DEBUG_PACKET)
                zlog_debug("%s: Notifying %s id %u note %u", __func__,
@@ -944,8 +943,7 @@ void zsend_ipset_entry_notify_owner(const struct zebra_dplane_ctx *ctx,
 
        if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipent))
                return;
-       if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
-               return;
+       dplane_ctx_get_pbr_ipset(ctx, &ipset);
 
        if (IS_ZEBRA_DEBUG_PACKET)
                zlog_debug("%s: Notifying %s id %u note %u", __func__,
index 3d258e082932299543271528cc43bef6d43a810e..9c17ab6892c834dec3485a13b277ffa3d02786f8 100644 (file)
@@ -2155,13 +2155,13 @@ dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
        return true;
 }
 
-bool dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
+void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
                              struct zebra_pbr_ipset *ipset)
 {
        DPLANE_CTX_VALID(ctx);
 
-       if (!ipset)
-               return false;
+       assert(ipset);
+
        if (ctx->zd_op == DPLANE_OP_IPSET_ENTRY_ADD ||
            ctx->zd_op == DPLANE_OP_IPSET_ENTRY_DELETE) {
                memset(ipset, 0, sizeof(struct zebra_pbr_ipset));
@@ -2171,7 +2171,6 @@ bool dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
                       ZEBRA_IPSET_NAME_SIZE);
        } else
                memcpy(ipset, &ctx->u.ipset, sizeof(struct zebra_pbr_ipset));
-       return true;
 }
 
 bool dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
@@ -5068,10 +5067,10 @@ static void kernel_dplane_log_detail(struct zebra_dplane_ctx *ctx)
        case DPLANE_OP_IPSET_DELETE: {
                struct zebra_pbr_ipset ipset;
 
-               if (dplane_ctx_get_pbr_ipset(ctx, &ipset))
-                       zlog_debug("Dplane ipset update op %s, unique(%u), ctx %p",
-                                  dplane_op2str(dplane_ctx_get_op(ctx)),
-                                  ipset.unique, ctx);
+               dplane_ctx_get_pbr_ipset(ctx, &ipset);
+               zlog_debug("Dplane ipset update op %s, unique(%u), ctx %p",
+                          dplane_op2str(dplane_ctx_get_op(ctx)), ipset.unique,
+                          ctx);
        } break;
        case DPLANE_OP_IPSET_ENTRY_ADD:
        case DPLANE_OP_IPSET_ENTRY_DELETE: {
index a23de61c80acec7a10ce3aa49a47113999ec0479..d3a232c9da3b16b53c46d5d9e8aa51d8fe4cd76a 100644 (file)
@@ -530,9 +530,8 @@ bool
 dplane_ctx_get_pbr_iptable(const struct zebra_dplane_ctx *ctx,
                           struct zebra_pbr_iptable *table);
 struct zebra_pbr_ipset;
-bool
-dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
-                        struct zebra_pbr_ipset *ipset);
+void dplane_ctx_get_pbr_ipset(const struct zebra_dplane_ctx *ctx,
+                             struct zebra_pbr_ipset *ipset);
 struct zebra_pbr_ipset_entry;
 bool
 dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx,
index 3607110aa26f35dd1e54e88aca8267ab3b6568f2..b0d274e7c170c644e4dc1ca66b0998fe8f546697 100644 (file)
@@ -571,13 +571,13 @@ void zebra_pbr_process_ipset(struct zebra_dplane_ctx *ctx)
                mode = 1;
        else
                mode = 0;
-       if (dplane_ctx_get_pbr_ipset(ctx, &ipset)) {
-               ret = hook_call(zebra_pbr_ipset_update, mode, &ipset);
-               if (ret)
-                       dplane_ctx_set_status(ctx,
-                                             ZEBRA_DPLANE_REQUEST_SUCCESS);
-       }
-       if (!ret)
+
+       dplane_ctx_get_pbr_ipset(ctx, &ipset);
+
+       ret = hook_call(zebra_pbr_ipset_update, mode, &ipset);
+       if (ret)
+               dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_SUCCESS);
+       else
                dplane_ctx_set_status(ctx, ZEBRA_DPLANE_REQUEST_FAILURE);
 }
 
@@ -594,8 +594,8 @@ void zebra_pbr_process_ipset_entry(struct zebra_dplane_ctx *ctx)
 
        if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipset_entry))
                return;
-       if (!dplane_ctx_get_pbr_ipset(ctx, &ipset))
-               return;
+       dplane_ctx_get_pbr_ipset(ctx, &ipset);
+
        ipset_entry.backpointer = &ipset;
 
        ret = hook_call(zebra_pbr_ipset_entry_update, mode, &ipset_entry);