Merge pull request #13953 from FRRouting/mergify/bp/dev/9.0/pr-13757

zebra: Fix crash when `dplane_fpm_nl` fails to process received routes (backport #13757)
This commit is contained in:
Donatas Abraitis 2023-07-08 09:50:35 +03:00 committed by GitHub
commit 28fbd32026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -587,7 +587,8 @@ static void fpm_read(struct event *t)
switch (hdr->nlmsg_type) {
case RTM_NEWROUTE:
ctx = dplane_ctx_alloc();
dplane_ctx_set_op(ctx, DPLANE_OP_ROUTE_NOTIFY);
dplane_ctx_route_init(ctx, DPLANE_OP_ROUTE_NOTIFY, NULL,
NULL);
if (netlink_route_change_read_unicast_internal(
hdr, 0, false, ctx) != 1) {
dplane_ctx_fini(&ctx);

View File

@ -2798,7 +2798,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);
@ -2806,6 +2806,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;
@ -2837,6 +2844,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)
@ -2853,9 +2862,17 @@ 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