Skip to content

Commit

Permalink
Merge pull request #16539 from donaldsharp/tests_memory_shut
Browse files Browse the repository at this point in the history
Tests memory shut
  • Loading branch information
ton31337 authored Aug 9, 2024
2 parents 536d478 + 208c53c commit 927be7a
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 7 deletions.
4 changes: 2 additions & 2 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ void isis_circuit_del(struct isis_circuit *circuit)
ldp_sync_info_free(&circuit->ldp_sync_info);

circuit_mt_finish(circuit);
isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL1);
isis_lfa_excluded_ifaces_clear(circuit, ISIS_LEVEL2);
isis_lfa_excluded_ifaces_delete(circuit, ISIS_LEVEL1);
isis_lfa_excluded_ifaces_delete(circuit, ISIS_LEVEL2);

list_delete(&circuit->ip_addrs);
list_delete(&circuit->ipv6_link);
Expand Down
6 changes: 3 additions & 3 deletions isisd/isis_lfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level)
*
* @param nodes List of SPF nodes
*/
void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level)
void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level)
{
hash_clean(circuit->lfa_excluded_ifaces[level - 1],
lfa_excl_interface_hash_free);
hash_clean_and_free(&circuit->lfa_excluded_ifaces[level - 1],
lfa_excl_interface_hash_free);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_lfa.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct lfa_tiebreaker *isis_lfa_tiebreaker_add(struct isis_area *area,
void isis_lfa_tiebreaker_delete(struct isis_area *area, int level,
struct lfa_tiebreaker *tie_b);
void isis_lfa_excluded_ifaces_init(struct isis_circuit *circuit, int level);
void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level);
void isis_lfa_excluded_ifaces_delete(struct isis_circuit *circuit, int level);
void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level,
const char *ifname);
void isis_lfa_excluded_iface_delete(struct isis_circuit *circuit, int level,
Expand Down
6 changes: 6 additions & 0 deletions isisd/isis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ static __attribute__((__noreturn__)) void terminate(int i)
isis_sr_term();
isis_srv6_term();
isis_zebra_stop();

isis_master_terminate();
route_map_finish();
vrf_terminate();

frr_fini();
exit(i);
}

Expand Down
8 changes: 8 additions & 0 deletions isisd/isis_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,13 @@ static int isis_snmp_init(struct event_loop *tm)
return 0;
}

static int isis_snmp_terminate(void)
{
smux_terminate();

return 0;
}

/*
* ISIS notification functions: we have one function per notification
*/
Expand Down Expand Up @@ -3448,6 +3455,7 @@ static int isis_snmp_module_init(void)
hook_register(isis_circuit_del_hook, isis_circuit_snmp_id_free);

hook_register(frr_late_init, isis_snmp_init);
hook_register(frr_fini, isis_snmp_terminate);
return 0;
}

Expand Down
1 change: 0 additions & 1 deletion isisd/isis_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1628,5 +1628,4 @@ void isis_zebra_stop(void)
zclient_free(zclient_sync);
zclient_stop(zclient);
zclient_free(zclient);
frr_fini();
}
5 changes: 5 additions & 0 deletions isisd/isisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ void isis_master_init(struct event_loop *master)
im->master = master;
}

void isis_master_terminate(void)
{
list_delete(&im->isis);
}

struct isis *isis_new(const char *vrf_name)
{
struct vrf *vrf;
Expand Down
1 change: 1 addition & 0 deletions isisd/isisd.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ DECLARE_HOOK(isis_area_overload_bit_update, (struct isis_area * area), (area));

void isis_terminate(void);
void isis_master_init(struct event_loop *master);
void isis_master_terminate(void);
void isis_vrf_link(struct isis *isis, struct vrf *vrf);
void isis_vrf_unlink(struct isis *isis, struct vrf *vrf);
struct isis *isis_lookup_by_vrfid(vrf_id_t vrf_id);
Expand Down
5 changes: 5 additions & 0 deletions lib/agentx.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,9 @@ void smux_events_update(void)
agentx_events_update();
}

void smux_terminate(void)
{
if (events)
list_delete(&events);
}
#endif /* SNMP_AGENTX */
2 changes: 2 additions & 0 deletions lib/libfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,8 @@ void frr_fini(void)
/* frrmod_init -> nothing needed / hooks */
rcu_shutdown();

frrmod_terminate();

/* also log memstats to stderr when stderr goes to a file*/
if (debug_memstats_at_exit || !isatty(STDERR_FILENO))
have_leftovers = log_memstats(stderr, di->name);
Expand Down
12 changes: 12 additions & 0 deletions lib/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,15 @@ void frrmod_unload(struct frrmod_runtime *module)
{
}
#endif

void frrmod_terminate(void)
{
struct frrmod_runtime *rtinfo = frrmod_list;

while (rtinfo) {
XFREE(MTYPE_MODULE_LOADNAME, rtinfo->load_name);
XFREE(MTYPE_MODULE_LOADARGS, rtinfo->load_args);

rtinfo = rtinfo->next;
}
}
1 change: 1 addition & 0 deletions lib/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extern union _frrmod_runtime_u _frrmod_this_module;
extern struct frrmod_runtime *frrmod_list;

extern void frrmod_init(struct frrmod_runtime *modinfo);
extern void frrmod_terminate(void);
extern struct frrmod_runtime *frrmod_load(const char *spec, const char *dir,
void (*pFerrlog)(const void *,
const char *),
Expand Down
1 change: 1 addition & 0 deletions lib/smux.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern bool smux_enabled(void);

extern void libagentx_init(void);
extern void smux_init(struct event_loop *tm);
extern void smux_terminate(void);
extern void smux_agentx_enable(void);
extern void smux_register_mib(const char *, struct variable *, size_t, int,
oid[], size_t);
Expand Down
9 changes: 9 additions & 0 deletions sharpd/sharp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ static void sharp_global_init(void)
sg.srv6_locators = list_new();
}

static void sharp_srv6_locators_list_delete(void *item)
{
struct sharp_srv6_locator *loc = item;

list_delete(&loc->chunks);
}

static void sharp_global_destroy(void)
{
list_delete(&sg.nhs);

sg.srv6_locators->del = sharp_srv6_locators_list_delete;
list_delete(&sg.srv6_locators);
}

Expand Down

0 comments on commit 927be7a

Please sign in to comment.