summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zebra/rt_netlink.c2
-rw-r--r--zebra/zapi_msg.c18
-rw-r--r--zebra/zapi_msg.h2
-rw-r--r--zebra/zebra_rib.c10
-rw-r--r--zebra/zebra_rnh.c2
5 files changed, 15 insertions, 19 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 01b527ea80..768090badb 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1040,7 +1040,7 @@ int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
zlog_err(
"%s: %pFX multipath RTM_NEWROUTE has a invalid nexthop group from the kernel",
__func__, &p);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
}
} else {
if (ctx) {
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index 654ade8063..aecbba2ebc 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2148,7 +2148,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
__func__, &api.prefix,
zebra_route_string(client->proto));
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
return;
}
@@ -2173,7 +2173,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
nexthop_group_delete(&ng);
zebra_nhg_backup_free(&bnhg);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
return;
}
@@ -2192,8 +2192,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
__func__);
nexthop_group_delete(&ng);
zebra_nhg_backup_free(&bnhg);
- XFREE(MTYPE_RE_OPAQUE, re->opaque);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
return;
}
if (CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX))
@@ -2205,8 +2204,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
__func__, api.safi);
nexthop_group_delete(&ng);
zebra_nhg_backup_free(&bnhg);
- XFREE(MTYPE_RE_OPAQUE, re->opaque);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
return;
}
@@ -2235,8 +2233,7 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
*/
if (ret == -1) {
client->error_cnt++;
- XFREE(MTYPE_RE_OPAQUE, re->opaque);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
}
/* At this point, these allocations are not needed: 're' has been
@@ -2264,9 +2261,10 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
}
}
-void zapi_re_opaque_free(struct re_opaque *opaque)
+void zapi_re_opaque_free(struct route_entry *re)
{
- XFREE(MTYPE_RE_OPAQUE, opaque);
+ XFREE(MTYPE_RE_OPAQUE, re->opaque);
+ re->opaque = NULL;
}
static void zread_route_del(ZAPI_HANDLER_ARGS)
diff --git a/zebra/zapi_msg.h b/zebra/zapi_msg.h
index 9e3ea6fb6e..a59ccc838b 100644
--- a/zebra/zapi_msg.h
+++ b/zebra/zapi_msg.h
@@ -106,7 +106,7 @@ extern int zsend_client_close_notify(struct zserv *client,
int zsend_nhg_notify(uint16_t type, uint16_t instance, uint32_t session_id,
uint32_t id, enum zapi_nhg_notify_owner note);
-extern void zapi_re_opaque_free(struct re_opaque *opaque);
+extern void zapi_re_opaque_free(struct route_entry *re);
extern int zsend_zebra_srv6_locator_add(struct zserv *client,
struct srv6_locator *loc);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 0f02b0a2ec..59190e9dd3 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2696,8 +2696,7 @@ static void early_route_memory_free(struct zebra_early_route *ere)
if (ere->re_nhe)
zebra_nhg_free(ere->re_nhe);
- zapi_re_opaque_free(ere->re->opaque);
- XFREE(MTYPE_RE, ere->re);
+ zebra_rib_route_entry_free(ere->re);
XFREE(MTYPE_WQ_WRAPPER, ere);
}
@@ -4070,9 +4069,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
rib_re_nhg_free(re);
- zapi_re_opaque_free(re->opaque);
-
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
}
void rib_delnode(struct route_node *rn, struct route_entry *re)
@@ -4319,6 +4316,7 @@ struct route_entry *zebra_rib_route_entry_new(vrf_id_t vrf_id, int type,
void zebra_rib_route_entry_free(struct route_entry *re)
{
+ zapi_re_opaque_free(re);
XFREE(MTYPE_RE, re);
}
@@ -4389,7 +4387,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
/* In error cases, free the route also */
if (ret < 0)
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
return ret;
}
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index bff8258879..303a81bb3e 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -826,7 +826,7 @@ static void free_state(vrf_id_t vrf_id, struct route_entry *re,
/* free RE and nexthops */
zebra_nhg_free(re->nhe);
- XFREE(MTYPE_RE, re);
+ zebra_rib_route_entry_free(re);
}
static void copy_state(struct rnh *rnh, const struct route_entry *re,