Skip to content

Commit

Permalink
Merge pull request #12119 from FRRouting/mergify/bp/dev/8.4/pr-12108
Browse files Browse the repository at this point in the history
General mayhem (backport #12108)
  • Loading branch information
ton31337 authored Oct 13, 2022
2 parents bbaf4e7 + f40e627 commit 2219391
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 9 deletions.
28 changes: 19 additions & 9 deletions lib/frrscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ static void *codec_alloc(void *arg)
return e;
}

#if 0
static void codec_free(struct codec *c)
static void codec_free(void *data)
{
XFREE(MTYPE_TMP, c->typename);
XFREE(MTYPE_TMP, c);
struct frrscript_codec *c = data;
char *constworkaroundandihateit = (char *)c->typename;

XFREE(MTYPE_SCRIPT, constworkaroundandihateit);
XFREE(MTYPE_SCRIPT, c);
}
#endif

/* Lua function hash utils */

Expand All @@ -212,17 +213,18 @@ bool lua_function_hash_cmp(const void *d1, const void *d2)
void *lua_function_alloc(void *arg)
{
struct lua_function_state *tmp = arg;

struct lua_function_state *lfs =
XCALLOC(MTYPE_SCRIPT, sizeof(struct lua_function_state));

lfs->name = tmp->name;
lfs->L = tmp->L;
return lfs;
}

static void lua_function_free(struct hash_bucket *b, void *data)
static void lua_function_free(void *data)
{
struct lua_function_state *lfs = (struct lua_function_state *)b->data;
struct lua_function_state *lfs = data;

lua_close(lfs->L);
XFREE(MTYPE_SCRIPT, lfs);
}
Expand Down Expand Up @@ -409,7 +411,8 @@ int frrscript_load(struct frrscript *fs, const char *function_name,

void frrscript_delete(struct frrscript *fs)
{
hash_iterate(fs->lua_function_hash, lua_function_free, NULL);
hash_clean(fs->lua_function_hash, lua_function_free);
hash_free(fs->lua_function_hash);
XFREE(MTYPE_SCRIPT, fs->name);
XFREE(MTYPE_SCRIPT, fs);
}
Expand All @@ -425,4 +428,11 @@ void frrscript_init(const char *sd)
frrscript_register_type_codecs(frrscript_codecs_lib);
}

void frrscript_fini(void)
{
hash_clean(codec_hash, codec_free);
hash_free(codec_hash);

frrscript_names_destroy();
}
#endif /* HAVE_SCRIPTING */
5 changes: 5 additions & 0 deletions lib/frrscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ void frrscript_register_type_codecs(struct frrscript_codec *codecs);
*/
void frrscript_init(const char *scriptdir);

/*
* On shutdown clean up memory associated with the scripting subsystem
*/
void frrscript_fini(void);

/*
* This macro is mapped to every (name, value) in frrscript_call,
* so this in turn maps them onto their encoders
Expand Down
4 changes: 4 additions & 0 deletions lib/libfrr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,10 @@ void frr_fini(void)
db_close();
#endif
log_ref_fini();

#ifdef HAVE_SCRIPTING
frrscript_fini();
#endif
frr_pthread_finish();
zprivs_terminate(di->privs);
/* signal_init -> nothing needed */
Expand Down
8 changes: 8 additions & 0 deletions ripd/ripd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3551,10 +3551,18 @@ static int rip_vrf_new(struct vrf *vrf)

static int rip_vrf_delete(struct vrf *vrf)
{
struct rip *rip;

if (IS_RIP_DEBUG_EVENT)
zlog_debug("%s: VRF deleted: %s(%u)", __func__, vrf->name,
vrf->vrf_id);

rip = rip_lookup_by_vrf_name(vrf->name);
if (!rip)
return 0;

rip_clean(rip);

return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions ripngd/ripngd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2581,10 +2581,17 @@ static int ripng_vrf_new(struct vrf *vrf)

static int ripng_vrf_delete(struct vrf *vrf)
{
struct ripng *ripng;

if (IS_RIPNG_DEBUG_EVENT)
zlog_debug("%s: VRF deleted: %s(%u)", __func__, vrf->name,
vrf->vrf_id);

ripng = ripng_lookup_by_vrf_name(vrf->name);
if (!ripng)
return 0;

ripng_clean(ripng);
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions staticd/static_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static void sigint(void)

static_vrf_terminate();

static_zebra_stop();
frr_fini();

exit(0);
Expand Down
1 change: 1 addition & 0 deletions zebra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void zebra_finalize(struct thread *dummy)

zebra_router_terminate();

ns_terminate();
frr_fini();
exit(0);
}
Expand Down
2 changes: 2 additions & 0 deletions zebra/zebra_evpn_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -4028,4 +4028,6 @@ void zebra_evpn_mh_terminate(void)
hash_free(zmh_info->nhg_table);
hash_free(zmh_info->nh_ip_table);
bf_free(zmh_info->nh_id_bitmap);

XFREE(MTYPE_ZMH_INFO, zrouter.mh_info);
}

0 comments on commit 2219391

Please sign in to comment.