diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 85721d7d70..54ab0afd5c 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__, @@ -906,8 +905,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__, @@ -942,10 +940,8 @@ void zsend_ipset_entry_notify_owner(const struct zebra_dplane_ctx *ctx, struct zebra_pbr_ipset ipset; uint16_t cmd = ZEBRA_IPSET_ENTRY_NOTIFY_OWNER; - if (!dplane_ctx_get_pbr_ipset_entry(ctx, &ipent)) - return; - if (!dplane_ctx_get_pbr_ipset(ctx, &ipset)) - return; + dplane_ctx_get_pbr_ipset_entry(ctx, &ipent); + dplane_ctx_get_pbr_ipset(ctx, &ipset); 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 3d258e0829..20aa9b8432 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -2145,23 +2145,21 @@ 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; } -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,18 +2169,16 @@ 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, +void dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx, struct zebra_pbr_ipset_entry *entry) { DPLANE_CTX_VALID(ctx); - if (!entry) - return false; + assert(entry); + memcpy(entry, &ctx->u.ipset_entry.entry, sizeof(struct zebra_pbr_ipset_entry)); - return true; } /* @@ -5060,29 +5056,30 @@ 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: { 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: { struct zebra_pbr_ipset_entry ipent; - if (dplane_ctx_get_pbr_ipset_entry(ctx, &ipent)) - zlog_debug("Dplane ipset entry update op %s, unique(%u), ctx %p", - dplane_op2str(dplane_ctx_get_op(ctx)), - ipent.unique, ctx); + dplane_ctx_get_pbr_ipset_entry(ctx, &ipent); + zlog_debug( + "Dplane ipset entry update op %s, unique(%u), ctx %p", + dplane_op2str(dplane_ctx_get_op(ctx)), ipent.unique, + ctx); } break; - case DPLANE_OP_NEIGH_TABLE_UPDATE: zlog_debug("Dplane neigh table op %s, ifp %s, family %s", dplane_op2str(dplane_ctx_get_op(ctx)), diff --git a/zebra/zebra_dplane.h b/zebra/zebra_dplane.h index a23de61c80..977f00bd2a 100644 --- a/zebra/zebra_dplane.h +++ b/zebra/zebra_dplane.h @@ -526,17 +526,14 @@ 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; -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, - struct zebra_pbr_ipset_entry *entry); +void dplane_ctx_get_pbr_ipset_entry(const struct zebra_dplane_ctx *ctx, + struct zebra_pbr_ipset_entry *entry); /* Accessors for bridge port information */ uint32_t dplane_ctx_get_br_port_flags(const struct zebra_dplane_ctx *ctx); uint32_t diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index 3607110aa2..e66d7aaf5c 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); } @@ -571,13 +570,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); } @@ -592,10 +591,9 @@ void zebra_pbr_process_ipset_entry(struct zebra_dplane_ctx *ctx) else mode = 0; - 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_entry(ctx, &ipset_entry); + dplane_ctx_get_pbr_ipset(ctx, &ipset); + ipset_entry.backpointer = &ipset; ret = hook_call(zebra_pbr_ipset_entry_update, mode, &ipset_entry);