Skip to content

Commit 20504c9

Browse files
donaldsharpton31337
authored andcommitted
zebra: Cleanup ctx leak on shutdown and turn off event
two things: On shutdown cleanup any events associated with the update walker. Also do not allow new events to be created. Fixes this mem-leak: ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790:Direct leak of 8 byte(s) in 1 object(s) allocated from: ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- #0 0x7f0dd0b08037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#1 0x7f0dd06c19f9 in qcalloc lib/memory.c:105 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#2 0x55b42fb605bc in rib_update_ctx_init zebra/zebra_rib.c:4383 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#3 0x55b42fb6088f in rib_update zebra/zebra_rib.c:4421 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#4 0x55b42fa00344 in netlink_link_change zebra/if_netlink.c:2221 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#5 0x55b42fa24622 in netlink_information_fetch zebra/kernel_netlink.c:399 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#6 0x55b42fa28c02 in netlink_parse_info zebra/kernel_netlink.c:1183 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#7 0x55b42fa24951 in kernel_read zebra/kernel_netlink.c:493 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#8 0x7f0dd0797f0c in event_call lib/event.c:1995 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#9 0x7f0dd0684fd9 in frr_run lib/libfrr.c:1185 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#10 0x55b42fa30caa in main zebra/main.c:465 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- sonic-net#11 0x7f0dd01b5d09 in __libc_start_main ../csu/libc-start.c:308 ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790- ./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s). Signed-off-by: Donald Sharp <[email protected]> (cherry picked from commit 3cd0acc) Signed-off-by: Donatas Abraitis <[email protected]>
1 parent 4661804 commit 20504c9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

zebra/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ static void sigint(void)
204204
*/
205205
zebra_routemap_finish();
206206

207+
rib_update_finish();
208+
207209
list_delete(&zrouter.client_list);
208210

209211
/* Indicate that all new dplane work has been enqueued. When that

zebra/rib.h

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ enum rib_update_event {
338338
RIB_UPDATE_OTHER,
339339
RIB_UPDATE_MAX
340340
};
341+
void rib_update_finish(void);
341342

342343
int route_entry_update_nhe(struct route_entry *re,
343344
struct nhg_hash_entry *new_nhghe);

zebra/zebra_rib.c

+19
Original file line numberDiff line numberDiff line change
@@ -4393,6 +4393,22 @@ static void rib_update_handler(struct thread *thread)
43934393
*/
43944394
static struct thread *t_rib_update_threads[RIB_UPDATE_MAX];
43954395

4396+
void rib_update_finish(void)
4397+
{
4398+
int i;
4399+
4400+
for (i = RIB_UPDATE_KERNEL; i < RIB_UPDATE_MAX; i++) {
4401+
if (thread_is_scheduled(t_rib_update_threads[i])) {
4402+
struct rib_update_ctx *ctx;
4403+
4404+
ctx = THREAD_ARG(t_rib_update_threads[i]);
4405+
4406+
rib_update_ctx_fini(&ctx);
4407+
THREAD_OFF(t_rib_update_threads[i]);
4408+
}
4409+
}
4410+
}
4411+
43964412
/* Schedule a RIB update event for all vrfs */
43974413
void rib_update(enum rib_update_event event)
43984414
{
@@ -4401,6 +4417,9 @@ void rib_update(enum rib_update_event event)
44014417
if (thread_is_scheduled(t_rib_update_threads[event]))
44024418
return;
44034419

4420+
if (zebra_router_in_shutdown())
4421+
return;
4422+
44044423
ctx = rib_update_ctx_init(0, event);
44054424

44064425
thread_add_event(zrouter.master, rib_update_handler, ctx, 0,

0 commit comments

Comments
 (0)