summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_keepalives.c16
-rw-r--r--ospf6d/ospf6_lsa.c4
-rw-r--r--ospfclient/ospf_apiclient.c4
-rw-r--r--ospfclient/subdir.am1
-rw-r--r--ospfd/ospf_apiserver.c31
-rw-r--r--ospfd/ospf_apiserver.h4
-rw-r--r--ospfd/ospf_snmp.c6
-rw-r--r--ospfd/subdir.am8
8 files changed, 41 insertions, 33 deletions
diff --git a/bgpd/bgp_keepalives.c b/bgpd/bgp_keepalives.c
index b39a7daa1d..0e83157ecd 100644
--- a/bgpd/bgp_keepalives.c
+++ b/bgpd/bgp_keepalives.c
@@ -36,6 +36,10 @@
#include "bgpd/bgp_keepalives.h"
/* clang-format on */
+DEFINE_MTYPE_STATIC(BGPD, BGP_PKAT, "Peer KeepAlive Timer");
+DEFINE_MTYPE_STATIC(BGPD, BGP_COND, "BGP Peer pthread Conditional");
+DEFINE_MTYPE_STATIC(BGPD, BGP_MUTEX, "BGP Peer pthread Mutex");
+
/*
* Peer KeepAlive Timer.
* Associates a peer with the time of its last keepalive.
@@ -54,7 +58,7 @@ static struct hash *peerhash;
static struct pkat *pkat_new(struct peer *peer)
{
- struct pkat *pkat = XMALLOC(MTYPE_TMP, sizeof(struct pkat));
+ struct pkat *pkat = XMALLOC(MTYPE_BGP_PKAT, sizeof(struct pkat));
pkat->peer = peer;
monotime(&pkat->last);
return pkat;
@@ -62,7 +66,7 @@ static struct pkat *pkat_new(struct peer *peer)
static void pkat_del(void *pkat)
{
- XFREE(MTYPE_TMP, pkat);
+ XFREE(MTYPE_BGP_PKAT, pkat);
}
@@ -158,8 +162,8 @@ static void bgp_keepalives_finish(void *arg)
pthread_mutex_destroy(peerhash_mtx);
pthread_cond_destroy(peerhash_cond);
- XFREE(MTYPE_TMP, peerhash_mtx);
- XFREE(MTYPE_TMP, peerhash_cond);
+ XFREE(MTYPE_BGP_MUTEX, peerhash_mtx);
+ XFREE(MTYPE_BGP_COND, peerhash_cond);
}
/*
@@ -184,8 +188,8 @@ void *bgp_keepalives_start(void *arg)
*/
rcu_read_unlock();
- peerhash_mtx = XCALLOC(MTYPE_TMP, sizeof(pthread_mutex_t));
- peerhash_cond = XCALLOC(MTYPE_TMP, sizeof(pthread_cond_t));
+ peerhash_mtx = XCALLOC(MTYPE_BGP_MUTEX, sizeof(pthread_mutex_t));
+ peerhash_cond = XCALLOC(MTYPE_BGP_COND, sizeof(pthread_cond_t));
/* initialize mutex */
pthread_mutex_init(peerhash_mtx, NULL);
diff --git a/ospf6d/ospf6_lsa.c b/ospf6d/ospf6_lsa.c
index 2792820a54..55ac7c88a5 100644
--- a/ospf6d/ospf6_lsa.c
+++ b/ospf6d/ospf6_lsa.c
@@ -573,7 +573,7 @@ void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
json = json_object_new_object();
size_t header_str_sz = (2 * (end - start)) + 1;
- header_str = XMALLOC(MTYPE_TMP, header_str_sz);
+ header_str = XMALLOC(MTYPE_OSPF6_LSA_HEADER, header_str_sz);
inet_ntop(AF_INET, &lsa->header->id, id, sizeof(id));
inet_ntop(AF_INET, &lsa->header->adv_router, adv_router,
@@ -586,7 +586,7 @@ void ospf6_lsa_show_dump(struct vty *vty, struct ospf6_lsa *lsa,
json_object_string_add(json, "header", header_str);
json_object_array_add(json_array, json);
- XFREE(MTYPE_TMP, header_str);
+ XFREE(MTYPE_OSPF6_LSA_HEADER, header_str);
} else {
vty_out(vty, "\n%s:\n", lsa->name);
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index 05c5e7789d..4982cd885e 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -54,10 +54,6 @@
#include "ospf_apiclient.h"
-/* *sigh* ... can't find a better way to hammer this into automake */
-#include "ospfd/ospf_dump_api.c"
-#include "ospfd/ospf_api.c"
-
XREF_SETUP();
DEFINE_MGROUP(OSPFCLIENT, "libospfapiclient");
diff --git a/ospfclient/subdir.am b/ospfclient/subdir.am
index b8c82c0bcf..289ddd009d 100644
--- a/ospfclient/subdir.am
+++ b/ospfclient/subdir.am
@@ -27,6 +27,7 @@ endif
ospfclient_ospfclient_LDADD = \
ospfclient/libfrrospfapiclient.la \
+ ospfd/libfrrospfclient.a \
$(LIBCAP) \
# end
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 0c2ee0c4f8..6fd1c82c24 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -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);
}
diff --git a/ospfd/ospf_apiserver.h b/ospfd/ospf_apiserver.h
index e28202e46f..0a6b7319a0 100644
--- a/ospfd/ospf_apiserver.h
+++ b/ospfd/ospf_apiserver.h
@@ -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;
diff --git a/ospfd/ospf_snmp.c b/ospfd/ospf_snmp.c
index 9727c7039c..f1b876cfbe 100644
--- a/ospfd/ospf_snmp.c
+++ b/ospfd/ospf_snmp.c
@@ -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)
diff --git a/ospfd/subdir.am b/ospfd/subdir.am
index b67f942883..e45f617dfa 100644
--- a/ospfd/subdir.am
+++ b/ospfd/subdir.am
@@ -4,6 +4,7 @@
if OSPFD
noinst_LIBRARIES += ospfd/libfrrospf.a
+noinst_LIBRARIES += ospfd/libfrrospfclient.a
sbin_PROGRAMS += ospfd/ospfd
vtysh_daemons += ospfd
if SNMP
@@ -12,6 +13,11 @@ endif
man8 += $(MANBUILD)/frr-ospfd.8
endif
+ospfd_libfrrospfclient_a_SOURCES = \
+ ospfd/ospf_api.c \
+ ospfd/ospf_dump_api.c \
+ #end
+
ospfd_libfrrospf_a_SOURCES = \
ospfd/ospf_abr.c \
ospfd/ospf_api.c \
@@ -104,7 +110,7 @@ noinst_HEADERS += \
ospfd/ospf_zebra.h \
# end
-ospfd_ospfd_LDADD = ospfd/libfrrospf.a lib/libfrr.la $(LIBCAP) $(LIBM)
+ospfd_ospfd_LDADD = ospfd/libfrrospf.a ospfd/libfrrospfclient.a lib/libfrr.la $(LIBCAP) $(LIBM)
ospfd_ospfd_SOURCES = ospfd/ospf_main.c
ospfd_ospfd_snmp_la_SOURCES = ospfd/ospf_snmp.c