From: David Lamparter <equi...@opensourcerouting.org>

Move over to the new allocation counting added in the previous commit.

(This is mostly mechanical.)

Signed-off-by: David Lamparter <equi...@opensourcerouting.org>
Signed-off-by: Philippe Guibert <philippe.guib...@6wind.com>
---
 bgpd/bgp_main.c             |   1 +
 bgpd/bgp_vty.c              |   1 +
 isisd/isis_main.c           |   1 +
 lib/Makefile.am             |   6 +-
 lib/memory.h                |  15 +-
 lib/memory_vty.c            | 268 +---------------------
 lib/memory_vty.h            |  64 +-----
 lib/memtypes.awk            |  87 -------
 lib/memtypes.c              | 541 +++++++++++++++++++++-----------------------
 ospf6d/ospf6_main.c         |   1 +
 ospfclient/ospf_apiclient.c |   2 +
 ospfclient/ospf_apiclient.h |   2 -
 ospfd/ospf_main.c           |   1 +
 ospfd/ospf_opaque.c         |   9 +-
 ospfd/ospf_te.c             |   5 +-
 pimd/pim_main.c             |   1 +
 ripd/rip_main.c             |   1 +
 ripngd/ripng_main.c         |   1 +
 tests/common-cli.c          |   1 +
 tests/main.c                |   1 +
 tests/test-buffer.c         |   1 +
 tests/test-privs.c          |   1 +
 vtysh/vtysh_main.c          |   1 +
 zebra/main.c                |   1 +
 zebra/test_main.c           |   1 +
 25 files changed, 308 insertions(+), 706 deletions(-)
 delete mode 100644 lib/memtypes.awk

diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 11c73ceae97f..25669a0cb08f 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -27,6 +27,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, 
Boston, MA
 #include "thread.h"
 #include <lib/version.h>
 #include "memory.h"
+#include "memory_vty.h"
 #include "prefix.h"
 #include "log.h"
 #include "privs.h"
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 6db3dcb1cdfa..a2d72ff8e0d1 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -29,6 +29,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, 
Boston, MA
 #include "thread.h"
 #include "log.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "hash.h"
 #include "filter.h"
 
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 3a730879551a..1c3323ebc4d7 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -29,6 +29,7 @@
 #include "command.h"
 #include "vty.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "stream.h"
 #include "if.h"
 #include "privs.h"
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d67c4e72fd3b..9b52931a8074 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -39,12 +39,12 @@ noinst_HEADERS = \
 EXTRA_DIST = \
        regex.c regex-gnu.h \
        queue.h \
-       memtypes.awk \
+       memtypes.pl \
        route_types.pl route_types.txt \
        gitversion.pl
 
-memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.awk
-       ($(GAWK) -f $(srcdir)/memtypes.awk $(srcdir)/memtypes.c > $@)
+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 > $@
diff --git a/lib/memory.h b/lib/memory.h
index 86971ccd5e90..d4acaac089dc 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -122,8 +122,17 @@ extern void *qstrdup (struct memtype *mt, const char *str)
        __attribute__ ((malloc, nonnull (1) _RET_NONNULL));
 extern void qfree (struct memtype *mt, void *ptr);
 
