diff options
Diffstat (limited to 'zebra/zebra_dplane.c')
| -rw-r--r-- | zebra/zebra_dplane.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index d1b28227c3..6fc62147c8 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -1344,10 +1344,6 @@ dplane_route_update_internal(struct route_node *rn, /* Obtain context block */ ctx = dplane_ctx_alloc(); - if (ctx == NULL) { - ret = ENOMEM; - goto done; - } /* Init context with info from zebra data structs */ ret = dplane_ctx_route_init(ctx, op, rn, re); @@ -1382,7 +1378,6 @@ dplane_route_update_internal(struct route_node *rn, ret = dplane_route_enqueue(ctx); } -done: /* Update counter */ atomic_fetch_add_explicit(&zdplane_info.dg_routes_in, 1, memory_order_relaxed); @@ -1562,10 +1557,6 @@ static enum zebra_dplane_result lsp_update_internal(zebra_lsp_t *lsp, /* Obtain context block */ ctx = dplane_ctx_alloc(); - if (ctx == NULL) { - ret = ENOMEM; - goto done; - } ret = dplane_ctx_lsp_init(ctx, op, lsp); if (ret != AOK) @@ -1583,8 +1574,7 @@ done: else { atomic_fetch_add_explicit(&zdplane_info.dg_lsp_errors, 1, memory_order_relaxed); - if (ctx) - dplane_ctx_free(&ctx); + dplane_ctx_free(&ctx); } return result; @@ -1601,10 +1591,6 @@ static enum zebra_dplane_result pw_update_internal(struct zebra_pw *pw, struct zebra_dplane_ctx *ctx = NULL; ctx = dplane_ctx_alloc(); - if (ctx == NULL) { - ret = ENOMEM; - goto done; - } ret = dplane_ctx_pw_init(ctx, op, pw); if (ret != AOK) @@ -1622,8 +1608,7 @@ done: else { atomic_fetch_add_explicit(&zdplane_info.dg_pw_errors, 1, memory_order_relaxed); - if (ctx) - dplane_ctx_free(&ctx); + dplane_ctx_free(&ctx); } return result; @@ -1691,10 +1676,6 @@ static enum zebra_dplane_result intf_addr_update_internal( } ctx = dplane_ctx_alloc(); - if (ctx == NULL) { - ret = ENOMEM; - goto done; - } ctx->zd_op = op; ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS; @@ -1706,7 +1687,7 @@ static enum zebra_dplane_result intf_addr_update_internal( /* Init the interface-addr-specific area */ memset(&ctx->u.intf, 0, sizeof(ctx->u.intf)); - strncpy(ctx->u.intf.ifname, ifp->name, sizeof(ctx->u.intf.ifname)); + strlcpy(ctx->u.intf.ifname, ifp->name, sizeof(ctx->u.intf.ifname)); ctx->u.intf.ifindex = ifp->ifindex; ctx->u.intf.prefix = *(ifc->address); @@ -1734,7 +1715,7 @@ static enum zebra_dplane_result intf_addr_update_internal( len = strlen(ifc->label); if (len < sizeof(ctx->u.intf.label_buf)) { - strncpy(ctx->u.intf.label_buf, ifc->label, + strlcpy(ctx->u.intf.label_buf, ifc->label, sizeof(ctx->u.intf.label_buf)); ctx->u.intf.label = ctx->u.intf.label_buf; } else { @@ -1744,8 +1725,6 @@ static enum zebra_dplane_result intf_addr_update_internal( ret = dplane_route_enqueue(ctx); -done: - /* Increment counter */ atomic_fetch_add_explicit(&zdplane_info.dg_intf_addrs_in, 1, memory_order_relaxed); @@ -1756,8 +1735,7 @@ done: /* Error counter */ atomic_fetch_add_explicit(&zdplane_info.dg_intf_addr_errors, 1, memory_order_relaxed); - if (ctx) - dplane_ctx_free(&ctx); + dplane_ctx_free(&ctx); } return result; |
