Merge pull request #12482 from donaldsharp/mem_this

Mem this
This commit is contained in:
Jafar Al-Gharaibeh 2022-12-09 20:19:28 -06:00 committed by GitHub
commit b7f08a6fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 46 deletions

View File

@ -1297,6 +1297,7 @@ static void spf_adj_get_reverse_metrics(struct isis_spftree *spftree)
if (lsp_adj == NULL || lsp_adj->hdr.rem_lifetime == 0) {
/* Delete one-way adjacency. */
listnode_delete(spftree->sadj_list, sadj);
isis_spf_adj_free(sadj);
continue;
}
@ -1313,6 +1314,7 @@ static void spf_adj_get_reverse_metrics(struct isis_spftree *spftree)
if (args.reverse_metric == UINT32_MAX) {
/* Delete one-way adjacency. */
listnode_delete(spftree->sadj_list, sadj);
isis_spf_adj_free(sadj);
continue;
}
sadj->metric = args.reverse_metric;

View File

@ -28,6 +28,37 @@
DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List");
DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node");
/* these *do not* cleanup list nodes and referenced data, as the functions
* do - these macros simply {de,at}tach a listnode from/to a list.
*/
/* List node attach macro. */
#define LISTNODE_ATTACH(L, N) \
do { \
(N)->prev = (L)->tail; \
(N)->next = NULL; \
if ((L)->head == NULL) \
(L)->head = (N); \
else \
(L)->tail->next = (N); \
(L)->tail = (N); \
(L)->count++; \
} while (0)
/* List node detach macro. */
#define LISTNODE_DETACH(L, N) \
do { \
if ((N)->prev) \
(N)->prev->next = (N)->next; \
else \
(L)->head = (N)->next; \
if ((N)->next) \
(N)->next->prev = (N)->prev; \
else \
(L)->tail = (N)->prev; \
(L)->count--; \
} while (0)
struct list *list_new(void)
{
return XCALLOC(MTYPE_LINK_LIST, sizeof(struct list));

View File

@ -349,37 +349,6 @@ extern struct list *list_dup(struct list *list);
(node) != NULL && ((data) = static_cast(data, listgetdata(node)), 1); \
(node) = listnextnode(node), ((data) = NULL)
/* these *do not* cleanup list nodes and referenced data, as the functions
* do - these macros simply {de,at}tach a listnode from/to a list.
*/
/* List node attach macro. */
#define LISTNODE_ATTACH(L, N) \
do { \
(N)->prev = (L)->tail; \
(N)->next = NULL; \
if ((L)->head == NULL) \
(L)->head = (N); \
else \
(L)->tail->next = (N); \
(L)->tail = (N); \
(L)->count++; \
} while (0)
/* List node detach macro. */
#define LISTNODE_DETACH(L, N) \
do { \
if ((N)->prev) \
(N)->prev->next = (N)->next; \
else \
(L)->head = (N)->next; \
if ((N)->next) \
(N)->next->prev = (N)->prev; \
else \
(L)->tail = (N)->prev; \
(L)->count--; \
} while (0)
extern struct listnode *listnode_lookup_nocheck(struct list *list, void *data);
/*

View File

@ -1242,7 +1242,8 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
}
}
json_auth = json_object_new_object();
if (use_json)
json_auth = json_object_new_object();
if (oi->at_data.flags != 0) {
if (use_json) {
if (CHECK_FLAG(oi->at_data.flags,

View File

@ -833,20 +833,8 @@ static void dplane_ctx_free_internal(struct zebra_dplane_ctx *ctx)
break;
case DPLANE_OP_IPTABLE_ADD:
case DPLANE_OP_IPTABLE_DELETE:
if (ctx->u.iptable.interface_name_list) {
struct listnode *node, *nnode;
char *ifname;
for (ALL_LIST_ELEMENTS(
ctx->u.iptable.interface_name_list, node,
nnode, ifname)) {
LISTNODE_DETACH(
ctx->u.iptable.interface_name_list,
node);
XFREE(MTYPE_DP_NETFILTER, ifname);
}
if (ctx->u.iptable.interface_name_list)
list_delete(&ctx->u.iptable.interface_name_list);
}
break;
case DPLANE_OP_GRE_SET:
case DPLANE_OP_INTF_NETCONFIG:
@ -3476,6 +3464,11 @@ static int dplane_ctx_rule_init(struct zebra_dplane_ctx *ctx,
return AOK;
}
static void zebra_dplane_interface_name_list_deletion(void *data)
{
XFREE(MTYPE_DP_NETFILTER, data);
}
/**
* dplane_ctx_iptable_init() - Initialize a context block for a PBR iptable
* update.
@ -3509,9 +3502,10 @@ static int dplane_ctx_iptable_init(struct zebra_dplane_ctx *ctx,
ctx->zd_vrf_id = iptable->vrf_id;
memcpy(&ctx->u.iptable, iptable, sizeof(struct zebra_pbr_iptable));
ctx->u.iptable.interface_name_list = NULL;
if (iptable->nb_interface > 0) {
ctx->u.iptable.interface_name_list = list_new();
ctx->u.iptable.interface_name_list->del =
zebra_dplane_interface_name_list_deletion;
for (ALL_LIST_ELEMENTS_RO(iptable->interface_name_list, node,
ifname)) {
listnode_add(ctx->u.iptable.interface_name_list,

View File

@ -1818,6 +1818,23 @@ static void zebra_route_map_event(const char *rmap_name)
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
}
void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf)
{
afi_t afi;
uint8_t type;
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
if (PROTO_RM_NAME(zvrf, afi, type))
XFREE(MTYPE_ROUTE_MAP_NAME,
PROTO_RM_NAME(zvrf, afi, type));
if (NHT_RM_NAME(zvrf, afi, type))
XFREE(MTYPE_ROUTE_MAP_NAME,
NHT_RM_NAME(zvrf, afi, type));
}
}
}
/* ip protocol configuration write function */
void zebra_routemap_config_write_protocol(struct vty *vty,
struct zebra_vrf *zvrf)

View File

@ -50,6 +50,8 @@ zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p,
struct zebra_vrf *zvrf, struct route_entry *,
struct nexthop *nexthop);
extern void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf);
#ifdef __cplusplus
}
#endif

View File

@ -268,6 +268,7 @@ static int zebra_vrf_delete(struct vrf *vrf)
/* Cleanup EVPN states for vrf */
zebra_vxlan_vrf_delete(zvrf);
zebra_routemap_vrf_delete(zvrf);
list_delete_all_node(zvrf->rid_all_sorted_list);
list_delete_all_node(zvrf->rid_lo_sorted_list);