summaryrefslogtreecommitdiff
path: root/zebra/zebra_dplane.c
diff options
context:
space:
mode:
authorMark Stapp <mjs.ietf@gmail.com>2023-07-07 12:15:31 -0400
committerGitHub <noreply@github.com>2023-07-07 12:15:31 -0400
commit2332ca1d1b8c6cf46da7375f51a109a52e4fd30d (patch)
tree756bb37b1f2e386b93c1be15b1deec5ccd8f7fe1 /zebra/zebra_dplane.c
parent700ef0dd20edcf97123b29eb65980f6d84b9ceba (diff)
parent7f2dec4f090500c65f54fb7ce3c2bab22eef5474 (diff)
Merge pull request #13757 from cscarpitta/bugfix/fix-fpm-read-crash
zebra: Fix crash when `dplane_fpm_nl` fails to process received routes
Diffstat (limited to 'zebra/zebra_dplane.c')
-rw-r--r--zebra/zebra_dplane.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 6dd1a9c18d..6a685267a9 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -3257,7 +3257,7 @@ int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
{
int ret = EINVAL;
- if (!ctx || !re)
+ if (!ctx)
return ret;
dplane_intf_extra_list_init(&ctx->u.rinfo.intf_extra_list);
@@ -3265,6 +3265,13 @@ int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
+ /* This function may be called to create/init a dplane context, not
+ * necessarily to copy a route object. Let's return if there is no route
+ * object to copy.
+ */
+ if (!re)
+ return AOK;
+
ctx->u.rinfo.zd_type = re->type;
ctx->u.rinfo.zd_old_type = re->type;
@@ -3296,6 +3303,8 @@ int dplane_ctx_route_init_basic(struct zebra_dplane_ctx *ctx,
/*
* Initialize a context block for a route update from zebra data structs.
+ * If the `rn` or `re` parameters are NULL, this function only initializes the
+ * dplane context without copying a route object into it.
*/
int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
struct route_node *rn, struct route_entry *re)
@@ -3312,10 +3321,18 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op,
const struct interface *ifp;
struct dplane_intf_extra *if_extra;
- if (!ctx || !rn || !re)
+ if (!ctx)
return ret;
/*
+ * Initialize the dplane context and return, if there is no route
+ * object to copy
+ */
+ if (!re || !rn)
+ return dplane_ctx_route_init_basic(ctx, op, NULL, NULL, NULL,
+ AFI_UNSPEC, SAFI_UNSPEC);
+
+ /*
* Let's grab the data from the route_node
* so that we can call a helper function
*/