Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: avoid race between FPM pthread and zebra main pthread in netlink encode/decode #17581

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions zebra/dplane_fpm_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ static void fpm_read(struct event *t)
struct zebra_dplane_ctx *ctx;
size_t available_bytes;
size_t hdr_available_bytes;
int ival;

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

/* Parse the route data into a dplane ctx, then
* enqueue it to zebra for processing.
*/
ctx = dplane_ctx_alloc();
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);
stream_pulldown(fnc->ibuf);

if (netlink_route_notify_read_ctx(hdr, 0, ctx) >= 0) {
/* In the FPM encoding, the vrfid is present */
ival = dplane_ctx_get_table(ctx);
dplane_ctx_set_vrf(ctx, ival);
dplane_ctx_set_table(ctx,
ZEBRA_ROUTE_TABLE_UNKNOWN);

dplane_provider_enqueue_to_zebra(ctx);
} else {
/*
* Let's continue to read other messages
* Even if we ignore this one.
*/
dplane_ctx_fini(&ctx);
stream_pulldown(fnc->ibuf);
}
break;
default:
Expand Down
Loading
Loading