Skip to content

Commit 0a5ceb7

Browse files
committed
[FRR]: Bring FPM changes from FRR mainline
Bring the following change from FRR mainline and apply to dplane_fpm_sonic: - zebra: change fpm_read to batch the messages (FRRouting@7e8c18d) Signed-off-by: Yuqing Zhao <[email protected]>
1 parent ba5bb5a commit 0a5ceb7

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/sonic-frr/dplane_fpm_sonic/dplane_fpm_sonic.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,10 @@ static void fpm_read(struct event *t)
699699
size_t available_bytes;
700700
size_t hdr_available_bytes;
701701
int ival;
702+
struct dplane_ctx_list_head batch_list;
703+
704+
/* Initialize the batch list */
705+
dplane_ctx_q_init(&batch_list);
702706

703707
/* Let's ignore the input at the moment. */
704708
rv = stream_read_try(fnc->ibuf, fnc->socket,
@@ -739,7 +743,7 @@ static void fpm_read(struct event *t)
739743
while (available_bytes) {
740744
if (available_bytes < (ssize_t)FPM_MSG_HDR_LEN) {
741745
stream_pulldown(fnc->ibuf);
742-
return;
746+
goto send_batch;
743747
}
744748

745749
fpm.version = stream_getc(fnc->ibuf);
@@ -754,7 +758,7 @@ static void fpm_read(struct event *t)
754758
__func__, fpm.version, fpm.msg_type);
755759

756760
FPM_RECONNECT(fnc);
757-
return;
761+
goto send_batch;
758762
}
759763

760764
/*
@@ -766,7 +770,7 @@ static void fpm_read(struct event *t)
766770
"%s: Received message length: %u that does not even fill the FPM header",
767771
__func__, fpm.msg_len);
768772
FPM_RECONNECT(fnc);
769-
return;
773+
goto send_batch;
770774
}
771775

772776
/*
@@ -777,7 +781,7 @@ static void fpm_read(struct event *t)
777781
if (fpm.msg_len > available_bytes) {
778782
stream_rewind_getp(fnc->ibuf, FPM_MSG_HDR_LEN);
779783
stream_pulldown(fnc->ibuf);
780-
return;
784+
goto send_batch;
781785
}
782786

783787
available_bytes -= FPM_MSG_HDR_LEN;
@@ -827,8 +831,9 @@ static void fpm_read(struct event *t)
827831
break;
828832
}
829833

830-
/* Parse the route data into a dplane ctx, then
831-
* enqueue it to zebra for processing.
834+
/*
835+
* Parse the route data into a dplane ctx, add to ctx list
836+
* and enqueue the batch of ctx to zebra for processing.
832837
*/
833838
ctx = dplane_ctx_alloc();
834839
dplane_ctx_route_init(ctx, DPLANE_OP_ROUTE_NOTIFY, NULL,
@@ -840,8 +845,9 @@ static void fpm_read(struct event *t)
840845
dplane_ctx_set_vrf(ctx, ival);
841846
dplane_ctx_set_table(ctx,
842847
ZEBRA_ROUTE_TABLE_UNKNOWN);
843-
844-
dplane_provider_enqueue_to_zebra(ctx);
848+
849+
/* Add to the list for batching */
850+
dplane_ctx_enqueue_tail(&batch_list, ctx);
845851
} else {
846852
/*
847853
* Let's continue to read other messages
@@ -861,6 +867,15 @@ static void fpm_read(struct event *t)
861867
}
862868

863869
stream_reset(fnc->ibuf);
870+
871+
send_batch:
872+
/* Send all contexts to zebra in a single batch if we have any */
873+
if (dplane_ctx_queue_count(&batch_list) > 0) {
874+
if (IS_ZEBRA_DEBUG_FPM)
875+
zlog_debug("%s: Sending batch of %u contexts to zebra", __func__,
876+
dplane_ctx_queue_count(&batch_list));
877+
dplane_provider_enqueue_ctx_list_to_zebra(&batch_list);
878+
}
864879
}
865880

866881
static void fpm_write(struct event *t)

0 commit comments

Comments
 (0)