-/* still here until next commit */
-#include "memory_vty.h"
+#define XMALLOC(mtype, size)           qmalloc(mtype, size)
+#define XCALLOC(mtype, size)           qcalloc(mtype, size)
+#define XREALLOC(mtype, ptr, size)     qrealloc(mtype, ptr, size)
+#define XSTRDUP(mtype, str)            qstrdup(mtype, str)
+#define XFREE(mtype, ptr)              do { qfree(mtype, ptr); ptr = NULL; } \
+                                       while (0)
+
+static inline size_t mtype_stats_alloc(struct memtype *mt)
+{
+       return mt->n_alloc;
+}
 
 /* NB: calls are ordered by memgroup; and there is a call with mt == NULL for
  * each memgroup (so that a header can be printed, and empty memgroups show)
@@ -135,5 +144,7 @@ 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/memory_vty.c b/lib/memory_vty.c
index 763f2383e50b..814ced8607c0 100644
--- a/lib/memory_vty.c
+++ b/lib/memory_vty.c
@@ -28,265 +28,17 @@
 
 #include "log.h"
 #include "memory.h"
-
-static void alloc_inc (int);
-static void alloc_dec (int);
-static void log_memstats(int log_priority);
-
-static const struct message mstr [] =
-{
-  { MTYPE_THREAD, "thread" },
-  { MTYPE_THREAD_MASTER, "thread_master" },
-  { MTYPE_VECTOR, "vector" },
-  { MTYPE_VECTOR_INDEX, "vector_index" },
-  { MTYPE_IF, "interface" },
-  { 0, NULL },
-};
-
-/* Fatal memory allocation error occured. */
-static void __attribute__ ((noreturn))
-zerror (const char *fname, int type, size_t size)
-{
-  zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n", 
-           fname, lookup (mstr, type), (int) size, safe_strerror(errno));
-  log_memstats(LOG_WARNING);
-  /* N.B. It might be preferable to call zlog_backtrace_sigsafe here, since
-     that function should definitely be safe in an OOM condition.  But
-     unfortunately zlog_backtrace_sigsafe does not support syslog logging at
-     this time... */
-  zlog_backtrace(LOG_WARNING);
-  abort();
-}
-
-/*
- * Allocate memory of a given size, to be tracked by a given type.
- * Effects: Returns a pointer to usable memory.  If memory cannot
- * be allocated, aborts execution.
- */
-void *
-zmalloc (int type, size_t size)
-{
-  void *memory;
-
-  memory = malloc (size);
-
-  if (memory == NULL)
-    zerror ("malloc", type, size);
-
-  alloc_inc (type);
-
-  return memory;
-}
-
-/*
- * Allocate memory as in zmalloc, and also clear the memory.
- */
-void *
-zcalloc (int type, size_t size)
-{
-  void *memory;
-
-  memory = calloc (1, size);
-
-  if (memory == NULL)
-    zerror ("calloc", type, size);
-
-  alloc_inc (type);
-
-  return memory;
-}
-
-/* 
- * Given a pointer returned by zmalloc or zcalloc, free it and
- * return a pointer to a new size, basically acting like realloc().
- * Requires: ptr was returned by zmalloc, zcalloc, or zrealloc with the
- * same type.
- * Effects: Returns a pointer to the new memory, or aborts.
- */
-void *
-zrealloc (int type, void *ptr, size_t size)
-{
-  void *memory;
-
-  if (ptr == NULL)              /* is really alloc */
-      return zcalloc(type, size);
-
-  memory = realloc (ptr, size);
-  if (memory == NULL)
-    zerror ("realloc", type, size);
-  if (ptr == NULL)
-    alloc_inc (type);
-
-  return memory;
-}
-
-/*
- * Free memory allocated by z*alloc or zstrdup.
- * Requires: ptr was returned by zmalloc, zcalloc, or zrealloc with the
- * same type.
- * Effects: The memory is freed and may no longer be referenced.
- */
-void
-zfree (int type, void *ptr)
-{
-  if (ptr != NULL)
-    {
-      alloc_dec (type);
-      free (ptr);
-    }
-}
-
-/*
- * Duplicate a string, counting memory usage by type.
- * Effects: The string is duplicated, and the return value must
- * eventually be passed to zfree with the same type.  The function will
- * succeed or abort.
- */
-char *
-zstrdup (int type, const char *str)
-{
-  void *dup;
-
-  dup = strdup (str);
-  if (dup == NULL)
-    zerror ("strdup", type, strlen (str));
-  alloc_inc (type);
-  return dup;
-}
-
-#ifdef MEMORY_LOG
-static struct 
-{
-  const char *name;
-  long alloc;
-  unsigned long t_malloc;
-  unsigned long c_malloc;
-  unsigned long t_calloc;
-  unsigned long c_calloc;
-  unsigned long t_realloc;
-  unsigned long t_free;
-  unsigned long c_strdup;
-} mstat [MTYPE_MAX];
-
-static void
-mtype_log (char *func, void *memory, const char *file, int line, int type)
-{
-  zlog_debug ("%s: %s %p %s %d", func, lookup (mstr, type), memory, file, 
line);
-}
-
-void *
-mtype_zmalloc (const char *file, int line, int type, size_t size)
-{
-  void *memory;
-
-  mstat[type].c_malloc++;
-  mstat[type].t_malloc++;
-
-  memory = zmalloc (type, size);
-  mtype_log ("zmalloc", memory, file, line, type);
-
-  return memory;
-}
-
-void *
-mtype_zcalloc (const char *file, int line, int type, size_t size)
-{
-  void *memory;
-
-  mstat[type].c_calloc++;
-  mstat[type].t_calloc++;
-
-  memory = zcalloc (type, size);
-  mtype_log ("xcalloc", memory, file, line, type);
-
-  return memory;
-}
-
-void *
-mtype_zrealloc (const char *file, int line, int type, void *ptr, size_t size)
-{
-  void *memory;
-
-  /* Realloc need before allocated pointer. */
-  mstat[type].t_realloc++;
-
-  memory = zrealloc (type, ptr, size);
-
-  mtype_log ("xrealloc", memory, file, line, type);
-
-  return memory;
-}
-
-/* Important function. */
-void 
-mtype_zfree (const char *file, int line, int type, void *ptr)
-{
-  mstat[type].t_free++;
-
-  mtype_log ("xfree", ptr, file, line, type);
-
-  zfree (type, ptr);
-}
-
-char *
-mtype_zstrdup (const char *file, int line, int type, const char *str)
-{
-  char *memory;
-
-  mstat[type].c_strdup++;
-
-  memory = zstrdup (type, str);
-  
-  mtype_log ("xstrdup", memory, file, line, type);
-
-  return memory;
-}
-#else
-static struct 
-{
-  char *name;
-  long alloc;
-} mstat [MTYPE_MAX];
-#endif /* MEMORY_LOG */
-
-/* Increment allocation counter. */
-static void
-alloc_inc (int type)
-{
-  mstat[type].alloc++;
-}
-
-/* Decrement allocation counter. */
-static void
-alloc_dec (int type)
-{
-  mstat[type].alloc--;
-}
+#include "memory_vty.h"
 
 /* Looking up memory status from vty interface. */
 #include "vector.h"
 #include "vty.h"
 #include "command.h"
 
-static void
-log_memstats(int pri)
-{
-  struct mlist *ml;
-
-  for (ml = mlists; ml->list; ml++)
-    {
-      struct memory_list *m;
-
-      zlog (NULL, pri, "Memory utilization in module %s:", ml->name);
-      for (m = ml->list; m->index >= 0; m++)
-       if (m->index && mstat[m->index].alloc)
-         zlog (NULL, pri, "  %-30s: %10ld", m->format, mstat[m->index].alloc);
-    }
-}
-
 void
 log_memstats_stderr (const char *prefix)
 {
+#if 0
   struct mlist *ml;
   struct memory_list *m;
   int i;
@@ -323,8 +75,10 @@ log_memstats_stderr (const char *prefix)
     fprintf (stderr,
              "%s: memstats: No remaining tracked memory utilization.\n",
              prefix);
+#endif
 }
 
