diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2015-05-29 05:48:31 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-09-19 22:31:04 +0200 |
commit | 4a1ab8e4050a141d3d7a80b5f8bb27dfd045dae8 (patch) | |
tree | 14b33d958cb88df6195994c78ee74b781e7968a6 /lib | |
parent | lib: migrate to new memory-type handling (diff) | |
download | frr-4a1ab8e4050a141d3d7a80b5f8bb27dfd045dae8.tar.xz frr-4a1ab8e4050a141d3d7a80b5f8bb27dfd045dae8.zip |
*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.
The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.
bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use. This is bad practice and would break when the
memtype are made static.
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/.gitignore | 1 | ||||
-rw-r--r-- | lib/Makefile.am | 10 | ||||
-rw-r--r-- | lib/bfd.c | 2 | ||||
-rw-r--r-- | lib/buffer.c | 3 | ||||
-rw-r--r-- | lib/command.c | 4 | ||||
-rw-r--r-- | lib/command.h | 6 | ||||
-rw-r--r-- | lib/distribute.c | 4 | ||||
-rw-r--r-- | lib/filter.c | 4 | ||||
-rw-r--r-- | lib/hash.c | 4 | ||||
-rw-r--r-- | lib/hash.h | 5 | ||||
-rw-r--r-- | lib/if.c | 6 | ||||
-rw-r--r-- | lib/if.h | 4 | ||||
-rw-r--r-- | lib/if_rmap.c | 3 | ||||
-rw-r--r-- | lib/keychain.c | 3 | ||||
-rw-r--r-- | lib/linklist.c | 3 | ||||
-rw-r--r-- | lib/log.c | 2 | ||||
-rw-r--r-- | lib/memory.c | 3 | ||||
-rw-r--r-- | lib/memory.h | 5 | ||||
-rw-r--r-- | lib/memtypes.c | 292 | ||||
-rwxr-xr-x | lib/memtypes.pl | 6 | ||||
-rw-r--r-- | lib/nexthop.c | 2 | ||||
-rw-r--r-- | lib/ns.c | 3 | ||||
-rw-r--r-- | lib/plist.c | 9 | ||||
-rw-r--r-- | lib/pqueue.c | 3 | ||||
-rw-r--r-- | lib/prefix.c | 2 | ||||
-rw-r--r-- | lib/privs.c | 3 | ||||
-rw-r--r-- | lib/routemap.c | 8 | ||||
-rw-r--r-- | lib/routemap.h | 4 | ||||
-rw-r--r-- | lib/sockunion.c | 2 | ||||
-rw-r--r-- | lib/stream.c | 4 | ||||
-rw-r--r-- | lib/table.c | 3 | ||||
-rw-r--r-- | lib/table.h | 3 | ||||
-rw-r--r-- | lib/thread.c | 4 | ||||
-rw-r--r-- | lib/vector.c | 3 | ||||
-rw-r--r-- | lib/vector.h | 3 | ||||
-rw-r--r-- | lib/vrf.c | 3 | ||||
-rw-r--r-- | lib/vty.c | 4 | ||||
-rw-r--r-- | lib/workqueue.c | 4 | ||||
-rw-r--r-- | lib/workqueue.h | 3 | ||||
-rw-r--r-- | lib/zclient.c | 2 |
40 files changed, 131 insertions, 311 deletions
diff --git a/lib/.gitignore b/lib/.gitignore index a25bae5aa..fe75137bc 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -14,6 +14,5 @@ gitversion.h.tmp .arch-ids *~ *.loT -memtypes.h route_types.h refix diff --git a/lib/Makefile.am b/lib/Makefile.am index 7a2151151..dbb80076c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,10 +13,10 @@ libzebra_la_SOURCES = \ sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \ filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ zclient.c sockopt.c smux.c agentx.c snmp.c md5.c if_rmap.c keychain.c privs.c \ - sigevent.c pqueue.c jhash.c memtypes.c workqueue.c nexthop.c json.c \ + sigevent.c pqueue.c jhash.c workqueue.c nexthop.c json.c \ ptm_lib.c csv.c bfd.c vrf.c systemd.c ns.c memory.c memory_vty.c -BUILT_SOURCES = memtypes.h route_types.h gitversion.h +BUILT_SOURCES = route_types.h gitversion.h libzebra_la_DEPENDENCIES = @LIB_REGEX@ @@ -28,7 +28,7 @@ pkginclude_HEADERS = \ memory.h network.h prefix.h routemap.h distribute.h sockunion.h \ str.h stream.h table.h thread.h vector.h version.h vty.h zebra.h \ plist.h zclient.h sockopt.h smux.h md5.h if_rmap.h keychain.h \ - privs.h sigevent.h pqueue.h jhash.h zassert.h memtypes.h \ + privs.h sigevent.h pqueue.h jhash.h zassert.h \ workqueue.h route_types.h libospf.h nexthop.h json.h \ ptm_lib.h csv.h bfd.h vrf.h ns.h systemd.h bitfield.h \ fifo.h memory_vty.h @@ -39,13 +39,9 @@ noinst_HEADERS = \ EXTRA_DIST = \ regex.c regex-gnu.h \ queue.h \ - memtypes.pl \ route_types.pl route_types.txt \ gitversion.pl -memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.pl - @PERL@ $(srcdir)/memtypes.pl < $(srcdir)/memtypes.c > $@ - route_types.h: $(srcdir)/route_types.txt $(srcdir)/route_types.pl @PERL@ $(srcdir)/route_types.pl < $(srcdir)/route_types.txt > $@ @@ -33,6 +33,8 @@ #include "vty.h" #include "bfd.h" +DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info") + int bfd_debug = 0; struct bfd_gbl bfd_gbl; diff --git a/lib/buffer.c b/lib/buffer.c index ee9310100..1dfcdb473 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -28,7 +28,8 @@ #include "network.h" #include <stddef.h> - +DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer") +DEFINE_MTYPE_STATIC(LIB, BUFFER_DATA, "Buffer data") /* Buffer master. */ struct buffer diff --git a/lib/command.c b/lib/command.c index e67007ae2..cfdb91a5b 100644 --- a/lib/command.c +++ b/lib/command.c @@ -34,6 +34,10 @@ Boston, MA 02111-1307, USA. */ #include "workqueue.h" #include "vrf.h" +DEFINE_MTYPE( LIB, HOST, "Host config") +DEFINE_MTYPE( LIB, STRVEC, "String vector") +DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc") + /* Command vector which includes some level of command lists. Normally each daemon maintains each own cmdvec. */ vector cmdvec = NULL; diff --git a/lib/command.h b/lib/command.h index 0415834b0..9ee4f2db3 100644 --- a/lib/command.h +++ b/lib/command.h @@ -26,6 +26,12 @@ #include "vector.h" #include "vty.h" #include "lib/route_types.h" +#include "memory.h" + +DECLARE_MTYPE(HOST) + +/* for test-commands.c */ +DECLARE_MTYPE(STRVEC) /* Host configuration variable */ struct host diff --git a/lib/distribute.c b/lib/distribute.c index 757525fd7..d0d637fbb 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -28,6 +28,10 @@ #include "distribute.h" #include "memory.h" +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list") +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname") +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name") + /* Hash of distribute list. */ struct hash *disthash; diff --git a/lib/filter.c b/lib/filter.c index 0eeb8f187..e9ba715c9 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -30,6 +30,10 @@ #include "log.h" #include "routemap.h" +DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List") +DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str") +DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter") + struct filter_cisco { /* Cisco access-list */ diff --git a/lib/hash.c b/lib/hash.c index a20093cd6..cb8531fcc 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -24,6 +24,10 @@ #include "hash.h" #include "memory.h" +DEFINE_MTYPE( LIB, HASH, "Hash") +DEFINE_MTYPE( LIB, HASH_BACKET, "Hash Bucket") +DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index") + /* Allocate a new hash. */ struct hash * hash_create_size (unsigned int size, unsigned int (*hash_key) (void *), diff --git a/lib/hash.h b/lib/hash.h index 0bc3089f3..11ecf75ec 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -21,6 +21,11 @@ Boston, MA 02111-1307, USA. */ #ifndef _ZEBRA_HASH_H #define _ZEBRA_HASH_H +#include "memory.h" + +DECLARE_MTYPE(HASH) +DECLARE_MTYPE(HASH_BACKET) + /* Default hash table size. */ #define HASH_INITIAL_SIZE 256 /* initial number of backets. */ #define HASH_THRESHOLD 10 /* expand when backet. */ @@ -37,6 +37,12 @@ #include "str.h" #include "log.h" +DEFINE_MTYPE( 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") +DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters") + /* List of interfaces in only the default VRF */ int ptm_enable = 0; @@ -23,6 +23,10 @@ Boston, MA 02111-1307, USA. */ #include "zebra.h" #include "linklist.h" +#include "memory.h" + +DECLARE_MTYPE(IF) +DECLARE_MTYPE(CONNECTED_LABEL) /* Interface link-layer type, if known. Derived from: * diff --git a/lib/if_rmap.c b/lib/if_rmap.c index f2d76c69d..736f2e237 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -27,6 +27,9 @@ #include "if.h" #include "if_rmap.h" +DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map") +DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name") + struct hash *ifrmaphash; /* Hook functions. */ diff --git a/lib/keychain.c b/lib/keychain.c index c4a007edd..ac2083cf4 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -25,6 +25,9 @@ Boston, MA 02111-1307, USA. */ #include "linklist.h" #include "keychain.h" +DEFINE_MTYPE_STATIC(LIB, KEY, "Key") +DEFINE_MTYPE_STATIC(LIB, KEYCHAIN, "Key chain") + /* Master list of key chain. */ struct list *keychain_list; diff --git a/lib/linklist.c b/lib/linklist.c index d27a2da84..6fe91c75f 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -24,6 +24,9 @@ #include "linklist.h" #include "memory.h" +DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List") +DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node") + /* Allocate new list. */ struct list * list_new (void) @@ -35,6 +35,8 @@ #include <ucontext.h> #endif +DEFINE_MTYPE_STATIC(LIB, ZLOG, "Logging") + static int logfile_fd = -1; /* Used in signal handler. */ struct zlog *zlog_default = NULL; diff --git a/lib/memory.c b/lib/memory.c index 60008d4b5..562b0f589 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -29,6 +29,9 @@ static struct memgroup *mg_first = NULL; struct memgroup **mg_insert = &mg_first; +DEFINE_MGROUP(LIB, "libzebra") +DEFINE_MTYPE(LIB, TMP, "Temporary memory") + static inline void mt_count_alloc (struct memtype *mt, size_t size) { diff --git a/lib/memory.h b/lib/memory.h index e8243f173..2680253d9 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -138,6 +138,9 @@ struct memgroup DEFINE_MTYPE_ATTR(group, name, static, desc) \ static struct memtype * const MTYPE_ ## name = &_mt_##name; +DECLARE_MGROUP(LIB) +DECLARE_MTYPE(TMP) + extern void *qmalloc (struct memtype *mt, size_t size) __attribute__ ((malloc, _ALLOC_SIZE(2), nonnull (1) _RET_NONNULL)); @@ -172,6 +175,4 @@ extern int qmem_walk (qmem_walk_fn *func, void *arg); extern void memory_oom (size_t size, const char *name); -#include "memtypes.h" - #endif /* _QUAGGA_MEMORY_H */ diff --git a/lib/memtypes.c b/lib/memtypes.c deleted file mode 100644 index 4fa64a8cb..000000000 --- a/lib/memtypes.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Memory type definitions. This file is parsed by memtypes.awk to extract - * MTYPE_ and memory_list_.. information in order to autogenerate - * memtypes.h. - * - * The script is sensitive to the format (though not whitespace), see - * the top of memtypes.awk for more details. - */ - -#include "zebra.h" -#include "memory.h" - -DEFINE_MGROUP(LIB, "libzebra") -DEFINE_MTYPE(LIB, TMP, "Temporary memory") -DEFINE_MTYPE(LIB, STRVEC, "String vector") -DEFINE_MTYPE(LIB, VECTOR, "Vector") -DEFINE_MTYPE(LIB, VECTOR_INDEX, "Vector index") -DEFINE_MTYPE(LIB, LINK_LIST, "Link List") -DEFINE_MTYPE(LIB, LINK_NODE, "Link Node") -DEFINE_MTYPE(LIB, THREAD, "Thread") -DEFINE_MTYPE(LIB, THREAD_MASTER, "Thread master") -DEFINE_MTYPE(LIB, THREAD_STATS, "Thread stats") -DEFINE_MTYPE(LIB, VTY, "VTY") -DEFINE_MTYPE(LIB, VTY_OUT_BUF, "VTY output buffer") -DEFINE_MTYPE(LIB, VTY_HIST, "VTY history") -DEFINE_MTYPE(LIB, IF, "Interface") -DEFINE_MTYPE(LIB, CONNECTED, "Connected") -DEFINE_MTYPE(LIB, NBR_CONNECTED, "Neighbor Connected") -DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label") -DEFINE_MTYPE(LIB, BUFFER, "Buffer") -DEFINE_MTYPE(LIB, BUFFER_DATA, "Buffer data") -DEFINE_MTYPE(LIB, STREAM, "Stream") -DEFINE_MTYPE(LIB, STREAM_DATA, "Stream data") -DEFINE_MTYPE(LIB, STREAM_FIFO, "Stream FIFO") -DEFINE_MTYPE(LIB, PREFIX, "Prefix") -DEFINE_MTYPE(LIB, PREFIX_IPV4, "Prefix IPv4") -DEFINE_MTYPE(LIB, PREFIX_IPV6, "Prefix IPv6") -DEFINE_MTYPE(LIB, HASH, "Hash") -DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket") -DEFINE_MTYPE(LIB, HASH_INDEX, "Hash Index") -DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table") -DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node") -DEFINE_MTYPE(LIB, DISTRIBUTE, "Distribute list") -DEFINE_MTYPE(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname") -DEFINE_MTYPE(LIB, DISTRIBUTE_NAME, "Dist-list name") -DEFINE_MTYPE(LIB, ACCESS_LIST, "Access List") -DEFINE_MTYPE(LIB, ACCESS_LIST_STR, "Access List Str") -DEFINE_MTYPE(LIB, ACCESS_FILTER, "Access Filter") -DEFINE_MTYPE(LIB, PREFIX_LIST, "Prefix List") -DEFINE_MTYPE(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") -DEFINE_MTYPE(LIB, PREFIX_LIST_STR, "Prefix List Str") -DEFINE_MTYPE(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table") -DEFINE_MTYPE(LIB, ROUTE_MAP, "Route map") -DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name") -DEFINE_MTYPE(LIB, ROUTE_MAP_INDEX, "Route map index") -DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule") -DEFINE_MTYPE(LIB, ROUTE_MAP_RULE_STR, "Route map rule str") -DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled") -DEFINE_MTYPE(LIB, ROUTE_MAP_DEP, "Route map dependency") -DEFINE_MTYPE(LIB, CMD_TOKENS, "Command desc") -DEFINE_MTYPE(LIB, KEY, "Key") -DEFINE_MTYPE(LIB, KEYCHAIN, "Key chain") -DEFINE_MTYPE(LIB, IF_RMAP, "Interface route map") -DEFINE_MTYPE(LIB, IF_RMAP_NAME, "I.f. route map name") -DEFINE_MTYPE(LIB, SOCKUNION, "Socket union") -DEFINE_MTYPE(LIB, PRIVS, "Privilege information") -DEFINE_MTYPE(LIB, ZLOG, "Logging") -DEFINE_MTYPE(LIB, ZCLIENT, "Zclient") -DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue") -DEFINE_MTYPE(LIB, WORK_QUEUE_ITEM, "Work queue item") -DEFINE_MTYPE(LIB, WORK_QUEUE_NAME, "Work queue name string") -DEFINE_MTYPE(LIB, PQUEUE, "Priority queue") -DEFINE_MTYPE(LIB, PQUEUE_DATA, "Priority queue data") -DEFINE_MTYPE(LIB, HOST, "host configuration") -DEFINE_MTYPE(LIB, BFD_INFO, "BFD info") -DEFINE_MTYPE(LIB, VRF, "VRF") -DEFINE_MTYPE(LIB, VRF_NAME, "VRF name") -DEFINE_MTYPE(LIB, VRF_BITMAP, "VRF bit-map") -DEFINE_MTYPE(LIB, IF_LINK_PARAMS, "Informational Link Parameters") -DEFINE_MTYPE(LIB, NS, "Logical-Router") -DEFINE_MTYPE(LIB, NS_NAME, "Logical-Router Name") -DEFINE_MTYPE(LIB, NS_BITMAP, "Logical-Router bit-map") - - - -DEFINE_MGROUP(ZEBRA, "zebra") -DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") -DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") -DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF") -DEFINE_MTYPE(ZEBRA, NEXTHOP, "Nexthop") -DEFINE_MTYPE(ZEBRA, RIB, "RIB") -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") -DEFINE_MTYPE(ZEBRA, NETLINK_NAME, "Netlink name") - - - -DEFINE_MGROUP(BGPD, "bgpd") -DEFINE_MTYPE(BGPD, BGP, "BGP instance") -DEFINE_MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details") -DEFINE_MTYPE(BGPD, BGP_PEER, "BGP peer") -DEFINE_MTYPE(BGPD, BGP_PEER_HOST, "BGP peer hostname") -DEFINE_MTYPE(BGPD, BGP_PEER_IFNAME, "BGP peer ifname") -DEFINE_MTYPE(BGPD, PEER_GROUP, "Peer group") -DEFINE_MTYPE(BGPD, PEER_GROUP_HOST, "BGP Peer group hostname") -DEFINE_MTYPE(BGPD, PEER_DESC, "Peer description") -DEFINE_MTYPE(BGPD, PEER_PASSWORD, "Peer password string") -DEFINE_MTYPE(BGPD, BGP_PEER_AF, "BGP peer af") -DEFINE_MTYPE(BGPD, BGP_UPDGRP, "BGP update group") -DEFINE_MTYPE(BGPD, BGP_UPD_SUBGRP, "BGP update subgroup") -DEFINE_MTYPE(BGPD, BGP_PACKET, "BGP packet") -DEFINE_MTYPE(BGPD, ATTR, "BGP attribute") -DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes") -DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath") -DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg") -DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data") -DEFINE_MTYPE(BGPD, AS_STR, "BGP aspath str") - -DEFINE_MTYPE(BGPD, BGP_TABLE, "BGP table") -DEFINE_MTYPE(BGPD, BGP_NODE, "BGP node") -DEFINE_MTYPE(BGPD, BGP_ROUTE, "BGP route") -DEFINE_MTYPE(BGPD, BGP_ROUTE_EXTRA, "BGP ancillary route info") -DEFINE_MTYPE(BGPD, BGP_CONN, "BGP connected") -DEFINE_MTYPE(BGPD, BGP_STATIC, "BGP static") -DEFINE_MTYPE(BGPD, BGP_ADVERTISE_ATTR, "BGP adv attr") -DEFINE_MTYPE(BGPD, BGP_ADVERTISE, "BGP adv") -DEFINE_MTYPE(BGPD, BGP_SYNCHRONISE, "BGP synchronise") -DEFINE_MTYPE(BGPD, BGP_ADJ_IN, "BGP adj in") -DEFINE_MTYPE(BGPD, BGP_ADJ_OUT, "BGP adj out") -DEFINE_MTYPE(BGPD, BGP_MPATH_INFO, "BGP multipath info") - -DEFINE_MTYPE(BGPD, AS_LIST, "BGP AS list") -DEFINE_MTYPE(BGPD, AS_FILTER, "BGP AS filter") -DEFINE_MTYPE(BGPD, AS_FILTER_STR, "BGP AS filter str") - -DEFINE_MTYPE(BGPD, COMMUNITY, "community") -DEFINE_MTYPE(BGPD, COMMUNITY_VAL, "community val") -DEFINE_MTYPE(BGPD, COMMUNITY_STR, "community str") - -DEFINE_MTYPE(BGPD, ECOMMUNITY, "extcommunity") -DEFINE_MTYPE(BGPD, ECOMMUNITY_VAL, "extcommunity val") -DEFINE_MTYPE(BGPD, ECOMMUNITY_STR, "extcommunity str") - -DEFINE_MTYPE(BGPD, COMMUNITY_LIST, "community-list") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_NAME, "community-list name") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_ENTRY, "community-list entry") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_CONFIG, "community-list config") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_HANDLER, "community-list handler") - -DEFINE_MTYPE(BGPD, CLUSTER, "Cluster list") -DEFINE_MTYPE(BGPD, CLUSTER_VAL, "Cluster list val") - -DEFINE_MTYPE(BGPD, BGP_PROCESS_QUEUE, "BGP Process queue") -DEFINE_MTYPE(BGPD, BGP_CLEAR_NODE_QUEUE, "BGP node clear queue") - -DEFINE_MTYPE(BGPD, TRANSIT, "BGP transit attr") -DEFINE_MTYPE(BGPD, TRANSIT_VAL, "BGP transit val") - -DEFINE_MTYPE(BGPD, BGP_DEBUG_FILTER, "BGP debug filter") -DEFINE_MTYPE(BGPD, BGP_DEBUG_STR, "BGP debug filter string") - -DEFINE_MTYPE(BGPD, BGP_DISTANCE, "BGP distance") -DEFINE_MTYPE(BGPD, BGP_NEXTHOP_CACHE, "BGP nexthop") -DEFINE_MTYPE(BGPD, BGP_CONFED_LIST, "BGP confed list") -DEFINE_MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface") -DEFINE_MTYPE(BGPD, PEER_CONF_IF, "BGP peer config interface") -DEFINE_MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info") -DEFINE_MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array") -DEFINE_MTYPE(BGPD, BGP_REGEXP, "BGP regexp") -DEFINE_MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate") -DEFINE_MTYPE(BGPD, BGP_ADDR, "BGP own address") - -DEFINE_MTYPE(BGPD, BGP_REDIST, "BGP redistribution") -DEFINE_MTYPE(BGPD, BGP_FILTER_NAME, "BGP Filter Information") -DEFINE_MTYPE(BGPD, BGP_DUMP_STR, "BGP Dump String Information") -DEFINE_MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV") - - - -DEFINE_MGROUP(RIPD, "ripd") -DEFINE_MTYPE(RIPD, RIP, "RIP structure") -DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info") -DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface") -DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer") -DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list") -DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance") - - - -DEFINE_MGROUP(RIPNGD, "ripngd") -DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure") -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") - - - -DEFINE_MGROUP(OSPFD, "ospfd") -DEFINE_MTYPE(OSPFD, OSPF_TOP, "OSPF top") -DEFINE_MTYPE(OSPFD, OSPF_AREA, "OSPF area") -DEFINE_MTYPE(OSPFD, OSPF_AREA_RANGE, "OSPF area range") -DEFINE_MTYPE(OSPFD, OSPF_NETWORK, "OSPF network") -DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR_STATIC, "OSPF static nbr") -DEFINE_MTYPE(OSPFD, OSPF_IF, "OSPF interface") -DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR, "OSPF neighbor") -DEFINE_MTYPE(OSPFD, OSPF_ROUTE, "OSPF route") -DEFINE_MTYPE(OSPFD, OSPF_TMP, "OSPF tmp mem") -DEFINE_MTYPE(OSPFD, OSPF_LSA, "OSPF LSA") -DEFINE_MTYPE(OSPFD, OSPF_LSA_DATA, "OSPF LSA data") -DEFINE_MTYPE(OSPFD, OSPF_LSDB, "OSPF LSDB") -DEFINE_MTYPE(OSPFD, OSPF_PACKET, "OSPF packet") -DEFINE_MTYPE(OSPFD, OSPF_FIFO, "OSPF FIFO queue") -DEFINE_MTYPE(OSPFD, OSPF_VERTEX, "OSPF vertex") -DEFINE_MTYPE(OSPFD, OSPF_VERTEX_PARENT, "OSPF vertex parent") -DEFINE_MTYPE(OSPFD, OSPF_NEXTHOP, "OSPF nexthop") -DEFINE_MTYPE(OSPFD, OSPF_PATH, "OSPF path") -DEFINE_MTYPE(OSPFD, OSPF_VL_DATA, "OSPF VL data") -DEFINE_MTYPE(OSPFD, OSPF_CRYPT_KEY, "OSPF crypt key") -DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_INFO, "OSPF ext. info") -DEFINE_MTYPE(OSPFD, OSPF_DISTANCE, "OSPF distance") -DEFINE_MTYPE(OSPFD, OSPF_IF_INFO, "OSPF if info") -DEFINE_MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params") -DEFINE_MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message") -DEFINE_MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS parameters") -DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCE parameters") - - - -DEFINE_MGROUP(OSPF6D, "ospf6d") -DEFINE_MTYPE(OSPF6D, OSPF6_TOP, "OSPF6 top") -DEFINE_MTYPE(OSPF6D, OSPF6_AREA, "OSPF6 area") -DEFINE_MTYPE(OSPF6D, OSPF6_IF, "OSPF6 interface") -DEFINE_MTYPE(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor") -DEFINE_MTYPE(OSPF6D, OSPF6_ROUTE, "OSPF6 route") -DEFINE_MTYPE(OSPF6D, OSPF6_PREFIX, "OSPF6 prefix") -DEFINE_MTYPE(OSPF6D, OSPF6_MESSAGE, "OSPF6 message") -DEFINE_MTYPE(OSPF6D, OSPF6_LSA, "OSPF6 LSA") -DEFINE_MTYPE(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary") -DEFINE_MTYPE(OSPF6D, OSPF6_LSDB, "OSPF6 LSA database") -DEFINE_MTYPE(OSPF6D, OSPF6_VERTEX, "OSPF6 vertex") -DEFINE_MTYPE(OSPF6D, OSPF6_SPFTREE, "OSPF6 SPF tree") -DEFINE_MTYPE(OSPF6D, OSPF6_NEXTHOP, "OSPF6 nexthop") -DEFINE_MTYPE(OSPF6D, OSPF6_EXTERNAL_INFO,"OSPF6 ext. info") -DEFINE_MTYPE(OSPF6D, OSPF6_OTHER, "OSPF6 other") - - - -DEFINE_MGROUP(ISISD, "isisd") -DEFINE_MTYPE(ISISD, ISIS, "ISIS") -DEFINE_MTYPE(ISISD, ISIS_TMP, "ISIS TMP") -DEFINE_MTYPE(ISISD, ISIS_CIRCUIT, "ISIS circuit") -DEFINE_MTYPE(ISISD, ISIS_LSP, "ISIS LSP") -DEFINE_MTYPE(ISISD, ISIS_ADJACENCY, "ISIS adjacency") -DEFINE_MTYPE(ISISD, ISIS_AREA, "ISIS area") -DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address") -DEFINE_MTYPE(ISISD, ISIS_TLV, "ISIS TLV") -DEFINE_MTYPE(ISISD, ISIS_DYNHN, "ISIS dyn hostname") -DEFINE_MTYPE(ISISD, ISIS_SPFTREE, "ISIS SPFtree") -DEFINE_MTYPE(ISISD, ISIS_VERTEX, "ISIS vertex") -DEFINE_MTYPE(ISISD, ISIS_ROUTE_INFO, "ISIS route info") -DEFINE_MTYPE(ISISD, ISIS_NEXTHOP, "ISIS nexthop") -DEFINE_MTYPE(ISISD, ISIS_NEXTHOP6, "ISIS nexthop6") -DEFINE_MTYPE(ISISD, ISIS_DICT, "ISIS dictionary") -DEFINE_MTYPE(ISISD, ISIS_DICT_NODE, "ISIS dictionary node") -DEFINE_MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters") - - - -DEFINE_MGROUP(PIMD, "pimd") -DEFINE_MTYPE(PIMD, PIM_CHANNEL_OIL, "PIM SSM (S,G) channel OIL") -DEFINE_MTYPE(PIMD, PIM_INTERFACE, "PIM interface") -DEFINE_MTYPE(PIMD, PIM_IGMP_JOIN, "PIM interface IGMP static join") -DEFINE_MTYPE(PIMD, PIM_IGMP_SOCKET, "PIM interface IGMP socket") -DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP, "PIM interface IGMP group") -DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source") -DEFINE_MTYPE(PIMD, PIM_NEIGHBOR, "PIM interface neighbor") -DEFINE_MTYPE(PIMD, PIM_IFCHANNEL, "PIM interface (S,G) state") -DEFINE_MTYPE(PIMD, PIM_UPSTREAM, "PIM upstream (S,G) state") -DEFINE_MTYPE(PIMD, PIM_SSMPINGD, "PIM sspimgd socket") -DEFINE_MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route") -DEFINE_MTYPE(PIMD, PIM_BR, "PIM Bridge Router info") - - - -DEFINE_MGROUP(MVTYSH, "vtysh") -DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG, "Vtysh configuration") -DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line") diff --git a/lib/memtypes.pl b/lib/memtypes.pl deleted file mode 100755 index 0955161b1..000000000 --- a/lib/memtypes.pl +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/perl -while (<STDIN>) { - $_ =~ s/DEFINE_MTYPE\([^,]+,\s*([^,]+)\s*,.*\)/DECLARE_MTYPE\($1\)/; - $_ =~ s/DEFINE_MGROUP\(([^,]+),.*\)/DECLARE_MGROUP\($1\)/; - print $_; -} diff --git a/lib/nexthop.c b/lib/nexthop.c index 14486ea15..427f77f87 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -33,6 +33,8 @@ #include "prefix.h" #include "nexthop.h" +DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop") + /* check if nexthops are same, non-recursive */ int nexthop_same_no_recurse (struct nexthop *next1, struct nexthop *next2) @@ -39,6 +39,9 @@ #include "command.h" #include "vty.h" +DEFINE_MTYPE_STATIC(LIB, NS, "Logical-Router") +DEFINE_MTYPE_STATIC(LIB, NS_NAME, "Logical-Router Name") +DEFINE_MTYPE_STATIC(LIB, NS_BITMAP, "Logical-Router bit-map") #ifndef CLONE_NEWNET #define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */ diff --git a/lib/plist.c b/lib/plist.c index 7bb80fa2a..eedb830c1 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -34,6 +34,11 @@ #include "plist_int.h" +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List") +DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str") +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table") + /* not currently changeable, code assumes bytes further down */ #define PLC_BITS 8 #define PLC_LEN (1 << PLC_BITS) @@ -236,7 +241,7 @@ prefix_list_insert (afi_t afi, int orf, const char *name) /* Allocate new prefix_list and copy given name. */ plist = prefix_list_new (); - plist->name = XSTRDUP (MTYPE_PREFIX_LIST_STR, name); + plist->name = XSTRDUP (MTYPE_MPREFIX_LIST_STR, name); plist->master = master; plist->trie = XCALLOC (MTYPE_PREFIX_LIST_TRIE, sizeof (struct pltrie_table)); @@ -370,7 +375,7 @@ prefix_list_delete (struct prefix_list *plist) (*master->delete_hook) (plist); if (plist->name) - XFREE (MTYPE_PREFIX_LIST_STR, plist->name); + XFREE (MTYPE_MPREFIX_LIST_STR, plist->name); XFREE (MTYPE_PREFIX_LIST_TRIE, plist->trie); diff --git a/lib/pqueue.c b/lib/pqueue.c index 69ab8e65d..0f870564d 100644 --- a/lib/pqueue.c +++ b/lib/pqueue.c @@ -23,6 +23,9 @@ Boston, MA 02111-1307, USA. */ #include "memory.h" #include "pqueue.h" +DEFINE_MTYPE_STATIC(LIB, PQUEUE, "Priority queue") +DEFINE_MTYPE_STATIC(LIB, PQUEUE_DATA, "Priority queue data") + /* priority queue using heap sort */ /* pqueue->cmp() controls the order of sorting (i.e, ascending or diff --git a/lib/prefix.c b/lib/prefix.c index d2bb02831..34bb1a493 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -28,6 +28,8 @@ #include "memory.h" #include "log.h" +DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix") + /* Maskbit. */ static const u_char maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; diff --git a/lib/privs.c b/lib/privs.c index 3fb96aed1..9228a56d3 100644 --- a/lib/privs.c +++ b/lib/privs.c @@ -27,6 +27,9 @@ #include "memory.h" #ifdef HAVE_CAPABILITIES + +DEFINE_MTYPE_STATIC(LIB, PRIVS, "Privilege information") + /* sort out some generic internal types for: * * privilege values (cap_value_t, priv_t) -> pvalue_t diff --git a/lib/routemap.c b/lib/routemap.c index 9267056df..10e5ed304 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -30,6 +30,14 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "log.h" #include "hash.h" +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map") +DEFINE_MTYPE( LIB, ROUTE_MAP_NAME, "Route map name") +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index") +DEFINE_MTYPE( LIB, ROUTE_MAP_RULE, "Route map rule") +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str") +DEFINE_MTYPE( LIB, ROUTE_MAP_COMPILED, "Route map compiled") +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency") + /* Vector for route match rules. */ static vector route_match_vec; diff --git a/lib/routemap.h b/lib/routemap.h index f5981a87f..7006e43f6 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -23,6 +23,10 @@ #define _ZEBRA_ROUTEMAP_H #include "prefix.h" +#include "memory.h" +DECLARE_MTYPE(ROUTE_MAP_NAME) +DECLARE_MTYPE(ROUTE_MAP_RULE) +DECLARE_MTYPE(ROUTE_MAP_COMPILED) /* Route map's type. */ enum route_map_type diff --git a/lib/sockunion.c b/lib/sockunion.c index 9184e500f..96408965a 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -29,6 +29,8 @@ #include "log.h" #include "jhash.h" +DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union") + #ifndef HAVE_INET_ATON int inet_aton (const char *cp, struct in_addr *inaddr) diff --git a/lib/stream.c b/lib/stream.c index 809e749fb..301ebc627 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -29,6 +29,10 @@ #include "prefix.h" #include "log.h" +DEFINE_MTYPE_STATIC(LIB, STREAM, "Stream") +DEFINE_MTYPE_STATIC(LIB, STREAM_DATA, "Stream data") +DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO") + /* Tests whether a position is valid */ #define GETP_VALID(S,G) \ ((G) <= (S)->endp) diff --git a/lib/table.c b/lib/table.c index da2136168..8858aea0f 100644 --- a/lib/table.c +++ b/lib/table.c @@ -27,6 +27,9 @@ #include "memory.h" #include "sockunion.h" +DEFINE_MTYPE( LIB, ROUTE_TABLE, "Route table") +DEFINE_MTYPE_STATIC(LIB, ROUTE_NODE, "Route node") + static void route_node_delete (struct route_node *); static void route_table_free (struct route_table *); diff --git a/lib/table.h b/lib/table.h index 2ffd79b53..34c196aa4 100644 --- a/lib/table.h +++ b/lib/table.h @@ -23,6 +23,9 @@ #ifndef _ZEBRA_TABLE_H #define _ZEBRA_TABLE_H +#include "memory.h" +DECLARE_MTYPE(ROUTE_TABLE) + /* * Forward declarations. */ diff --git a/lib/thread.c b/lib/thread.c index 573e9f725..a26eb6bfd 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -32,6 +32,10 @@ #include "command.h" #include "sigevent.h" +DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") +DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") +DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats") + #if defined(__APPLE__) #include <mach/mach.h> #include <mach/mach_time.h> diff --git a/lib/vector.c b/lib/vector.c index 7c1486285..03ad3171d 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -24,6 +24,9 @@ #include "vector.h" #include "memory.h" +DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector") +DEFINE_MTYPE( LIB, VECTOR_INDEX, "Vector index") + /* Initialize vector : allocate memory and return vector. */ vector vector_init (unsigned int size) diff --git a/lib/vector.h b/lib/vector.h index 6b27fd96d..d8f4c7860 100644 --- a/lib/vector.h +++ b/lib/vector.h @@ -23,6 +23,9 @@ #ifndef _ZEBRA_VECTOR_H #define _ZEBRA_VECTOR_H +#include "memory.h" +DECLARE_MTYPE(VECTOR_INDEX) + /* struct for vector */ struct _vector { @@ -30,6 +30,9 @@ #include "memory.h" #include "command.h" +DEFINE_MTYPE_STATIC(LIB, VRF, "VRF") +DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map") + /* * Turn on/off debug code * for vrf. @@ -40,6 +40,10 @@ #include <arpa/telnet.h> #include <termios.h> +DEFINE_MTYPE_STATIC(LIB, VTY, "VTY") +DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer") +DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history") + /* Vty events */ enum event { diff --git a/lib/workqueue.c b/lib/workqueue.c index 772749403..549bb2360 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -29,6 +29,10 @@ #include "command.h" #include "log.h" +DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue") +DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_ITEM, "Work queue item") +DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_NAME, "Work queue name string") + /* master list of work_queues */ static struct list _work_queues; /* pointer primarily to avoid an otherwise harmless warning on diff --git a/lib/workqueue.h b/lib/workqueue.h index 19b44041d..eaf857490 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -24,6 +24,9 @@ #ifndef _QUAGGA_WORK_QUEUE_H #define _QUAGGA_WORK_QUEUE_H +#include "memory.h" +DECLARE_MTYPE(WORK_QUEUE) + /* Hold time for the initial schedule of a queue run, in millisec */ #define WORK_QUEUE_DEFAULT_HOLD 50 diff --git a/lib/zclient.c b/lib/zclient.c index 753954fd8..057fa7758 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -34,6 +34,8 @@ #include "table.h" #include "nexthop.h" +DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient") + /* Zebra client events. */ enum event {ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT}; |