Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory type stuff (backport #16711) #16715

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);

vty_out(vty, "\n %zu connected clients:\n",
Expand All @@ -2714,7 +2714,7 @@ DEFPY(show_bmp,
}
out = ttable_dump(tt, "\n");
vty_out(vty, "%s", out);
XFREE(MTYPE_TMP, out);
XFREE(MTYPE_TMP_TTABLE, out);
ttable_del(tt);
vty_out(vty, "\n");
}
Expand Down
14 changes: 8 additions & 6 deletions isisd/isis_mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ struct isis_area_mt_setting **area_mt_settings(struct isis_area *area,

count++;
if (count > size) {
rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
Expand Down Expand Up @@ -341,7 +342,8 @@ circuit_mt_settings(struct isis_circuit *circuit, unsigned int *mt_count)

count++;
if (count > size) {
rv = XREALLOC(MTYPE_TMP, rv, count * sizeof(*rv));
rv = XREALLOC(MTYPE_MT_AREA_SETTING, rv,
count * sizeof(*rv));
size = count;
}
rv[count - 1] = setting;
Expand Down Expand Up @@ -376,8 +378,8 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,

old_mt_count = adj->mt_count;
if (old_mt_count) {
old_mt_set =
XCALLOC(MTYPE_TMP, old_mt_count * sizeof(*old_mt_set));
old_mt_set = XCALLOC(MTYPE_MT_AREA_SETTING,
old_mt_count * sizeof(*old_mt_set));
memcpy(old_mt_set, adj->mt_set,
old_mt_count * sizeof(*old_mt_set));
}
Expand Down Expand Up @@ -436,7 +438,7 @@ bool tlvs_to_adj_mt_set(struct isis_tlvs *tlvs, bool v4_usable, bool v6_usable,
changed = true;

if (old_mt_count)
XFREE(MTYPE_TMP, old_mt_set);
XFREE(MTYPE_MT_AREA_SETTING, old_mt_set);

return changed;
}
Expand Down Expand Up @@ -464,7 +466,7 @@ static void mt_set_add(uint16_t **mt_set, unsigned int *size,
}

if (*index >= *size) {
*mt_set = XREALLOC(MTYPE_TMP, *mt_set,
*mt_set = XREALLOC(MTYPE_MT_AREA_SETTING, *mt_set,
sizeof(**mt_set) * ((*index) + 1));
*size = (*index) + 1;
}
Expand Down
16 changes: 14 additions & 2 deletions isisd/isis_spf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,18 @@ static void isis_print_paths(struct vty *vty, struct isis_vertex_queue *queue,
}
vty_out(vty, "\n");
}
<<<<<<< HEAD
=======
if (json == NULL) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
*json = ttable_json_with_json_text(
tt, "ssdsss",
"vertex|type|metric|nextHop|interface|parent");
ttable_del(tt);
>>>>>>> d97c535c1e (*: Create termtable specific temp memory)
}

void isis_print_spftree(struct vty *vty, struct isis_spftree *spftree)
Expand Down Expand Up @@ -2867,7 +2879,7 @@ void isis_print_routes(struct vty *vty, struct isis_spftree *spftree,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else if (json) {
*json = ttable_json(tt, prefix_sid ? "sdssdsdd" : "sdsss");
}
Expand Down Expand Up @@ -3242,7 +3254,7 @@ static void isis_print_frr_summary(struct vty *vty,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}

Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}
Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ static void show_node(struct vty *vty, struct isis_area *area, int level)

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
}
ttable_del(tt);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ DEFUN_NOSH(show_hash_stats,
ttable_colseps(tt, 0, RIGHT, true, '|');
char *table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No named hash tables to display.\n");

Expand Down
1 change: 1 addition & 0 deletions lib/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct memgroup **mg_insert = &mg_first;

DEFINE_MGROUP(LIB, "libfrr");
DEFINE_MTYPE(LIB, TMP, "Temporary memory");
DEFINE_MTYPE(LIB, TMP_TTABLE, "Temporary memory for TTABLE");
DEFINE_MTYPE(LIB, BITFIELD, "Bitfield memory");

static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr)
Expand Down
1 change: 1 addition & 0 deletions lib/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct memgroup {

DECLARE_MGROUP(LIB);
DECLARE_MTYPE(TMP);
DECLARE_MTYPE(TMP_TTABLE);


extern void *qmalloc(struct memtype *mt, size_t size)
Expand Down
6 changes: 3 additions & 3 deletions lib/northbound_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ static int nb_cli_show_transactions(struct vty *vty)

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No configuration transactions to display.\n\n");

Expand Down Expand Up @@ -1590,7 +1590,7 @@ DEFPY (show_yang_module,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG modules to display.\n\n");

Expand Down Expand Up @@ -1700,7 +1700,7 @@ DEFPY (show_yang_module_translator,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
} else
vty_out(vty, "No YANG module translators to display.\n\n");

Expand Down
2 changes: 1 addition & 1 deletion lib/termtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ char *ttable_dump(struct ttable *tt, const char *newline)
memcpy(&right[0], newline, nl_len);

/* allocate print buffer */
buf = XCALLOC(MTYPE_TMP, width * (nlines + 1) + 1);
buf = XCALLOC(MTYPE_TMP_TTABLE, width * (nlines + 1) + 1);
pos = 0;

if (tt->style.border.top_on) {
Expand Down
2 changes: 1 addition & 1 deletion lib/termtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void ttable_rowseps(struct ttable *tt, unsigned int row,
*
* Caller must free this string after use with
*
* XFREE (MTYPE_TMP, str);
* XFREE (MTYPE_TMP_TTABLE, str);
*
* @param tt the table to dump
* @param newline the desired newline sequence to use, null terminated.
Expand Down
2 changes: 1 addition & 1 deletion pathd/path_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ DEFPY(show_srte_policy,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);

ttable_del(tt);

Expand Down
4 changes: 2 additions & 2 deletions pimd/pim6_mld.c
Original file line number Diff line number Diff line change
Expand Up @@ -2537,7 +2537,7 @@ static void gm_show_if_vrf(struct vty *vty, struct vrf *vrf, const char *ifname,
if (!js && !detail) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -3021,7 +3021,7 @@ static void gm_show_groups(struct vty *vty, struct vrf *vrf, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down
36 changes: 18 additions & 18 deletions pimd/pim_cmd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void pim_show_rpf(struct pim_instance *pim, struct vty *vty, json_object *json)
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@ void pim_show_neighbors_secondary(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}

Expand Down Expand Up @@ -1275,7 +1275,7 @@ void pim_show_state(struct pim_instance *pim, struct vty *vty,
#else
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
#endif
}
Expand Down Expand Up @@ -1508,7 +1508,7 @@ void pim_show_upstream(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ void pim_show_join_desired(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -1664,7 +1664,7 @@ void pim_show_upstream_rpf(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -1846,7 +1846,7 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -1926,7 +1926,7 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}

Expand Down Expand Up @@ -2069,7 +2069,7 @@ void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -2174,7 +2174,7 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -2357,7 +2357,7 @@ void pim_show_interfaces(struct pim_instance *pim, struct vty *vty, bool mlag,
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);

ttable_del(tt);
}
Expand Down Expand Up @@ -2829,7 +2829,7 @@ static int pim_print_vty_pnc_cache_walkcb(struct hash_bucket *bucket, void *arg)
/* Dump the generated table. */
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);

return CMD_SUCCESS;
Expand Down Expand Up @@ -3309,7 +3309,7 @@ void pim_show_neighbors(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -3605,7 +3605,7 @@ void show_multicast_interfaces(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -4044,7 +4044,7 @@ void show_mroute(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -4127,7 +4127,7 @@ void show_mroute_count(struct pim_instance *pim, struct vty *vty,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
}
Expand Down Expand Up @@ -5430,7 +5430,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
tt = NULL;
}
Expand Down Expand Up @@ -5484,7 +5484,7 @@ static void pim_show_group_rp_mappings_info(struct pim_instance *pim,

table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
}
if (!bsm_rpinfos_count(bsgrp->partial_bsrp_list) && !uj)
Expand Down
2 changes: 1 addition & 1 deletion pimd/pim_rp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ void pim_rp_show_information(struct pim_instance *pim, struct prefix *range,
if (!json) {
table = ttable_dump(tt, "\n");
vty_out(vty, "%s\n", table);
XFREE(MTYPE_TMP, table);
XFREE(MTYPE_TMP_TTABLE, table);
ttable_del(tt);
} else {
if (prev_rp_info && json_rp_rows)
Expand Down
Loading
Loading