+#if 0
 static void
 show_separator(struct vty *vty)
 {
@@ -353,6 +107,7 @@ show_memory_vty (struct vty *vty, struct memory_list *list)
       }
   return needsep;
 }
+#endif
 
 #ifdef HAVE_MALLINFO
 static int
@@ -419,19 +174,22 @@ DEFUN (show_memory,
        "Show running system information\n"
        "Memory statistics\n")
 {
-  struct mlist *ml;
   int needsep = 0;
   
 #ifdef HAVE_MALLINFO
   needsep = show_memory_mallinfo (vty);
 #endif /* HAVE_MALLINFO */
-  
+
+  (void) needsep;
+#if 0
+  struct mlist *ml;
   for (ml = mlists; ml->list; ml++)
     {
       if (needsep)
        show_separator (vty);
       needsep = show_memory_vty (vty, ml->list);
     }
+#endif
 
   qmem_walk(qmem_walker, vty);
   return CMD_SUCCESS;
@@ -497,9 +255,3 @@ mtype_memstr (char *buf, size_t len, unsigned long bytes)
   
   return buf;
 }
-
-unsigned long
-mtype_stats_alloc (int type)
-{
-  return mstat[type].alloc;
-}
diff --git a/lib/memory_vty.h b/lib/memory_vty.h
index d691b9b2b8ab..7aab01ee5b1b 100644
--- a/lib/memory_vty.h
+++ b/lib/memory_vty.h
@@ -21,73 +21,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, 
Boston, MA
 #ifndef _ZEBRA_MEMORY_VTY_H
 #define _ZEBRA_MEMORY_VTY_H
 
-/* For pretty printing of memory allocate information. */
-struct memory_list
-{
-  int index;
-  const char *format;
-};
+#include "memory.h"
 
-struct mlist {
-  struct memory_list *list;
-  const char *name;
-};
- 
-#include "lib/memtypes.h"
-
-extern struct mlist mlists[];
-
-/* #define MEMORY_LOG */
-#ifdef MEMORY_LOG
-#define XMALLOC(mtype, size) \
-  mtype_zmalloc (__FILE__, __LINE__, (mtype), (size))
-#define XCALLOC(mtype, size) \
-  mtype_zcalloc (__FILE__, __LINE__, (mtype), (size))
-#define XREALLOC(mtype, ptr, size)  \
-  mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size))
-#define XFREE(mtype, ptr) \
-  do { \
-    mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)); \
-    ptr = NULL; } \
-  while (0)
-#define XSTRDUP(mtype, str) \
-  mtype_zstrdup (__FILE__, __LINE__, (mtype), (str))
-#else
-#define XMALLOC(mtype, size)       zmalloc ((mtype), (size))
-#define XCALLOC(mtype, size)       zcalloc ((mtype), (size))
-#define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
-#define XFREE(mtype, ptr)          do { \
-                                     zfree ((mtype), (ptr)); \
-                                     ptr = NULL; } \
-                                   while (0)
-#define XSTRDUP(mtype, str)        zstrdup ((mtype), (str))
-#endif /* MEMORY_LOG */
-
-/* Prototypes of memory function. */
-extern void *zmalloc (int type, size_t size);
-extern void *zcalloc (int type, size_t size);
-extern void *zrealloc (int type, void *ptr, size_t size);
-extern void  zfree (int type, void *ptr);
-extern char *zstrdup (int type, const char *str);
-
-extern void *mtype_zmalloc (const char *file, int line, int type, size_t size);
-
-extern void *mtype_zcalloc (const char *file, int line, int type, size_t size);
-
-extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr,
-                            size_t size);
-
-extern void mtype_zfree (const char *file, int line, int type,
-                        void *ptr);
-
-extern char *mtype_zstrdup (const char *file, int line, int type,
-                           const char *str);
 extern void memory_init (void);
 extern void log_memstats_stderr (const char *);
 
-/* return number of allocations outstanding for the type */
-extern unsigned long mtype_stats_alloc (int);
-
 /* Human friendly string for given byte count */
 #define MTYPE_MEMSTR_LEN 20
 extern const char *mtype_memstr (char *, size_t, unsigned long);
