ospfd: Remove MTYPE_TMP

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2022-12-05 11:43:57 -05:00
parent 1f98f42443
commit 29a1a53d6c
3 changed files with 21 additions and 20 deletions

View file

@ -56,10 +56,14 @@
#include "ospfd/ospf_ase.h"
#include "ospfd/ospf_zebra.h"
#include "ospfd/ospf_errors.h"
#include "ospfd/ospf_memory.h"
#include "ospfd/ospf_api.h"
#include "ospfd/ospf_apiserver.h"
DEFINE_MTYPE_STATIC(OSPFD, APISERVER, "API Server");
DEFINE_MTYPE_STATIC(OSPFD, APISERVER_MSGFILTER, "API Server Message Filter");
/* This is an implementation of an API to the OSPF daemon that allows
* external applications to access the OSPF daemon through socket
* connections. The application can use this API to inject its own
@ -245,9 +249,9 @@ static int ospf_apiserver_del_lsa_hook(struct ospf_lsa *lsa)
struct ospf_apiserver *ospf_apiserver_new(int fd_sync, int fd_async)
{
struct ospf_apiserver *new =
XMALLOC(MTYPE_OSPF_APISERVER, sizeof(struct ospf_apiserver));
XMALLOC(MTYPE_APISERVER, sizeof(struct ospf_apiserver));
new->filter = XMALLOC(MTYPE_OSPF_APISERVER_MSGFILTER,
new->filter = XMALLOC(MTYPE_APISERVER_MSGFILTER,
sizeof(struct lsa_filter_type));
new->fd_sync = fd_sync;
@ -360,7 +364,7 @@ void ospf_apiserver_free(struct ospf_apiserver *apiserv)
(void *)apiserv, apiserver_list->count);
/* And free instance. */
XFREE(MTYPE_OSPF_APISERVER, apiserv);
XFREE(MTYPE_APISERVER, apiserv);
}
void ospf_apiserver_read(struct thread *thread)
@ -862,8 +866,8 @@ int ospf_apiserver_register_opaque_type(struct ospf_apiserver *apiserv,
connection shuts down, we can flush all LSAs of this opaque
type. */
regtype = XCALLOC(MTYPE_OSPF_APISERVER,
sizeof(struct registered_opaque_type));
regtype =
XCALLOC(MTYPE_APISERVER, sizeof(struct registered_opaque_type));
regtype->lsa_type = lsa_type;
regtype->opaque_type = opaque_type;
@ -1155,12 +1159,12 @@ int ospf_apiserver_handle_register_event(struct ospf_apiserver *apiserv,
seqnum = msg_get_seq(msg);
/* Free existing filter in apiserv. */
XFREE(MTYPE_OSPF_APISERVER_MSGFILTER, apiserv->filter);
XFREE(MTYPE_APISERVER_MSGFILTER, apiserv->filter);
/* Alloc new space for filter. */
size = ntohs(msg->hdr.msglen);
if (size < OSPF_MAX_LSA_SIZE) {
apiserv->filter = XMALLOC(MTYPE_OSPF_APISERVER_MSGFILTER, size);
apiserv->filter = XMALLOC(MTYPE_APISERVER_MSGFILTER, size);
/* copy it over. */
memcpy(apiserv->filter, &rmsg->filter, size);
@ -1365,8 +1369,7 @@ int ospf_apiserver_handle_sync_reachable(struct ospf_apiserver *apiserv,
goto out;
/* send all adds based on current reachable routers */
a = abuf = XCALLOC(MTYPE_OSPF_APISERVER,
sizeof(struct in_addr) * rt->count);
a = abuf = XCALLOC(MTYPE_APISERVER, sizeof(struct in_addr) * rt->count);
for (struct route_node *rn = route_top(rt); rn; rn = route_next(rn))
if (listhead((struct list *)rn->info))
*a++ = rn->p.u.prefix4;
@ -1385,7 +1388,7 @@ int ospf_apiserver_handle_sync_reachable(struct ospf_apiserver *apiserv,
rc = ospf_apiserver_send_msg(apiserv, amsg);
msg_free(amsg);
}
XFREE(MTYPE_OSPF_APISERVER, abuf);
XFREE(MTYPE_APISERVER, abuf);
out:
/* Send a reply back to client with return code */
@ -2616,9 +2619,9 @@ void ospf_apiserver_notify_reachable(struct route_table *ort,
return;
}
if (nrt && nrt->count)
a = abuf = XCALLOC(MTYPE_OSPF_APISERVER, insz * nrt->count);
a = abuf = XCALLOC(MTYPE_APISERVER, insz * nrt->count);
if (ort && ort->count)
d = dbuf = XCALLOC(MTYPE_OSPF_APISERVER, insz * ort->count);
d = dbuf = XCALLOC(MTYPE_APISERVER, insz * ort->count);
/* walk both tables */
orn = ort ? route_top(ort) : NULL;
@ -2683,9 +2686,9 @@ void ospf_apiserver_notify_reachable(struct route_table *ort,
msg_free(msg);
}
if (abuf)
XFREE(MTYPE_OSPF_APISERVER, abuf);
XFREE(MTYPE_APISERVER, abuf);
if (dbuf)
XFREE(MTYPE_OSPF_APISERVER, dbuf);
XFREE(MTYPE_APISERVER, dbuf);
}

View file

@ -26,10 +26,6 @@
#include "ospf_api.h"
#include "ospf_lsdb.h"
/* MTYPE definition is not reflected to "memory.h". */
#define MTYPE_OSPF_APISERVER MTYPE_TMP
#define MTYPE_OSPF_APISERVER_MSGFILTER MTYPE_TMP
/* List of opaque types that application registered */
struct registered_opaque_type {
uint8_t lsa_type;

View file

@ -50,6 +50,8 @@
#include "ospfd/ospf_route.h"
#include "ospfd/ospf_zebra.h"
DEFINE_MTYPE_STATIC(OSPFD, SNMP, "OSPF SNMP");
/* OSPF2-MIB. */
#define OSPF2MIB 1,3,6,1,2,1,14
@ -1321,12 +1323,12 @@ struct ospf_snmp_if {
static struct ospf_snmp_if *ospf_snmp_if_new(void)
{
return XCALLOC(MTYPE_TMP, sizeof(struct ospf_snmp_if));
return XCALLOC(MTYPE_SNMP, sizeof(struct ospf_snmp_if));
}
static void ospf_snmp_if_free(struct ospf_snmp_if *osif)
{
XFREE(MTYPE_TMP, osif);
XFREE(MTYPE_SNMP, osif);
}
static int ospf_snmp_if_delete(struct interface *ifp)