Skip to content

Commit 97072d1

Browse files
committed
zebra: Free Zebra client resources
Memory leaks started flowing: ``` AddressSanitizer Topotests Part 0: 15 KB -> 283 KB AddressSanitizer Topotests Part 1: 1 KB -> 495 KB AddressSanitizer Topotests Part 2: 13 KB -> 478 KB AddressSanitizer Topotests Part 3: 39 KB -> 213 KB AddressSanitizer Topotests Part 4: 30 KB -> 836 KB AddressSanitizer Topotests Part 5: 0 bytes -> 356 KB AddressSanitizer Topotests Part 6: 86 KB -> 783 KB AddressSanitizer Topotests Part 7: 0 bytes -> 354 KB AddressSanitizer Topotests Part 8: 0 bytes -> 62 KB AddressSanitizer Topotests Part 9: 408 KB -> 518 KB ``` ``` Direct leak of 3584 byte(s) in 1 object(s) allocated from: #0 0x7f1957b02d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) sonic-net#1 0x559895c55df0 in qcalloc lib/memory.c:105 sonic-net#2 0x559895bc1cdf in zserv_client_create zebra/zserv.c:743 sonic-net#3 0x559895bc1cdf in zserv_accept zebra/zserv.c:880 sonic-net#4 0x559895cf3438 in event_call lib/event.c:1995 sonic-net#5 0x559895c3901c in frr_run lib/libfrr.c:1213 sonic-net#6 0x559895a698f1 in main zebra/main.c:472 sonic-net#7 0x7f195635ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) ``` Fixes b20acd0 ("bgpd: Use synchronous way to get labels from Zebra") Signed-off-by: Donatas Abraitis <[email protected]>
1 parent 4262dc3 commit 97072d1

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

zebra/zserv.c

+10-13
Original file line numberDiff line numberDiff line change
@@ -582,30 +582,27 @@ static void zserv_client_free(struct zserv *client)
582582

583583
/* Close file descriptor. */
584584
if (client->sock) {
585-
unsigned long nroutes;
586-
unsigned long nnhgs;
585+
unsigned long nroutes = 0;
586+
unsigned long nnhgs = 0;
587587

588588
close(client->sock);
589589

590-
/* If this is a synchronous BGP Zebra client for label/table
591-
* manager, then ignore it. It's not GR-aware, and causes GR to
592-
* be skipped for the session_id == 0 (asynchronous).
593-
*/
594-
if (client->proto == ZEBRA_ROUTE_BGP && client->session_id == 1)
595-
return;
596-
597590
if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
598-
zebra_mpls_client_cleanup_vrf_label(client->proto);
591+
if (!client->synchronous) {
592+
zebra_mpls_client_cleanup_vrf_label(
593+
client->proto);
599594

600-
nroutes = rib_score_proto(client->proto,
601-
client->instance);
595+
nroutes = rib_score_proto(client->proto,
596+
client->instance);
597+
}
602598
zlog_notice(
603599
"client %d disconnected %lu %s routes removed from the rib",
604600
client->sock, nroutes,
605601
zebra_route_string(client->proto));
606602

607603
/* Not worrying about instance for now */
608-
nnhgs = zebra_nhg_score_proto(client->proto);
604+
if (!client->synchronous)
605+
nnhgs = zebra_nhg_score_proto(client->proto);
609606
zlog_notice(
610607
"client %d disconnected %lu %s nhgs removed from the rib",
611608
client->sock, nnhgs,

0 commit comments

Comments
 (0)