diff --git a/lib/memtypes.awk b/lib/memtypes.awk
deleted file mode 100644
index bd13327db547..000000000000
--- a/lib/memtypes.awk
+++ /dev/null
@@ -1,87 +0,0 @@
-###
-# Copyright (C) Paul Jakma 2005
-#
-# 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 Quagga; see the file COPYING.  If not, write to the Free
-# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.  
-###
-#
-# Scan a file of memory definitions (see eg memtypes.c) and generate
-# a corresponding header file with an enum of the MTYPE's and declarations
-# for the struct memory_list arrays
-#
-# struct memory_list's must be declared as:
-# '\nstruct memory_list memory_list_<name>[] .....'
-#
-# Each MTYPE_ within the definition must the second token on the line,
-# tokens being delineated by whitespace. It may only consist of the set of
-# characters [[:upper:]_[:digit:]]. Eg:
-#
-# '\n  {  MTYPE_AWESOME_IPV8 , "Amazing new protocol, says genius" {}..boo'
-#
-# We try to ignore lines whose first token is /* or *, ie C comment lines.
-# So the following should work fine:
-#
-# '/* This is the best memory_list ever!
-# ' * It's got all my MTYPE's */
-# '
-# 'struct memory_list memory_list_my_amazing_mlist[] = =
-# '{
-# '  { MTYPE_DONGLE, "Dongle widget" }
-# '  { MTYPE_FROB, "Frobulator" },
-# '{  MTYPE_WIPPLE, "Wipple combombulator"}
-# '}}}
-#
-# Even if it isn't quite a valid C declaration.
-#
-
-BEGIN {
-       mlistregex = "memory_list_(.*)\\[\\]";
-       mtyperegex = "^(MTYPE_[[:upper:]_[:digit:]]+).*";
-       header = "/* Auto-generated from memtypes.c by " ARGV[0] ". */\n";
-       header = header "/* Do not edit! */\n";
-       header = header "\n#ifndef _QUAGGA_MEMTYPES_H\n";
-       header = header "#define _QUAGGA_MEMTYPES_H\n";
-       footer = "\n#endif /* _QUAGGA_MEMTYPES_H */\n\n";
-       mlistformat = "extern struct memory_list memory_list_%s[];";
-       printf ("%s\n", header);
-}
-
-# catch lines beginning with 'struct memory list ' and try snag the
-# memory_list name. Has to be 3rd field.
-($0 ~ /^struct memory_list /) && (NF >= 3) {
-       mlists[lcount++] = gensub(mlistregex, "\\1", "g",$3);
-}
-
-# snag the MTYPE, it must self-standing and the second field,
-# though we do manage to tolerate the , C seperator being appended
-($1 !~ /^\/?\*/) && ($2 ~ /^MTYPE_/) { 
-       mtype[tcount++] = gensub(mtyperegex, "\\1", "g", $2);
-} 
-
-END {
-       printf("enum\n{\n  MTYPE_TMP = 1,\n"); 
-       for (i = 0; i < tcount; i++) {
-               if (mtype[i] != "" && mtype[i] != "MTYPE_TMP")
-                       printf ("  %s,\n", mtype[i]);
-       }
-       printf ("  MTYPE_MAX,\n};\n\n");
-       for (i = 0; i < lcount; i++) {
-               if (mlists[i] != "")
-                       printf (mlistformat "\n", mlists[i]);
-       }
-       printf (footer);
-}
diff --git a/lib/memtypes.c b/lib/memtypes.c
index 6df144803064..215ea5265666 100644
--- a/lib/memtypes.c
+++ b/lib/memtypes.c
@@ -10,286 +10,261 @@
 #include "zebra.h"
 #include "memory.h"
 
