Merge pull request #4573 from opensourcerouting/mtype_cleanup

MTYPE cleanup pass
This commit is contained in:
Donald Sharp 2019-06-21 07:40:27 -04:00 committed by GitHub
commit 2bc398c3c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 126 additions and 355 deletions

View File

@ -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);

View File

@ -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")

View File

@ -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 */

View File

@ -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);

View File

@ -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 \

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -30,6 +30,8 @@
#include "bfd.h"
DEFINE_MTYPE_STATIC(BFDD, BFDD_LABEL, "long-lived label memory")
/*
* Definitions
*/

View File

@ -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),

View File

@ -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

View File

@ -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) \

View File

@ -34,7 +34,6 @@
extern "C" {
#endif
DECLARE_MTYPE(HOST)
DECLARE_MTYPE(COMPLETION)
/*

View File

@ -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);

View File

@ -29,9 +29,6 @@
extern "C" {
#endif
DECLARE_MTYPE(FRR_PTHREAD);
DECLARE_MTYPE(PTHREAD_PRIM);
#define OS_THREAD_NAMELEN 16
struct frr_pthread;

View File

@ -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;

View File

@ -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 */

View File

@ -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")

View File

@ -31,7 +31,6 @@
extern "C" {
#endif
DECLARE_MTYPE(IF)
DECLARE_MTYPE(CONNECTED_LABEL)
/* Interface link-layer type, if known. Derived from:

View File

@ -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; \
}
} \
/* end */
#define DEFINE_MTYPE(group, name, desc) DEFINE_MTYPE_ATTR(group, name, , desc)
/* 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)

View File

@ -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 *);

View File

@ -31,7 +31,6 @@
extern "C" {
#endif
DECLARE_MTYPE(ROUTE_TABLE)
DECLARE_MTYPE(ROUTE_NODE)
/*

View File

@ -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;

View File

@ -33,9 +33,6 @@
extern "C" {
#endif
DECLARE_MTYPE(YANG_MODULE)
DECLARE_MTYPE(YANG_DATA)
/* Maximum XPath length. */
#define XPATH_MAXLEN 256

View File

@ -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))

View File

@ -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);

View File

@ -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")

View File

@ -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 */

View File

@ -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

View File

@ -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)

View File

@ -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));

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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")

View File

@ -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 */

View File

@ -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))

View File

@ -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)

View File

@ -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));

View File

@ -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;

View File

@ -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,
};

View File

@ -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;

View File

@ -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 \

View File

@ -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 \

View File

@ -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

View File

@ -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;

View File

@ -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[] = {

View File

@ -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");

View File

@ -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__ */

View File

@ -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)

View File

@ -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.
*

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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
}

View File

@ -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,

View File

@ -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,

View File

@ -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)