Skip to content

Commit 67da971

Browse files
authored
Merge pull request #17581 from mjstapp/fix_fpm_netlink
zebra: avoid race between FPM pthread and zebra main pthread in netlink encode/decode
2 parents a6595fd + 9af5425 commit 67da971

8 files changed

+507
-159
lines changed

zebra/dplane_fpm_nl.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ static void fpm_read(struct event *t)
587587
struct zebra_dplane_ctx *ctx;
588588
size_t available_bytes;
589589
size_t hdr_available_bytes;
590+
int ival;
590591

591592
/* Let's ignore the input at the moment. */
592593
rv = stream_read_try(fnc->ibuf, fnc->socket,
@@ -715,17 +716,28 @@ static void fpm_read(struct event *t)
715716
break;
716717
}
717718

719+
/* Parse the route data into a dplane ctx, then
720+
* enqueue it to zebra for processing.
721+
*/
718722
ctx = dplane_ctx_alloc();
719723
dplane_ctx_route_init(ctx, DPLANE_OP_ROUTE_NOTIFY, NULL,
720724
NULL);
721-
if (netlink_route_change_read_unicast_internal(
722-
hdr, 0, false, ctx) != 1) {
723-
dplane_ctx_fini(&ctx);
724-
stream_pulldown(fnc->ibuf);
725+
726+
if (netlink_route_notify_read_ctx(hdr, 0, ctx) >= 0) {
727+
/* In the FPM encoding, the vrfid is present */
728+
ival = dplane_ctx_get_table(ctx);
729+
dplane_ctx_set_vrf(ctx, ival);
730+
dplane_ctx_set_table(ctx,
731+
ZEBRA_ROUTE_TABLE_UNKNOWN);
732+
733+
dplane_provider_enqueue_to_zebra(ctx);
734+
} else {
725735
/*
726736
* Let's continue to read other messages
727737
* Even if we ignore this one.
728738
*/
739+
dplane_ctx_fini(&ctx);
740+
stream_pulldown(fnc->ibuf);
729741
}
730742
break;
731743
default:

0 commit comments

Comments
 (0)