Skip to content

Commit

Permalink
Merge pull request #13861 from opensourcerouting/fix/memory_leak_zserv
Browse files Browse the repository at this point in the history
zebra: Free Zebra client resources
  • Loading branch information
mjstapp authored Jun 28, 2023
2 parents 4d1f3d5 + 97072d1 commit 59b8965
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions zebra/zserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,30 +582,27 @@ static void zserv_client_free(struct zserv *client)

/* Close file descriptor. */
if (client->sock) {
unsigned long nroutes;
unsigned long nnhgs;
unsigned long nroutes = 0;
unsigned long nnhgs = 0;

close(client->sock);

/* If this is a synchronous BGP Zebra client for label/table
* manager, then ignore it. It's not GR-aware, and causes GR to
* be skipped for the session_id == 0 (asynchronous).
*/
if (client->proto == ZEBRA_ROUTE_BGP && client->session_id == 1)
return;

if (DYNAMIC_CLIENT_GR_DISABLED(client)) {
zebra_mpls_client_cleanup_vrf_label(client->proto);
if (!client->synchronous) {
zebra_mpls_client_cleanup_vrf_label(
client->proto);

nroutes = rib_score_proto(client->proto,
client->instance);
nroutes = rib_score_proto(client->proto,
client->instance);
}
zlog_notice(
"client %d disconnected %lu %s routes removed from the rib",
client->sock, nroutes,
zebra_route_string(client->proto));

/* Not worrying about instance for now */
nnhgs = zebra_nhg_score_proto(client->proto);
if (!client->synchronous)
nnhgs = zebra_nhg_score_proto(client->proto);
zlog_notice(
"client %d disconnected %lu %s nhgs removed from the rib",
client->sock, nnhgs,
Expand Down

0 comments on commit 59b8965

Please sign in to comment.