summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2019-06-21 13:40:27 +0200
committerGitHub <noreply@github.com>2019-06-21 13:40:27 +0200
commit2bc398c3c4af0e3e7c821b81ba97d287246ed2ef (patch)
tree1bb05678fe57348b51e9ccc7cd5838bfaceef388
parentMerge pull request #4531 from donaldsharp/repeaty_mcrepeat (diff)
parentripngd: use MTYPE_STATIC (diff)
downloadfrr-2bc398c3c4af0e3e7c821b81ba97d287246ed2ef.tar.xz
frr-2bc398c3c4af0e3e7c821b81ba97d287246ed2ef.zip
Merge pull request #4573 from opensourcerouting/mtype_cleanup
MTYPE cleanup pass
-rw-r--r--babeld/babel_interface.c3
-rw-r--r--babeld/babel_memory.c30
-rw-r--r--babeld/babel_memory.h32
-rw-r--r--babeld/babeld.c4
-rw-r--r--babeld/subdir.am2
-rw-r--r--babeld/util.h3
-rw-r--r--bfdd/bfd.c5
-rw-r--r--bfdd/bfd.h15
-rw-r--r--bfdd/bfdd.c11
-rw-r--r--bfdd/config.c2
-rw-r--r--bgpd/bgp_vty.c8
-rw-r--r--doc/developer/memtypes.rst10
-rw-r--r--lib/command.c2
-rw-r--r--lib/command.h1
-rw-r--r--lib/frr_pthread.c4
-rw-r--r--lib/frr_pthread.h3
-rw-r--r--lib/hash.c4
-rw-r--r--lib/hash.h3
-rw-r--r--lib/if.c2
-rw-r--r--lib/if.h1
-rw-r--r--lib/memory.h23
-rw-r--r--lib/table.c2
-rw-r--r--lib/table.h1
-rw-r--r--lib/yang.c4
-rw-r--r--lib/yang.h3
-rw-r--r--ripd/rip_interface.c2
-rw-r--r--ripd/rip_interface.h3
-rw-r--r--ripd/rip_memory.c36
-rw-r--r--ripd/rip_memory.h37
-rw-r--r--ripd/rip_northbound.c1
-rw-r--r--ripd/rip_offset.c2
-rw-r--r--ripd/rip_peer.c2
-rw-r--r--ripd/ripd.c6
-rw-r--r--ripd/ripd.h4
-rw-r--r--ripd/subdir.am2
-rw-r--r--ripngd/ripng_interface.c6
-rw-r--r--ripngd/ripng_memory.c35
-rw-r--r--ripngd/ripng_memory.h36
-rw-r--r--ripngd/ripng_nexthop.c2
-rw-r--r--ripngd/ripng_offset.c2
-rw-r--r--ripngd/ripng_peer.c2
-rw-r--r--ripngd/ripng_route.c2
-rw-r--r--ripngd/ripngd.c5
-rw-r--r--ripngd/ripngd.h5
-rw-r--r--ripngd/subdir.am2
-rw-r--r--vrrpd/subdir.am2
-rw-r--r--vrrpd/vrrp.c6
-rw-r--r--vrrpd/vrrp.h3
-rw-r--r--vrrpd/vrrp_main.c2
-rw-r--r--vrrpd/vrrp_memory.c29
-rw-r--r--vrrpd/vrrp_memory.h32
-rw-r--r--vrrpd/vrrp_packet.c8
-rw-r--r--vrrpd/vrrp_packet.h3
-rw-r--r--vrrpd/vrrp_vty.c1
-rw-r--r--zebra/rtadv.c2
-rw-r--r--zebra/zebra_dplane.c4
-rw-r--r--zebra/zebra_memory.c6
-rw-r--r--zebra/zebra_memory.h8
-rw-r--r--zebra/zebra_rnh.c2
-rw-r--r--zebra/zebra_router.c2
-rw-r--r--zebra/zebra_vrf.c3
61 files changed, 127 insertions, 356 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c
index b84bc39cd..0eeb9b2bb 100644
--- a/babeld/babel_interface.c
+++ b/babeld/babel_interface.c
@@ -39,9 +39,10 @@ THE SOFTWARE.
#include "neighbour.h"
#include "route.h"
#include "xroute.h"
-#include "babel_memory.h"
#include "babel_errors.h"
+DEFINE_MTYPE_STATIC(BABELD, BABEL_IF, "Babel Interface")
+
#define IS_ENABLE(ifp) (babel_enable_if_lookup(ifp->name) >= 0)
static int babel_enable_if_lookup (const char *ifname);
diff --git a/babeld/babel_memory.c b/babeld/babel_memory.c
deleted file mode 100644
index a10b7791e..000000000
--- a/babeld/babel_memory.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* babeld memory type definitions
- *
- * Copyright (C) 2017 Donald Sharp
- *
- * This file is part of FRR
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FRR; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "babel_memory.h"
-
-DEFINE_MGROUP(BABELD, "babeld")
-DEFINE_MTYPE(BABELD, BABEL, "Babel Structure")
-DEFINE_MTYPE(BABELD, BABEL_IF, "Babel Interface")
diff --git a/babeld/babel_memory.h b/babeld/babel_memory.h
deleted file mode 100644
index 428349889..000000000
--- a/babeld/babel_memory.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* babel memory type declarations
- *
- * Copyright (C) 2017 Donald Sharp
- *
- * This file is part of FRR.
- *
- * FRR is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * FRR is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with FRR; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _FRR_BABEL_MEMORY_H
-#define _FRR_BABEL_MEMORY_H
-
-#include "memory.h"
-
-DECLARE_MGROUP(BABELD)
-DECLARE_MTYPE(BABEL)
-DECLARE_MTYPE(BABEL_IF)
-
-#endif /* _FRR_BABELD_MEMORY_H */
diff --git a/babeld/babeld.c b/babeld/babeld.c
index 39451b435..6ad004a4a 100644
--- a/babeld/babeld.c
+++ b/babeld/babeld.c
@@ -43,9 +43,11 @@ THE SOFTWARE.
#include "resend.h"
#include "babel_filter.h"
#include "babel_zebra.h"
-#include "babel_memory.h"
#include "babel_errors.h"
+DEFINE_MGROUP(BABELD, "babeld")
+DEFINE_MTYPE_STATIC(BABELD, BABEL, "Babel Structure")
+
static int babel_init_routing_process(struct thread *thread);
static void babel_get_myid(void);
static void babel_initial_noise(void);
diff --git a/babeld/subdir.am b/babeld/subdir.am
index 7081c730a..dd46675f2 100644
--- a/babeld/subdir.am
+++ b/babeld/subdir.am
@@ -17,7 +17,6 @@ babeld_libbabel_a_SOURCES = \
babeld/babel_errors.c \
babeld/babel_filter.c \
babeld/babel_interface.c \
- babeld/babel_memory.c \
babeld/babel_zebra.c \
babeld/babeld.c \
babeld/kernel.c \
@@ -36,7 +35,6 @@ noinst_HEADERS += \
babeld/babel_filter.h \
babeld/babel_interface.h \
babeld/babel_main.h \
- babeld/babel_memory.h \
babeld/babel_zebra.h \
babeld/babeld.h \
babeld/kernel.h \
diff --git a/babeld/util.h b/babeld/util.h
index 7b836c2e4..00a025ff9 100644
--- a/babeld/util.h
+++ b/babeld/util.h
@@ -27,6 +27,9 @@ THE SOFTWARE.
#include "babeld.h"
#include "babel_main.h"
#include "log.h"
+#include "memory.h"
+
+DECLARE_MGROUP(BABELD)
#if defined(i386) || defined(__mc68020__) || defined(__x86_64__)
#define DO_NTOHS(_d, _s) do{ _d = ntohs(*(const unsigned short*)(_s)); }while(0)
diff --git a/bfdd/bfd.c b/bfdd/bfd.c
index 435443182..c69e565d1 100644
--- a/bfdd/bfd.c
+++ b/bfdd/bfd.c
@@ -31,7 +31,10 @@
#include "bfd.h"
-DEFINE_QOBJ_TYPE(bfd_session);
+DEFINE_MTYPE_STATIC(BFDD, BFDD_CONFIG, "long-lived configuration memory")
+DEFINE_MTYPE_STATIC(BFDD, BFDD_SESSION_OBSERVER, "Session observer")
+DEFINE_MTYPE_STATIC(BFDD, BFDD_VRF, "BFD VRF")
+DEFINE_QOBJ_TYPE(bfd_session)
/*
* Prototypes
diff --git a/bfdd/bfd.h b/bfdd/bfd.h
index 213e905bf..ec31c8cbc 100644
--- a/bfdd/bfd.h
+++ b/bfdd/bfd.h
@@ -41,14 +41,9 @@
#define BFDD_JSON_CONV_OPTIONS (0)
#endif
-DECLARE_MGROUP(BFDD);
-DECLARE_MTYPE(BFDD_TMP);
-DECLARE_MTYPE(BFDD_CONFIG);
-DECLARE_MTYPE(BFDD_LABEL);
-DECLARE_MTYPE(BFDD_CONTROL);
-DECLARE_MTYPE(BFDD_SESSION_OBSERVER);
-DECLARE_MTYPE(BFDD_NOTIFICATION);
-DECLARE_MTYPE(BFDD_VRF);
+DECLARE_MGROUP(BFDD)
+DECLARE_MTYPE(BFDD_CONTROL)
+DECLARE_MTYPE(BFDD_NOTIFICATION)
struct bfd_timers {
uint32_t desired_min_tx;
@@ -259,9 +254,9 @@ struct bfd_session {
uint64_t refcount; /* number of pointers referencing this. */
/* VTY context data. */
- QOBJ_FIELDS;
+ QOBJ_FIELDS
};
-DECLARE_QOBJ_TYPE(bfd_session);
+DECLARE_QOBJ_TYPE(bfd_session)
struct peer_label {
TAILQ_ENTRY(peer_label) pl_entry;
diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c
index 06e01abcf..6c277c98f 100644
--- a/bfdd/bfdd.c
+++ b/bfdd/bfdd.c
@@ -29,14 +29,9 @@
/*
* FRR related code.
*/
-DEFINE_MGROUP(BFDD, "Bidirectional Forwarding Detection Daemon");
-DEFINE_MTYPE(BFDD, BFDD_TMP, "short-lived temporary memory");
-DEFINE_MTYPE(BFDD, BFDD_CONFIG, "long-lived configuration memory");
-DEFINE_MTYPE(BFDD, BFDD_LABEL, "long-lived label memory");
-DEFINE_MTYPE(BFDD, BFDD_CONTROL, "long-lived control socket memory");
-DEFINE_MTYPE(BFDD, BFDD_SESSION_OBSERVER, "Session observer");
-DEFINE_MTYPE(BFDD, BFDD_NOTIFICATION, "short-lived control notification data");
-DEFINE_MTYPE(BFDD, BFDD_VRF, "BFD VRF");
+DEFINE_MGROUP(BFDD, "Bidirectional Forwarding Detection Daemon")
+DEFINE_MTYPE(BFDD, BFDD_CONTROL, "long-lived control socket memory")
+DEFINE_MTYPE(BFDD, BFDD_NOTIFICATION, "short-lived control notification data")
/* Master of threads. */
struct thread_master *master;
diff --git a/bfdd/config.c b/bfdd/config.c
index 74e7d63d0..0c0bac0aa 100644
--- a/bfdd/config.c
+++ b/bfdd/config.c
@@ -30,6 +30,8 @@
#include "bfd.h"
+DEFINE_MTYPE_STATIC(BFDD, BFDD_LABEL, "long-lived label memory")
+
/*
* Definitions
*/
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 6cbb9af50..22e9469a7 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -7722,14 +7722,6 @@ DEFUN (show_bgp_memory,
count * sizeof(struct peer_group)));
/* Other */
- if ((count = mtype_stats_alloc(MTYPE_HASH)))
- vty_out(vty, "%ld hash tables, using %s of memory\n", count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct hash)));
- if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET)))
- vty_out(vty, "%ld hash buckets, using %s of memory\n", count,
- mtype_memstr(memstrbuf, sizeof(memstrbuf),
- count * sizeof(struct hash_bucket)));
if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP)))
vty_out(vty, "%ld compiled regexes, using %s of memory\n",
count, mtype_memstr(memstrbuf, sizeof(memstrbuf),
diff --git a/doc/developer/memtypes.rst b/doc/developer/memtypes.rst
index 153131bab..13f6b43bb 100644
--- a/doc/developer/memtypes.rst
+++ b/doc/developer/memtypes.rst
@@ -42,6 +42,16 @@ Example:
Definition
----------
+.. c:type:: struct memtype
+
+ This is the (internal) type used for MTYPE definitions. The macros below
+ should be used to create these, but in some cases it is useful to pass a
+ ``struct memtype *`` pointer to some helper function.
+
+ The ``MTYPE_name`` created by the macros is declared as an array, i.e.
+ a function taking a ``struct memtype *`` argument can be called with an
+ ``MTYPE_name`` argument (as opposed to ``&MTYPE_name``.)
+
.. c:macro:: DECLARE_MGROUP(name)
This macro forward-declares a memory group and should be placed in a
diff --git a/lib/command.c b/lib/command.c
index eb7ee5233..f257c7d0f 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -48,7 +48,7 @@
#include "lib_errors.h"
#include "northbound_cli.h"
-DEFINE_MTYPE(LIB, HOST, "Host config")
+DEFINE_MTYPE_STATIC(LIB, HOST, "Host config")
DEFINE_MTYPE(LIB, COMPLETION, "Completion item")
#define item(x) \
diff --git a/lib/command.h b/lib/command.h
index cc4c5d52f..fd8b56d62 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -34,7 +34,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(HOST)
DECLARE_MTYPE(COMPLETION)
/*
diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c
index 2a18e5cfc..e588571c0 100644
--- a/lib/frr_pthread.c
+++ b/lib/frr_pthread.c
@@ -28,8 +28,8 @@
#include "memory.h"
#include "linklist.h"
-DEFINE_MTYPE(LIB, FRR_PTHREAD, "FRR POSIX Thread");
-DEFINE_MTYPE(LIB, PTHREAD_PRIM, "POSIX synchronization primitives");
+DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread")
+DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives")
/* default frr_pthread start/stop routine prototypes */
static void *fpt_run(void *arg);
diff --git a/lib/frr_pthread.h b/lib/frr_pthread.h
index 9bc7b9403..3afe7ba96 100644
--- a/lib/frr_pthread.h
+++ b/lib/frr_pthread.h
@@ -29,9 +29,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(FRR_PTHREAD);
-DECLARE_MTYPE(PTHREAD_PRIM);
-
#define OS_THREAD_NAMELEN 16
struct frr_pthread;
diff --git a/lib/hash.c b/lib/hash.c
index fad7de513..9d9d39702 100644
--- a/lib/hash.c
+++ b/lib/hash.c
@@ -29,8 +29,8 @@
#include "command.h"
#include "libfrr.h"
-DEFINE_MTYPE(LIB, HASH, "Hash")
-DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket")
+DEFINE_MTYPE_STATIC(LIB, HASH, "Hash")
+DEFINE_MTYPE_STATIC(LIB, HASH_BACKET, "Hash Bucket")
DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index")
static pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER;
diff --git a/lib/hash.h b/lib/hash.h
index c56a98d50..7b3372d43 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -28,9 +28,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(HASH)
-DECLARE_MTYPE(HASH_BACKET)
-
/* Default hash table size. */
#define HASH_INITIAL_SIZE 256
/* Expansion threshold */
diff --git a/lib/if.c b/lib/if.c
index 4314252d7..f7a167f25 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -39,7 +39,7 @@
#include "lib/if_clippy.c"
#endif
-DEFINE_MTYPE(LIB, IF, "Interface")
+DEFINE_MTYPE_STATIC(LIB, IF, "Interface")
DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected")
DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected")
DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
diff --git a/lib/if.h b/lib/if.h
index 2dc1a7b2d..603c9c378 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -31,7 +31,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(IF)
DECLARE_MTYPE(CONNECTED_LABEL)
/* Interface link-layer type, if known. Derived from:
diff --git a/lib/memory.h b/lib/memory.h
index 0002ea334..28c3bb752 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -102,9 +102,14 @@ struct memgroup {
}
+/* the array is a trick to make the "MTYPE_FOO" name work as a pointer without
+ * putting a & in front of it, so we can do "XMALLOC(MTYPE_FOO, ...)" instead
+ * of "XMALLOC(&MTYPE_FOO, ...)".
+ */
#define DECLARE_MTYPE(name) \
extern struct memtype _mt_##name; \
- static struct memtype *const MTYPE_##name = &_mt_##name;
+ extern struct memtype MTYPE_##name[1]; \
+ /* end */
#define DEFINE_MTYPE_ATTR(group, mname, attr, desc) \
attr struct memtype _mt_##mname \
@@ -130,12 +135,20 @@ struct memgroup {
if (_mt_##mname.next) \
_mt_##mname.next->ref = _mt_##mname.ref; \
*_mt_##mname.ref = _mt_##mname.next; \
- }
-
-#define DEFINE_MTYPE(group, name, desc) DEFINE_MTYPE_ATTR(group, name, , desc)
+ } \
+ /* end */
+
+/* can't quite get gcc to emit the alias correctly, so asm-alias it is :/ */
+#define DEFINE_MTYPE(group, name, desc) \
+ DEFINE_MTYPE_ATTR(group, name, , desc) \
+ __asm__(".equiv MTYPE_" #name ", _mt_" #name "\n\t" \
+ ".global MTYPE_" #name "\n"); \
+ /* end */
#define DEFINE_MTYPE_STATIC(group, name, desc) \
DEFINE_MTYPE_ATTR(group, name, static, desc) \
- static struct memtype *const MTYPE_##name = &_mt_##name;
+ static struct memtype MTYPE_##name[1] \
+ __attribute__((alias("_mt_" #name))); \
+ /* end */
DECLARE_MGROUP(LIB)
DECLARE_MTYPE(TMP)
diff --git a/lib/table.c b/lib/table.c
index 728615c77..1a89a95f4 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -28,7 +28,7 @@
#include "memory.h"
#include "sockunion.h"
-DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table")
+DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table")
DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
static void route_table_free(struct route_table *);
diff --git a/lib/table.h b/lib/table.h
index eefd99254..57b65ac4b 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -31,7 +31,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(ROUTE_TABLE)
DECLARE_MTYPE(ROUTE_NODE)
/*
diff --git a/lib/yang.c b/lib/yang.c
index 2f9a9aa5a..674f3610d 100644
--- a/lib/yang.c
+++ b/lib/yang.c
@@ -27,8 +27,8 @@
#include <libyang/user_types.h>
-DEFINE_MTYPE(LIB, YANG_MODULE, "YANG module")
-DEFINE_MTYPE(LIB, YANG_DATA, "YANG data structure")
+DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module")
+DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure")
/* libyang container. */
struct ly_ctx *ly_native_ctx;
diff --git a/lib/yang.h b/lib/yang.h
index 6f8c84ab6..322c74c76 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -33,9 +33,6 @@
extern "C" {
#endif
-DECLARE_MTYPE(YANG_MODULE)
-DECLARE_MTYPE(YANG_DATA)
-
/* Maximum XPath length. */
#define XPATH_MAXLEN 256
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 634fee0b3..80561f350 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -43,6 +43,8 @@
#include "ripd/rip_debug.h"
#include "ripd/rip_interface.h"
+DEFINE_MTYPE_STATIC(RIPD, RIP_INTERFACE, "RIP interface")
+DEFINE_MTYPE(RIPD, RIP_INTERFACE_STRING, "RIP Interface String")
DEFINE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
DEFINE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
diff --git a/ripd/rip_interface.h b/ripd/rip_interface.h
index 6befda0e2..715daf2e5 100644
--- a/ripd/rip_interface.h
+++ b/ripd/rip_interface.h
@@ -20,8 +20,11 @@
#ifndef _QUAGGA_RIP_INTERFACE_H
#define _QUAGGA_RIP_INTERFACE_H
+#include "memory.h"
#include "zclient.h"
+DECLARE_MTYPE(RIP_INTERFACE_STRING)
+
extern int rip_interface_down(int, struct zclient *, zebra_size_t, vrf_id_t);
extern int rip_interface_up(int, struct zclient *, zebra_size_t, vrf_id_t);
extern int rip_interface_add(int, struct zclient *, zebra_size_t, vrf_id_t);
diff --git a/ripd/rip_memory.c b/ripd/rip_memory.c
deleted file mode 100644
index 7d703a86d..000000000
--- a/ripd/rip_memory.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ripd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "rip_memory.h"
-
-DEFINE_MGROUP(RIPD, "ripd")
-DEFINE_MTYPE(RIPD, RIP, "RIP structure")
-DEFINE_MTYPE(RIPD, RIP_VRF_NAME, "RIP VRF name")
-DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info")
-DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface")
-DEFINE_MTYPE(RIPD, RIP_INTERFACE_STRING, "RIP Interface String")
-DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer")
-DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list")
-DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance")
diff --git a/ripd/rip_memory.h b/ripd/rip_memory.h
deleted file mode 100644
index 1f9d8f500..000000000
--- a/ripd/rip_memory.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ripd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef _QUAGGA_RIP_MEMORY_H
-#define _QUAGGA_RIP_MEMORY_H
-
-#include "memory.h"
-
-DECLARE_MGROUP(RIPD)
-DECLARE_MTYPE(RIP)
-DECLARE_MTYPE(RIP_VRF_NAME)
-DECLARE_MTYPE(RIP_INFO)
-DECLARE_MTYPE(RIP_INTERFACE)
-DECLARE_MTYPE(RIP_INTERFACE_STRING)
-DECLARE_MTYPE(RIP_PEER)
-DECLARE_MTYPE(RIP_OFFSET_LIST)
-DECLARE_MTYPE(RIP_DISTANCE)
-
-#endif /* _QUAGGA_RIP_MEMORY_H */
diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c
index f8a7f5dc6..1238d0f0f 100644
--- a/ripd/rip_northbound.c
+++ b/ripd/rip_northbound.c
@@ -33,6 +33,7 @@
#include "ripd/ripd.h"
#include "ripd/rip_debug.h"
#include "ripd/rip_cli.h"
+#include "ripd/rip_interface.h"
/*
* XPath: /frr-ripd:ripd/instance
diff --git a/ripd/rip_offset.c b/ripd/rip_offset.c
index 8307a95d2..776f121d5 100644
--- a/ripd/rip_offset.c
+++ b/ripd/rip_offset.c
@@ -29,6 +29,8 @@
#include "ripd/ripd.h"
+DEFINE_MTYPE_STATIC(RIPD, RIP_OFFSET_LIST, "RIP offset list")
+
#define OFFSET_LIST_IN_NAME(O) ((O)->direct[RIP_OFFSET_LIST_IN].alist_name)
#define OFFSET_LIST_IN_METRIC(O) ((O)->direct[RIP_OFFSET_LIST_IN].metric)
diff --git a/ripd/rip_peer.c b/ripd/rip_peer.c
index 08aa61257..4ad7309c4 100644
--- a/ripd/rip_peer.c
+++ b/ripd/rip_peer.c
@@ -29,6 +29,8 @@
#include "ripd/ripd.h"
+DEFINE_MTYPE_STATIC(RIPD, RIP_PEER, "RIP peer")
+
static struct rip_peer *rip_peer_new(void)
{
return XCALLOC(MTYPE_RIP_PEER, sizeof(struct rip_peer));
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 3a1ffd17a..e0ff0430f 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -51,6 +51,12 @@
/* UDP receive buffer size */
#define RIP_UDP_RCV_BUF 41600
+DEFINE_MGROUP(RIPD, "ripd")
+DEFINE_MTYPE_STATIC(RIPD, RIP, "RIP structure")
+DEFINE_MTYPE_STATIC(RIPD, RIP_VRF_NAME, "RIP VRF name")
+DEFINE_MTYPE_STATIC(RIPD, RIP_INFO, "RIP route info")
+DEFINE_MTYPE_STATIC(RIPD, RIP_DISTANCE, "RIP distance")
+
/* Prototypes. */
static void rip_output_process(struct connected *, struct sockaddr_in *, int,
uint8_t);
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 44f5932fb..7f2c3fd06 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -24,7 +24,7 @@
#include "hook.h"
#include "nexthop.h"
#include "distribute.h"
-#include "rip_memory.h"
+#include "memory.h"
/* RIP version number. */
#define RIPv1 1
@@ -97,6 +97,8 @@
#define RIP_INSTANCE "/frr-ripd:ripd/instance"
#define RIP_IFACE "/frr-interface:lib/interface/frr-ripd:rip"
+DECLARE_MGROUP(RIPD)
+
/* RIP structure. */
struct rip {
RB_ENTRY(rip) entry;
diff --git a/ripd/subdir.am b/ripd/subdir.am
index 2a63cc522..312c1db6a 100644
--- a/ripd/subdir.am
+++ b/ripd/subdir.am
@@ -23,7 +23,6 @@ ripd_librip_a_SOURCES = \
ripd/rip_debug.c \
ripd/rip_errors.c \
ripd/rip_interface.c \
- ripd/rip_memory.c \
ripd/rip_offset.c \
ripd/rip_northbound.c \
ripd/rip_peer.c \
@@ -40,7 +39,6 @@ noinst_HEADERS += \
ripd/rip_debug.h \
ripd/rip_errors.h \
ripd/rip_interface.h \
- ripd/rip_memory.h \
ripd/ripd.h \
# end
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index d83f4d279..49ed13a2c 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -49,6 +49,8 @@
#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
#endif
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_IF, "ripng interface")
+
/* Static utility function. */
static void ripng_enable_apply(struct interface *);
static void ripng_passive_interface_apply(struct interface *);
@@ -913,7 +915,7 @@ static struct ripng_interface *ri_new(void)
{
struct ripng_interface *ri;
- ri = XCALLOC(MTYPE_IF, sizeof(struct ripng_interface));
+ ri = XCALLOC(MTYPE_RIPNG_IF, sizeof(struct ripng_interface));
/* Set default split-horizon behavior. If the interface is Frame
Relay or SMDS is enabled, the default value for split-horizon is
@@ -950,7 +952,7 @@ static int ripng_if_new_hook(struct interface *ifp)
/* Called when interface structure deleted. */
static int ripng_if_delete_hook(struct interface *ifp)
{
- XFREE(MTYPE_IF, ifp->info);
+ XFREE(MTYPE_RIPNG_IF, ifp->info);
ifp->info = NULL;
return 0;
}
diff --git a/ripngd/ripng_memory.c b/ripngd/ripng_memory.c
deleted file mode 100644
index f459566be..000000000
--- a/ripngd/ripng_memory.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ripngd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ripng_memory.h"
-
-DEFINE_MGROUP(RIPNGD, "ripngd")
-DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure")
-DEFINE_MTYPE(RIPNGD, RIPNG_VRF_NAME, "RIPng VRF name")
-DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info")
-DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate")
-DEFINE_MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer")
-DEFINE_MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst")
-DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data")
diff --git a/ripngd/ripng_memory.h b/ripngd/ripng_memory.h
deleted file mode 100644
index 3dfc57b3f..000000000
--- a/ripngd/ripng_memory.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ripngd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef _QUAGGA_RIPNG_MEMORY_H
-#define _QUAGGA_RIPNG_MEMORY_H
-
-#include "memory.h"
-
-DECLARE_MGROUP(RIPNGD)
-DECLARE_MTYPE(RIPNG)
-DECLARE_MTYPE(RIPNG_VRF_NAME)
-DECLARE_MTYPE(RIPNG_ROUTE)
-DECLARE_MTYPE(RIPNG_AGGREGATE)
-DECLARE_MTYPE(RIPNG_PEER)
-DECLARE_MTYPE(RIPNG_OFFSET_LIST)
-DECLARE_MTYPE(RIPNG_RTE_DATA)
-
-#endif /* _QUAGGA_RIPNG_MEMORY_H */
diff --git a/ripngd/ripng_nexthop.c b/ripngd/ripng_nexthop.c
index 882c2fbc8..ba6e52fdd 100644
--- a/ripngd/ripng_nexthop.c
+++ b/ripngd/ripng_nexthop.c
@@ -39,6 +39,8 @@
#include "ripngd/ripng_debug.h"
#include "ripngd/ripng_nexthop.h"
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data")
+
#define DEBUG 1
#define min(a, b) ((a) < (b) ? (a) : (b))
diff --git a/ripngd/ripng_offset.c b/ripngd/ripng_offset.c
index fe95ccfc2..0094c993a 100644
--- a/ripngd/ripng_offset.c
+++ b/ripngd/ripng_offset.c
@@ -33,6 +33,8 @@
#include "ripngd/ripngd.h"
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst")
+
#define OFFSET_LIST_IN_NAME(O) ((O)->direct[RIPNG_OFFSET_LIST_IN].alist_name)
#define OFFSET_LIST_IN_METRIC(O) ((O)->direct[RIPNG_OFFSET_LIST_IN].metric)
diff --git a/ripngd/ripng_peer.c b/ripngd/ripng_peer.c
index 537600774..109524e21 100644
--- a/ripngd/ripng_peer.c
+++ b/ripngd/ripng_peer.c
@@ -34,6 +34,8 @@
#include "ripngd/ripngd.h"
#include "ripngd/ripng_nexthop.h"
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_PEER, "RIPng peer")
+
static struct ripng_peer *ripng_peer_new(void)
{
return XCALLOC(MTYPE_RIPNG_PEER, sizeof(struct ripng_peer));
diff --git a/ripngd/ripng_route.c b/ripngd/ripng_route.c
index 1bf1007fe..ed9d77a37 100644
--- a/ripngd/ripng_route.c
+++ b/ripngd/ripng_route.c
@@ -30,6 +30,8 @@
#include "ripngd/ripngd.h"
#include "ripngd/ripng_route.h"
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate")
+
static struct ripng_aggregate *ripng_aggregate_new(void)
{
struct ripng_aggregate *new;
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index 71bc43049..3314892e7 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -43,6 +43,11 @@
#include "ripngd/ripng_debug.h"
#include "ripngd/ripng_nexthop.h"
+DEFINE_MGROUP(RIPNGD, "ripngd")
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG, "RIPng structure")
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_VRF_NAME, "RIPng VRF name")
+DEFINE_MTYPE_STATIC(RIPNGD, RIPNG_ROUTE, "RIPng route info")
+
enum { ripng_all_route,
ripng_changed_route,
};
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index a2686304f..5a0d350a8 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -26,8 +26,7 @@
#include <vty.h>
#include <distribute.h>
#include <vector.h>
-
-#include "ripng_memory.h"
+#include <memory.h>
/* RIPng version and port number. */
#define RIPNG_V1 1
@@ -87,6 +86,8 @@
#define RIPNG_INSTANCE "/frr-ripngd:ripngd/instance"
#define RIPNG_IFACE "/frr-interface:lib/interface/frr-ripngd:ripng"
+DECLARE_MGROUP(RIPNGD)
+
/* RIPng structure. */
struct ripng {
RB_ENTRY(ripng) entry;
diff --git a/ripngd/subdir.am b/ripngd/subdir.am
index ea0ccf148..eac0d6731 100644
--- a/ripngd/subdir.am
+++ b/ripngd/subdir.am
@@ -17,7 +17,6 @@ ripngd_libripng_a_SOURCES = \
ripngd/ripng_cli.c \
ripngd/ripng_debug.c \
ripngd/ripng_interface.c \
- ripngd/ripng_memory.c \
ripngd/ripng_nexthop.c \
ripngd/ripng_offset.c \
ripngd/ripng_northbound.c \
@@ -34,7 +33,6 @@ ripngd/ripng_cli.$(OBJEXT): ripngd/ripng_cli_clippy.c
noinst_HEADERS += \
ripngd/ripng_cli.h \
ripngd/ripng_debug.h \
- ripngd/ripng_memory.h \
ripngd/ripng_nexthop.h \
ripngd/ripng_route.h \
ripngd/ripngd.h \
diff --git a/vrrpd/subdir.am b/vrrpd/subdir.am
index a328f969d..57eec108c 100644
--- a/vrrpd/subdir.am
+++ b/vrrpd/subdir.am
@@ -14,7 +14,6 @@ vrrpd_libvrrp_a_SOURCES = \
vrrpd/vrrp.c \
vrrpd/vrrp_arp.c \
vrrpd/vrrp_debug.c \
- vrrpd/vrrp_memory.c \
vrrpd/vrrp_ndisc.c \
vrrpd/vrrp_packet.c \
vrrpd/vrrp_vty.c \
@@ -25,7 +24,6 @@ noinst_HEADERS += \
vrrpd/vrrp.h \
vrrpd/vrrp_arp.h \
vrrpd/vrrp_debug.h \
- vrrpd/vrrp_memory.h \
vrrpd/vrrp_ndisc.h \
vrrpd/vrrp_packet.h \
vrrpd/vrrp_vty.h \
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index 3d535cbfb..5213b27d3 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -34,13 +34,15 @@
#include "vrrp.h"
#include "vrrp_arp.h"
#include "vrrp_debug.h"
-#include "vrrp_memory.h"
#include "vrrp_ndisc.h"
#include "vrrp_packet.h"
#include "vrrp_zebra.h"
#define VRRP_LOGPFX "[CORE] "
+DEFINE_MTYPE_STATIC(VRRPD, VRRP_IP, "VRRP IP address")
+DEFINE_MTYPE_STATIC(VRRPD, VRRP_RTR, "VRRP Router")
+
/* statics */
struct hash *vrrp_vrouters_hash;
bool vrrp_autoconfig_is_on;
@@ -768,7 +770,7 @@ static void vrrp_send_advertisement(struct vrrp_router *r)
ssize_t sent = sendto(r->sock_tx, pkt, (size_t)pktsz, 0, &dest.sa,
sockunion_sizeof(&dest));
- XFREE(MTYPE_VRRP_PKT, pkt);
+ vrrp_pkt_free(pkt);
if (sent < 0) {
zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
diff --git a/vrrpd/vrrp.h b/vrrpd/vrrp.h
index fd4901fe2..5d355d04b 100644
--- a/vrrpd/vrrp.h
+++ b/vrrpd/vrrp.h
@@ -23,6 +23,7 @@
#include <zebra.h>
#include <netinet/ip.h>
+#include "lib/memory.h"
#include "lib/hash.h"
#include "lib/hook.h"
#include "lib/if.h"
@@ -54,6 +55,8 @@
/* User compatibility constant */
#define CS2MS 10
+DECLARE_MGROUP(VRRPD)
+
/* Configured defaults */
struct vrrp_defaults {
uint8_t priority;
diff --git a/vrrpd/vrrp_main.c b/vrrpd/vrrp_main.c
index 46a92d936..6c6a06064 100644
--- a/vrrpd/vrrp_main.c
+++ b/vrrpd/vrrp_main.c
@@ -39,6 +39,8 @@
#include "vrrp_vty.h"
#include "vrrp_zebra.h"
+DEFINE_MGROUP(VRRPD, "vrrpd")
+
char backup_config_file[256];
zebra_capabilities_t _caps_p[] = {
diff --git a/vrrpd/vrrp_memory.c b/vrrpd/vrrp_memory.c
deleted file mode 100644
index 30eef523c..000000000
--- a/vrrpd/vrrp_memory.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * VRRP memory types.
- * Copyright (C) 2018-2019 Cumulus Networks, Inc.
- * Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include <zebra.h>
-
-#include "lib/memory.h"
-
-#include "vrrp_memory.h"
-
-DEFINE_MGROUP(VRRPD, "vrrpd");
-DEFINE_MTYPE(VRRPD, VRRP_IP, "VRRP IP address");
-DEFINE_MTYPE(VRRPD, VRRP_PKT, "VRRP packet");
-DEFINE_MTYPE(VRRPD, VRRP_RTR, "VRRP Router");
diff --git a/vrrpd/vrrp_memory.h b/vrrpd/vrrp_memory.h
deleted file mode 100644
index c3025d1ac..000000000
--- a/vrrpd/vrrp_memory.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * VRRP memory types.
- * Copyright (C) 2018-2019 Cumulus Networks, Inc.
- * Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#ifndef __VRRP_MEMORY_H__
-#define __VRRP_MEMORY_H__
-
-#include <zebra.h>
-
-#include "lib/memory.h"
-
-DECLARE_MGROUP(VRRPD);
-DECLARE_MTYPE(VRRP_IP);
-DECLARE_MTYPE(VRRP_PKT);
-DECLARE_MTYPE(VRRP_RTR);
-
-#endif /* __VRRP_MEMORY_H__ */
diff --git a/vrrpd/vrrp_packet.c b/vrrpd/vrrp_packet.c
index c3f2afba4..c6b7ac1a7 100644
--- a/vrrpd/vrrp_packet.c
+++ b/vrrpd/vrrp_packet.c
@@ -28,9 +28,10 @@
#include "vrrp.h"
#include "vrrp_debug.h"
-#include "vrrp_memory.h"
#include "vrrp_packet.h"
+DEFINE_MTYPE_STATIC(VRRPD, VRRP_PKT, "VRRP packet")
+
/* clang-format off */
const char *vrrp_packet_names[16] = {
[0] = "Unknown",
@@ -151,6 +152,11 @@ ssize_t vrrp_pkt_adver_build(struct vrrp_pkt **pkt, struct ipaddr *src,
return pktsize;
}
+void vrrp_pkt_free(struct vrrp_pkt *pkt)
+{
+ XFREE(MTYPE_VRRP_PKT, pkt);
+}
+
size_t vrrp_pkt_adver_dump(char *buf, size_t buflen, struct vrrp_pkt *pkt)
{
if (buflen < 1)
diff --git a/vrrpd/vrrp_packet.h b/vrrpd/vrrp_packet.h
index 475e4780d..c2ce22f00 100644
--- a/vrrpd/vrrp_packet.h
+++ b/vrrpd/vrrp_packet.h
@@ -135,6 +135,9 @@ ssize_t vrrp_pkt_adver_build(struct vrrp_pkt **pkt, struct ipaddr *src,
uint16_t max_adver_int, uint8_t numip,
struct ipaddr **ips);
+/* free memory allocated by vrrp_pkt_adver_build's pkt arg */
+void vrrp_pkt_free(struct vrrp_pkt *pkt);
+
/*
* Dumps a VRRP ADVERTISEMENT packet to a string.
*
diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c
index 48d81b025..2dc3d3f8a 100644
--- a/vrrpd/vrrp_vty.c
+++ b/vrrpd/vrrp_vty.c
@@ -29,7 +29,6 @@
#include "vrrp.h"
#include "vrrp_debug.h"
-#include "vrrp_memory.h"
#include "vrrp_vty.h"
#ifndef VTYSH_EXTRACT_PL
#include "vrrpd/vrrp_vty_clippy.c"
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index e181b495b..5841c44b0 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -50,6 +50,8 @@ extern struct zebra_privs_t zserv_privs;
#if defined(HAVE_RTADV)
+DEFINE_MTYPE_STATIC(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
+
#ifdef OPEN_BSD
#include <netinet/icmp6.h>
#endif
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index abe1879c2..f93562b31 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -36,8 +36,8 @@
#include "zebra/debug.h"
/* Memory type for context blocks */
-DEFINE_MTYPE(ZEBRA, DP_CTX, "Zebra DPlane Ctx")
-DEFINE_MTYPE(ZEBRA, DP_PROV, "Zebra DPlane Provider")
+DEFINE_MTYPE_STATIC(ZEBRA, DP_CTX, "Zebra DPlane Ctx")
+DEFINE_MTYPE_STATIC(ZEBRA, DP_PROV, "Zebra DPlane Provider")
#ifndef AOK
# define AOK 0
diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c
index ee041b1c3..a9c2c5fe5 100644
--- a/zebra/zebra_memory.c
+++ b/zebra/zebra_memory.c
@@ -26,11 +26,5 @@
#include "zebra_memory.h"
DEFINE_MGROUP(ZEBRA, "zebra")
-DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
-DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
DEFINE_MTYPE(ZEBRA, RE, "Route Entry")
-DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue")
-DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route")
DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination")
-DEFINE_MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info")
-DEFINE_MTYPE(ZEBRA, RNH, "Nexthop tracking object")
diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h
index 667c73b22..e15f97249 100644
--- a/zebra/zebra_memory.h
+++ b/zebra/zebra_memory.h
@@ -29,17 +29,9 @@ extern "C" {
#endif
DECLARE_MGROUP(ZEBRA)
-DECLARE_MTYPE(RTADV_PREFIX)
DECLARE_MTYPE(ZEBRA_NS)
-DECLARE_MTYPE(ZEBRA_VRF)
DECLARE_MTYPE(RE)
-DECLARE_MTYPE(RIB_QUEUE)
-DECLARE_MTYPE(STATIC_ROUTE)
DECLARE_MTYPE(RIB_DEST)
-DECLARE_MTYPE(RIB_TABLE_INFO)
-DECLARE_MTYPE(RNH)
-DECLARE_MTYPE(DP_CTX)
-DECLARE_MTYPE(DP_PROV)
#ifdef __cplusplus
}
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index 0a8dbfdde..5f397eb8c 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -50,6 +50,8 @@
#include "zebra/zebra_memory.h"
#include "zebra/zebra_errors.h"
+DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object")
+
static void free_state(vrf_id_t vrf_id, struct route_entry *re,
struct route_node *rn);
static void copy_state(struct rnh *rnh, struct route_entry *re,
diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c
index 4352d688a..1e9f9e4ec 100644
--- a/zebra/zebra_router.c
+++ b/zebra/zebra_router.c
@@ -32,6 +32,8 @@
#include "zebra_nhg.h"
#include "debug.h"
+DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info")
+
struct zebra_router zrouter = {
.multipath_num = MULTIPATH_NUM,
.ipv4_multicast_mode = MCAST_NO_CONFIG,
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index fdf0cbc69..fcc94a7be 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -48,7 +48,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
static void zebra_rnhtable_node_cleanup(struct route_table *table,
struct route_node *node);
-DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table");
+DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
+DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table")
/* VRF information update. */
static void zebra_vrf_add_update(struct zebra_vrf *zvrf)