-struct memory_list memory_list_lib[] =
-{
-  { MTYPE_TMP,                 "Temporary memory"              },
-  { MTYPE_STRVEC,              "String vector"                 },
-  { MTYPE_VECTOR,              "Vector"                        },
-  { MTYPE_VECTOR_INDEX,                "Vector index"                  },
-  { MTYPE_LINK_LIST,           "Link List"                     },
-  { MTYPE_LINK_NODE,           "Link Node"                     },
-  { MTYPE_THREAD,              "Thread"                        },
-  { MTYPE_THREAD_MASTER,       "Thread master"                 },
-  { MTYPE_THREAD_STATS,                "Thread stats"                  },
-  { MTYPE_VTY,                 "VTY"                           },
-  { MTYPE_VTY_OUT_BUF,         "VTY output buffer"             },
-  { MTYPE_VTY_HIST,            "VTY history"                   },
-  { MTYPE_IF,                  "Interface"                     },
-  { MTYPE_CONNECTED,           "Connected"                     },
-  { MTYPE_CONNECTED_LABEL,     "Connected interface label"     },
-  { MTYPE_BUFFER,              "Buffer"                        },
-  { MTYPE_BUFFER_DATA,         "Buffer data"                   },
-  { MTYPE_STREAM,              "Stream"                        },
-  { MTYPE_STREAM_DATA,         "Stream data"                   },
-  { MTYPE_STREAM_FIFO,         "Stream FIFO"                   },
-  { MTYPE_PREFIX,              "Prefix"                        },
-  { MTYPE_PREFIX_IPV4,         "Prefix IPv4"                   },
-  { MTYPE_PREFIX_IPV6,         "Prefix IPv6"                   },
-  { MTYPE_HASH,                        "Hash"                          },
-  { MTYPE_HASH_BACKET,         "Hash Bucket"                   },
-  { MTYPE_HASH_INDEX,          "Hash Index"                    },
-  { MTYPE_ROUTE_TABLE,         "Route table"                   },
-  { MTYPE_ROUTE_NODE,          "Route node"                    },
-  { MTYPE_DISTRIBUTE,          "Distribute list"               },
-  { MTYPE_DISTRIBUTE_IFNAME,   "Dist-list ifname"              },
-  { MTYPE_ACCESS_LIST,         "Access List"                   },
-  { MTYPE_ACCESS_LIST_STR,     "Access List Str"               },
-  { MTYPE_ACCESS_FILTER,       "Access Filter"                 },
-  { MTYPE_PREFIX_LIST,         "Prefix List"                   },
-  { MTYPE_PREFIX_LIST_ENTRY,   "Prefix List Entry"             },
-  { MTYPE_PREFIX_LIST_STR,     "Prefix List Str"               },
-  { MTYPE_ROUTE_MAP,           "Route map"                     },
-  { MTYPE_ROUTE_MAP_NAME,      "Route map name"                },
-  { MTYPE_ROUTE_MAP_INDEX,     "Route map index"               },
-  { MTYPE_ROUTE_MAP_RULE,      "Route map rule"                },
-  { MTYPE_ROUTE_MAP_RULE_STR,  "Route map rule str"            },
-  { MTYPE_ROUTE_MAP_COMPILED,  "Route map compiled"            },
-  { MTYPE_CMD_TOKENS,          "Command desc"                  },
-  { MTYPE_KEY,                 "Key"                           },
-  { MTYPE_KEYCHAIN,            "Key chain"                     },
-  { MTYPE_IF_RMAP,             "Interface route map"           },
-  { MTYPE_IF_RMAP_NAME,                "I.f. route map name",          },
-  { MTYPE_SOCKUNION,           "Socket union"                  },
-  { MTYPE_PRIVS,               "Privilege information"         },
-  { MTYPE_ZLOG,                        "Logging"                       },
-  { MTYPE_ZCLIENT,             "Zclient"                       },
-  { MTYPE_WORK_QUEUE,          "Work queue"                    },
-  { MTYPE_WORK_QUEUE_ITEM,     "Work queue item"               },
-  { MTYPE_WORK_QUEUE_NAME,     "Work queue name string"        },
-  { MTYPE_PQUEUE,              "Priority queue"                },
-  { MTYPE_PQUEUE_DATA,         "Priority queue data"           },
-  { MTYPE_HOST,                        "Host config"                   },
-  { MTYPE_VRF,                 "VRF"                           },
-  { MTYPE_VRF_NAME,            "VRF name"                      },
-  { MTYPE_VRF_BITMAP,          "VRF bit-map"                   },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_zebra[] = 
-{
-  { MTYPE_RTADV_PREFIX,                "Router Advertisement Prefix"   },
-  { MTYPE_ZEBRA_VRF,           "ZEBRA VRF"                             },
-  { MTYPE_NEXTHOP,             "Nexthop"                       },
-  { MTYPE_RIB,                 "RIB"                           },
-  { MTYPE_RIB_QUEUE,           "RIB process work queue"        },
-  { MTYPE_STATIC_ROUTE,                "Static route"                  },
-  { MTYPE_RIB_DEST,            "RIB destination"               },
-  { MTYPE_RIB_TABLE_INFO,      "RIB table info"                },
-  { MTYPE_NETLINK_NAME,        "Netlink name"                  },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_bgp[] =
-{
-  { MTYPE_BGP,                 "BGP instance"                  },
-  { MTYPE_BGP_LISTENER,                "BGP listen socket details"     },
-  { MTYPE_BGP_PEER,            "BGP peer"                      },
-  { MTYPE_BGP_PEER_HOST,       "BGP peer hostname"             },
-  { MTYPE_PEER_GROUP,          "Peer group"                    },
-  { MTYPE_PEER_DESC,           "Peer description"              },
-  { MTYPE_PEER_PASSWORD,       "Peer password string"          },
-  { MTYPE_ATTR,                        "BGP attribute"                 },
-  { MTYPE_ATTR_EXTRA,          "BGP extra attributes"          },
-  { MTYPE_AS_PATH,             "BGP aspath"                    },
-  { MTYPE_AS_SEG,              "BGP aspath seg"                },
-  { MTYPE_AS_SEG_DATA,         "BGP aspath segment data"       },
-  { MTYPE_AS_STR,              "BGP aspath str"                },
-  { 0, NULL },
-  { MTYPE_BGP_TABLE,           "BGP table"                     },
-  { MTYPE_BGP_NODE,            "BGP node"                      },
-  { MTYPE_BGP_ROUTE,           "BGP route"                     },
-  { MTYPE_BGP_ROUTE_EXTRA,     "BGP ancillary route info"      },
-  { MTYPE_BGP_CONN,            "BGP connected"                 },
-  { MTYPE_BGP_STATIC,          "BGP static"                    },
-  { MTYPE_BGP_ADVERTISE_ATTR,  "BGP adv attr"                  },
-  { MTYPE_BGP_ADVERTISE,       "BGP adv"                       },
-  { MTYPE_BGP_SYNCHRONISE,     "BGP synchronise"               },
-  { MTYPE_BGP_ADJ_IN,          "BGP adj in"                    },
-  { MTYPE_BGP_ADJ_OUT,         "BGP adj out"                   },
-  { MTYPE_BGP_MPATH_INFO,      "BGP multipath info"            },
-  { 0, NULL },
-  { MTYPE_AS_LIST,             "BGP AS list"                   },
-  { MTYPE_AS_FILTER,           "BGP AS filter"                 },
-  { MTYPE_AS_FILTER_STR,       "BGP AS filter str"             },
-  { 0, NULL },
-  { MTYPE_COMMUNITY,           "community"                     },
-  { MTYPE_COMMUNITY_VAL,       "community val"                 },
-  { MTYPE_COMMUNITY_STR,       "community str"                 },
-  { 0, NULL },
-  { MTYPE_ECOMMUNITY,          "extcommunity"                  },
-  { MTYPE_ECOMMUNITY_VAL,      "extcommunity val"              },
-  { MTYPE_ECOMMUNITY_STR,      "extcommunity str"              },
-  { 0, NULL },
-  { MTYPE_COMMUNITY_LIST,      "community-list"                },
-  { MTYPE_COMMUNITY_LIST_NAME, "community-list name"           },
-  { MTYPE_COMMUNITY_LIST_ENTRY,        "community-list entry"          },
-  { MTYPE_COMMUNITY_LIST_CONFIG,  "community-list config"      },
-  { MTYPE_COMMUNITY_LIST_HANDLER, "community-list handler"     },
-  { 0, NULL },
-  { MTYPE_CLUSTER,             "Cluster list"                  },
-  { MTYPE_CLUSTER_VAL,         "Cluster list val"              },
-  { 0, NULL },
-  { MTYPE_BGP_PROCESS_QUEUE,   "BGP Process queue"             },
-  { MTYPE_BGP_CLEAR_NODE_QUEUE, "BGP node clear queue"         },
-  { 0, NULL },
-  { MTYPE_TRANSIT,             "BGP transit attr"              },
-  { MTYPE_TRANSIT_VAL,         "BGP transit val"               },
-  { 0, NULL },
-  { MTYPE_BGP_DISTANCE,                "BGP distance"                  },
-  { MTYPE_BGP_NEXTHOP_CACHE,   "BGP nexthop"                   },
-  { MTYPE_BGP_CONFED_LIST,     "BGP confed list"               },
-  { MTYPE_PEER_UPDATE_SOURCE,  "BGP peer update interface"     },
-  { MTYPE_BGP_DAMP_INFO,       "Dampening info"                },
-  { MTYPE_BGP_DAMP_ARRAY,      "BGP Dampening array"           },
-  { MTYPE_BGP_REGEXP,          "BGP regexp"                    },
-  { MTYPE_BGP_AGGREGATE,       "BGP aggregate"                 },
-  { MTYPE_BGP_ADDR,            "BGP own address"               },
-  { MTYPE_ENCAP_TLV,           "ENCAP TLV",                    },
-  { -1, NULL }
-};
-
-struct memory_list memory_list_rip[] =
-{
-  { MTYPE_RIP,                "RIP structure"                  },
-  { MTYPE_RIP_INFO,           "RIP route info"                 },
-  { MTYPE_RIP_INTERFACE,      "RIP interface"                  },
-  { MTYPE_RIP_PEER,           "RIP peer"                       },
-  { MTYPE_RIP_OFFSET_LIST,    "RIP offset list"                        },
-  { MTYPE_RIP_DISTANCE,       "RIP distance"                   },
-  { -1, NULL }
-};
-
-struct memory_list memory_list_ripng[] =
-{
-  { MTYPE_RIPNG,              "RIPng structure"                        },
-  { MTYPE_RIPNG_ROUTE,        "RIPng route info"               },
-  { MTYPE_RIPNG_AGGREGATE,    "RIPng aggregate"                        },
-  { MTYPE_RIPNG_PEER,         "RIPng peer"                     },
-  { MTYPE_RIPNG_OFFSET_LIST,  "RIPng offset lst"               },
-  { MTYPE_RIPNG_RTE_DATA,     "RIPng rte data"                 },
-  { -1, NULL }
-};
-
-struct memory_list memory_list_babel[] =
-{
-  { MTYPE_BABEL,              "Babel structure"                        },
-  { MTYPE_BABEL_IF,           "Babel interface"                        },
-  { -1, NULL }
-};
-
-struct memory_list memory_list_ospf[] =
-{
-  { MTYPE_OSPF_TOP,           "OSPF top"                       },
-  { MTYPE_OSPF_AREA,          "OSPF area"                      },
-  { MTYPE_OSPF_AREA_RANGE,    "OSPF area range"                        },
-  { MTYPE_OSPF_NETWORK,       "OSPF network"                   },
-  { MTYPE_OSPF_NEIGHBOR_STATIC,"OSPF static nbr"               },
-  { MTYPE_OSPF_IF,            "OSPF interface"                 },
-  { MTYPE_OSPF_NEIGHBOR,      "OSPF neighbor"                  },
-  { MTYPE_OSPF_ROUTE,         "OSPF route"                     },
-  { MTYPE_OSPF_TMP,           "OSPF tmp mem"                   },
-  { MTYPE_OSPF_LSA,           "OSPF LSA"                       },
-  { MTYPE_OSPF_LSA_DATA,      "OSPF LSA data"                  },
-  { MTYPE_OSPF_LSDB,          "OSPF LSDB"                      },
-  { MTYPE_OSPF_PACKET,        "OSPF packet"                    },
-  { MTYPE_OSPF_FIFO,          "OSPF FIFO queue"                        },
-  { MTYPE_OSPF_VERTEX,        "OSPF vertex"                    },
-  { MTYPE_OSPF_VERTEX_PARENT, "OSPF vertex parent",            },
-  { MTYPE_OSPF_NEXTHOP,       "OSPF nexthop"                   },
-  { MTYPE_OSPF_PATH,         "OSPF path"                       },
-  { MTYPE_OSPF_VL_DATA,       "OSPF VL data"                   },
-  { MTYPE_OSPF_CRYPT_KEY,     "OSPF crypt key"                 },
-  { MTYPE_OSPF_EXTERNAL_INFO, "OSPF ext. info"                 },
-  { MTYPE_OSPF_DISTANCE,      "OSPF distance"                  },
-  { MTYPE_OSPF_IF_INFO,       "OSPF if info"                   },
-  { MTYPE_OSPF_IF_PARAMS,     "OSPF if params"                 },
-  { MTYPE_OSPF_MESSAGE,                "OSPF message"                  },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_ospf6[] =
-{
-  { MTYPE_OSPF6_TOP,          "OSPF6 top"                      },
-  { MTYPE_OSPF6_AREA,         "OSPF6 area"                     },
-  { MTYPE_OSPF6_IF,           "OSPF6 interface"                        },
-  { MTYPE_OSPF6_NEIGHBOR,     "OSPF6 neighbor"                 },
-  { MTYPE_OSPF6_ROUTE,        "OSPF6 route"                    },
-  { MTYPE_OSPF6_PREFIX,       "OSPF6 prefix"                   },
-  { MTYPE_OSPF6_MESSAGE,      "OSPF6 message"                  },
-  { MTYPE_OSPF6_LSA,          "OSPF6 LSA"                      },
-  { MTYPE_OSPF6_LSA_SUMMARY,  "OSPF6 LSA summary"              },
-  { MTYPE_OSPF6_LSDB,         "OSPF6 LSA database"             },
-  { MTYPE_OSPF6_VERTEX,       "OSPF6 vertex"                   },
-  { MTYPE_OSPF6_SPFTREE,      "OSPF6 SPF tree"                 },
-  { MTYPE_OSPF6_NEXTHOP,      "OSPF6 nexthop"                  },
-  { MTYPE_OSPF6_EXTERNAL_INFO,"OSPF6 ext. info"                        },
-  { MTYPE_OSPF6_OTHER,        "OSPF6 other"                    },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_isis[] =
-{
-  { MTYPE_ISIS,               "ISIS"                           },
-  { MTYPE_ISIS_TMP,           "ISIS TMP"                       },
-  { MTYPE_ISIS_CIRCUIT,       "ISIS circuit"                   },
-  { MTYPE_ISIS_LSP,           "ISIS LSP"                       },
-  { MTYPE_ISIS_ADJACENCY,     "ISIS adjacency"                 },
-  { MTYPE_ISIS_AREA,          "ISIS area"                      },
-  { MTYPE_ISIS_AREA_ADDR,     "ISIS area address"              },
-  { MTYPE_ISIS_TLV,           "ISIS TLV"                       },
-  { MTYPE_ISIS_DYNHN,         "ISIS dyn hostname"              },
-  { MTYPE_ISIS_SPFTREE,       "ISIS SPFtree"                   },
-  { MTYPE_ISIS_VERTEX,        "ISIS vertex"                    },
-  { MTYPE_ISIS_ROUTE_INFO,    "ISIS route info"                        },
-  { MTYPE_ISIS_NEXTHOP,       "ISIS nexthop"                   },
-  { MTYPE_ISIS_NEXTHOP6,      "ISIS nexthop6"                  },
-  { MTYPE_ISIS_DICT,          "ISIS dictionary"                        },
-  { MTYPE_ISIS_DICT_NODE,     "ISIS dictionary node"           },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_pim[] =
-{
-  { MTYPE_PIM_CHANNEL_OIL,       "PIM SSM (S,G) channel OIL"      },
-  { MTYPE_PIM_INTERFACE,         "PIM interface"                 },
-  { MTYPE_PIM_IGMP_JOIN,         "PIM interface IGMP static join" },
-  { MTYPE_PIM_IGMP_SOCKET,       "PIM interface IGMP socket"      },
-  { MTYPE_PIM_IGMP_GROUP,        "PIM interface IGMP group"       },
-  { MTYPE_PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source"      },
-  { MTYPE_PIM_NEIGHBOR,          "PIM interface neighbor"         },
-  { MTYPE_PIM_IFCHANNEL,         "PIM interface (S,G) state"      },
-  { MTYPE_PIM_UPSTREAM,          "PIM upstream (S,G) state"       },
-  { MTYPE_PIM_SSMPINGD,          "PIM sspimgd socket"             },
-  { MTYPE_PIM_STATIC_ROUTE,      "PIM Static Route"               },
-  { -1, NULL },
-};
-
-struct memory_list memory_list_vtysh[] =
-{
-  { MTYPE_VTYSH_CONFIG,                "Vtysh configuration",          },
-  { MTYPE_VTYSH_CONFIG_LINE,   "Vtysh configuration line"      },
-  { -1, NULL },
-};
-
-struct mlist mlists[] __attribute__ ((unused)) = {
-  { memory_list_lib,   "LIB"   },
-  { memory_list_zebra, "ZEBRA" },
-  { memory_list_rip,   "RIP"   },
-  { memory_list_ripng, "RIPNG" },
-  { memory_list_ospf,  "OSPF"  },
-  { memory_list_ospf6, "OSPF6" },
-  { memory_list_isis,  "ISIS"  },
-  { memory_list_bgp,   "BGP"   },
-  { memory_list_pim,   "PIM"   },
-  { NULL, NULL},
-};
+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, 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, 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, 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, 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, VRF,                 "VRF")
+DEFINE_MTYPE(LIB, VRF_NAME,            "VRF name")
+DEFINE_MTYPE(LIB, VRF_BITMAP,          "VRF bit-map")
+
+
+
+DEFINE_MGROUP(ZEBRA, "zebra")
+DEFINE_MTYPE(ZEBRA, RTADV_PREFIX,              "Router Advertisement Prefix")
+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, 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, PEER_GROUP,         "Peer group")
+DEFINE_MTYPE(BGPD, PEER_DESC,          "Peer description")
+DEFINE_MTYPE(BGPD, PEER_PASSWORD,              "Peer password string")
+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_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, 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, 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(BABELD, "babeld")
+DEFINE_MTYPE(BABELD, BABEL,            "Babel structure")
+DEFINE_MTYPE(BABELD, BABEL_IF,         "Babel interface")
+
+
+
+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_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_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_MGROUP(MVTYSH, "vtysh")
+DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG,             "Vtysh configuration")
+DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG_LINE,        "Vtysh configuration line")
+
+
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index 1afe84a733af..adc1c5c581a2 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -28,6 +28,7 @@
 #include "command.h"
 #include "vty.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "if.h"
 #include "filter.h"
 #include "prefix.h"
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index ed7ca94756c7..453e05ce2ebb 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -49,6 +49,8 @@
 
 #include "ospf_apiclient.h"
 
+DEFINE_MTYPE_STATIC(OSPFD, OSPF_APICLIENT,  "OSPF-API client")
+
 /* Backlog for listen */
 #define BACKLOG 5
 
diff --git a/ospfclient/ospf_apiclient.h b/ospfclient/ospf_apiclient.h
index 809861995e17..5a1de3b136ac 100644
--- a/ospfclient/ospf_apiclient.h
+++ b/ospfclient/ospf_apiclient.h
@@ -23,8 +23,6 @@
 #ifndef _OSPF_APICLIENT_H
 #define _OSPF_APICLIENT_H
 
-#define MTYPE_OSPF_APICLIENT MTYPE_TMP
-
 /* Structure for the OSPF API client */
 struct ospf_apiclient
 {
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index f373650c2f49..d4f2b377f854 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -36,6 +36,7 @@
 #include "stream.h"
 #include "log.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "privs.h"
 #include "sigevent.h"
 #include "zclient.h"
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 697655d536b2..fa7b2de8f432 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -21,11 +21,6 @@
  * 02111-1307, USA.
  */
 
-/***** MTYPE definitions are not reflected to "memory.h" yet. *****/
-#define MTYPE_OSPF_OPAQUE_FUNCTAB      MTYPE_TMP
-#define MTYPE_OPAQUE_INFO_PER_TYPE     MTYPE_TMP
-#define MTYPE_OPAQUE_INFO_PER_ID       MTYPE_TMP
-
 #include <zebra.h>
 
 #include "linklist.h"
@@ -57,6 +52,10 @@
 #include "ospfd/ospf_ase.h"
 #include "ospfd/ospf_zebra.h"
 
+DEFINE_MTYPE_STATIC(OSPFD, OSPF_OPAQUE_FUNCTAB,  "OSPF opaque function table")
+DEFINE_MTYPE_STATIC(OSPFD, OPAQUE_INFO_PER_TYPE, "OSPF opaque per-type info")
+DEFINE_MTYPE_STATIC(OSPFD, OPAQUE_INFO_PER_ID,   "OSPF opaque per-ID info")
+
 /*------------------------------------------------------------------------*
  * Followings are initialize/terminate functions for Opaque-LSAs handling.
  *------------------------------------------------------------------------*/
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 03109bc82703..04496ef21ce2 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -21,9 +21,6 @@
  * 02111-1307, USA.
  */
 
-/***** MTYPE definition is not reflected to "memory.h" yet. *****/
-#define MTYPE_OSPF_MPLS_TE_LINKPARAMS  MTYPE_TMP
-
 #include <zebra.h>
 
 #include "linklist.h"
@@ -56,6 +53,8 @@
 #include "ospfd/ospf_zebra.h"
 #include "ospfd/ospf_te.h"
 
+DEFINE_MTYPE_STATIC(OSPFD, OSPF_MPLS_TE_LINKPARAMS, "OSPF MPLS-TE link 
parameters")
+
 /* Following structure are internal use only. */
 struct ospf_mpls_te
 {
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index 5f4711e865de..68fbe9f76e21 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -32,6 +32,7 @@
 
 #include "memory.h"
 #include "vrf.h"
+#include "memory_vty.h"
 #include "filter.h"
 #include "vty.h"
 #include "sigevent.h"
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index 4ead9b0edec7..42363c5214d0 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -26,6 +26,7 @@
 #include "thread.h"
 #include "command.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "prefix.h"
 #include "filter.h"
 #include "keychain.h"
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index 1c184e2c29ca..ee7beec93ca9 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -28,6 +28,7 @@
 #include "vty.h"
 #include "command.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "thread.h"
 #include "log.h"
 #include "prefix.h"
diff --git a/tests/common-cli.c b/tests/common-cli.c
index 7135856e9907..f837db5e99a1 100644
--- a/tests/common-cli.c
+++ b/tests/common-cli.c
@@ -26,6 +26,7 @@
 #include "vty.h"
 #include "command.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "log.h"
 
 #include "common-cli.h"
diff --git a/tests/main.c b/tests/main.c
index 5396c7d50fa9..885b8a2923ee 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -27,6 +27,7 @@
 #include "vty.h"
 #include "command.h"
 #include "memory.h"
+#include "memory_vty.h"
 
 extern void test_init();
 
diff --git a/tests/test-buffer.c b/tests/test-buffer.c
index e95d6fb8291a..67e40358060e 100644
--- a/tests/test-buffer.c
+++ b/tests/test-buffer.c
@@ -21,6 +21,7 @@
 
 #include <zebra.h>
 #include <memory.h>
+#include <memory_vty.h>
 #include <buffer.h>
 
 struct thread_master *master;
diff --git a/tests/test-privs.c b/tests/test-privs.c
index beae81f693ea..e0118a881c8d 100644
--- a/tests/test-privs.c
+++ b/tests/test-privs.c
@@ -25,6 +25,7 @@
 #include "getopt.h"
 #include "privs.h"
 #include "memory.h"
+#include "memory_vty.h"
 
 zebra_capabilities_t _caps_p [] = 
 {
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 3fc0419eceac..2f76e89f9208 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -33,6 +33,7 @@
 #include "getopt.h"
 #include "command.h"
 #include "memory.h"
+#include "memory_vty.h"
 
 #include "vtysh/vtysh.h"
 #include "vtysh/vtysh_user.h"
diff --git a/zebra/main.c b/zebra/main.c
index f3c08f1929d2..af33d0c62e8b 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -27,6 +27,7 @@
 #include "thread.h"
 #include "filter.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "prefix.h"
 #include "log.h"
 #include "plist.h"
diff --git a/zebra/test_main.c b/zebra/test_main.c
index 09f53adfbc32..f14c6751adea 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -25,6 +25,7 @@
 #include "thread.h"
 #include "filter.h"
 #include "memory.h"
+#include "memory_vty.h"
 #include "prefix.h"
 #include "log.h"
 #include "privs.h"
-- 
2.1.4


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to