summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-09-20 21:17:34 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-09-20 21:17:34 -0400
commit460a768914822df062bc1282296e6bf6a3c6f725 (patch)
tree5997cc60a574e56f4960103caa9d9f35a36bc4e2
parent844ec28cee41395cdd1cc0cdf8cf0168f9dc1adf (diff)
parente3e29b328d161c6d129e479a9564ce216688da81 (diff)
Merge remote-tracking branch 'origin/cmaster-next' into vtysh-grammar
-rw-r--r--INSTALL.quagga.txt1
-rw-r--r--bgpd/Makefile.am2
-rw-r--r--bgpd/bgp_advertise.h2
-rw-r--r--bgpd/bgp_community.c1
-rw-r--r--bgpd/bgp_fsm.c15
-rw-r--r--bgpd/bgp_main.c1
-rw-r--r--bgpd/bgp_memory.c110
-rw-r--r--bgpd/bgp_memory.h108
-rw-r--r--bgpd/bgp_mplsvpn.c108
-rw-r--r--bgpd/bgp_network.c4
-rw-r--r--bgpd/bgp_nexthop.c11
-rw-r--r--bgpd/bgp_open.c9
-rw-r--r--bgpd/bgp_packet.c4
-rw-r--r--bgpd/bgp_route.c139
-rw-r--r--bgpd/bgp_vty.c36
-rw-r--r--bgpd/bgp_vty.h2
-rw-r--r--bgpd/bgpd.c13
-rw-r--r--bgpd/bgpd.h1
-rwxr-xr-xconfigure.ac12
-rw-r--r--doc/Makefile.am2
-rw-r--r--isisd/Makefile.am2
-rw-r--r--isisd/dict.c1
-rw-r--r--isisd/isis_main.c1
-rw-r--r--isisd/isis_memory.c48
-rw-r--r--isisd/isis_memory.h49
-rw-r--r--isisd/isis_redist.c114
-rw-r--r--isisd/isis_routemap.c217
-rw-r--r--isisd/isis_te.c2
-rw-r--r--isisd/isis_te.h6
-rw-r--r--isisd/isis_vty.c22
-rw-r--r--isisd/isisd.c2
-rw-r--r--isisd/isisd.h1
-rw-r--r--lib/.gitignore1
-rw-r--r--lib/Makefile.am17
-rw-r--r--lib/bfd.c2
-rw-r--r--lib/buffer.c3
-rw-r--r--lib/command.c5
-rw-r--r--lib/command.h6
-rw-r--r--lib/command_match.c3
-rw-r--r--lib/command_parse.y69
-rw-r--r--lib/distribute.c4
-rw-r--r--lib/fifo.h62
-rw-r--r--lib/filter.c4
-rw-r--r--lib/graph.c2
-rw-r--r--lib/hash.c4
-rw-r--r--lib/hash.h5
-rw-r--r--lib/if.c6
-rw-r--r--lib/if.h4
-rw-r--r--lib/if_rmap.c3
-rw-r--r--lib/json.h2
-rw-r--r--lib/keychain.c3
-rw-r--r--lib/linklist.c3
-rw-r--r--lib/log.c15
-rw-r--r--lib/memory.c514
-rw-r--r--lib/memory.h272
-rw-r--r--lib/memory_vty.c169
-rw-r--r--lib/memory_vty.h31
-rw-r--r--lib/memtypes.awk87
-rw-r--r--lib/memtypes.c317
-rw-r--r--lib/nexthop.c2
-rw-r--r--lib/ns.c3
-rw-r--r--lib/plist.c9
-rw-r--r--lib/pqueue.c3
-rw-r--r--lib/prefix.c2
-rw-r--r--lib/privs.c3
-rw-r--r--lib/routemap.c8
-rw-r--r--lib/routemap.h4
-rw-r--r--lib/sockunion.c2
-rw-r--r--lib/stream.c4
-rw-r--r--lib/table.c3
-rw-r--r--lib/table.h3
-rw-r--r--lib/thread.c32
-rw-r--r--lib/vector.c3
-rw-r--r--lib/vector.h3
-rw-r--r--lib/vrf.c3
-rw-r--r--lib/vty.c4
-rw-r--r--lib/workqueue.c14
-rw-r--r--lib/workqueue.h3
-rw-r--r--lib/zclient.c2
-rw-r--r--lib/zebra.h157
-rw-r--r--ospf6d/Makefile.am2
-rw-r--r--ospf6d/ospf6_interface.c10
-rw-r--r--ospf6d/ospf6_main.c1
-rw-r--r--ospf6d/ospf6_memory.c44
-rw-r--r--ospf6d/ospf6_memory.h45
-rw-r--r--ospf6d/ospf6d.h2
-rw-r--r--ospfclient/ospf_apiclient.c2
-rw-r--r--ospfclient/ospf_apiclient.h2
-rw-r--r--ospfd/Makefile.am4
-rw-r--r--ospfd/ospf_main.c1
-rw-r--r--ospfd/ospf_memory.c56
-rw-r--r--ospfd/ospf_memory.h57
-rw-r--r--ospfd/ospf_opaque.c9
-rw-r--r--ospfd/ospf_packet.c20
-rw-r--r--ospfd/ospf_te.c8
-rw-r--r--ospfd/ospfd.h2
-rw-r--r--pimd/Makefile.am2
-rw-r--r--pimd/pim_main.c2
-rw-r--r--pimd/pim_memory.c41
-rw-r--r--pimd/pim_memory.h42
-rw-r--r--pimd/pimd.h1
-rw-r--r--ripd/Makefile.am2
-rw-r--r--ripd/rip_main.c1
-rw-r--r--ripd/rip_memory.c35
-rw-r--r--ripd/rip_memory.h36
-rw-r--r--ripd/ripd.h2
-rw-r--r--ripngd/Makefile.am2
-rw-r--r--ripngd/ripng_main.c1
-rw-r--r--ripngd/ripng_memory.c35
-rw-r--r--ripngd/ripng_memory.h36
-rw-r--r--ripngd/ripngd.h2
-rw-r--r--tests/common-cli.c1
-rw-r--r--tests/heavy-wq.c14
-rw-r--r--tests/main.c1
-rw-r--r--tests/test-buffer.c1
-rw-r--r--tests/test-memory.c49
-rw-r--r--tests/test-privs.c1
-rwxr-xr-xvtysh/extract.pl.in2
-rw-r--r--vtysh/vtysh.c14
-rw-r--r--vtysh/vtysh.h3
-rw-r--r--vtysh/vtysh_config.c4
-rw-r--r--vtysh/vtysh_main.c1
-rw-r--r--zebra/Makefile.am5
-rw-r--r--zebra/connected.c1
-rw-r--r--zebra/if_ioctl.c1
-rw-r--r--zebra/if_ioctl_solaris.c1
-rw-r--r--zebra/if_sysctl.c1
-rw-r--r--zebra/interface.c50
-rw-r--r--zebra/irdp_interface.c1
-rw-r--r--zebra/irdp_main.c1
-rw-r--r--zebra/irdp_packet.c1
-rw-r--r--zebra/kernel_socket.c1
-rw-r--r--zebra/main.c2
-rw-r--r--zebra/redistribute.c1
-rw-r--r--zebra/rib.h2
-rw-r--r--zebra/router-id.c1
-rw-r--r--zebra/rt_netlink.c1
-rw-r--r--zebra/rtadv.c1
-rw-r--r--zebra/rtread_sysctl.c1
-rw-r--r--zebra/test_main.c2
-rw-r--r--zebra/zebra_memory.c37
-rw-r--r--zebra/zebra_memory.h40
-rw-r--r--zebra/zebra_ns.c4
-rw-r--r--zebra/zebra_ptm_redistribute.c1
-rw-r--r--zebra/zebra_rib.c41
-rw-r--r--zebra/zebra_rnh.c1
-rw-r--r--zebra/zebra_routemap.c1
-rw-r--r--zebra/zebra_static.c1
-rw-r--r--zebra/zebra_vrf.c2
-rw-r--r--zebra/zebra_vty.c4
-rw-r--r--zebra/zserv.c246
151 files changed, 2295 insertions, 1679 deletions
diff --git a/INSTALL.quagga.txt b/INSTALL.quagga.txt
index 11c85b1a31..b414d94861 100644
--- a/INSTALL.quagga.txt
+++ b/INSTALL.quagga.txt
@@ -69,7 +69,6 @@ deficient is made.
autoconf: 2.59 (2.60 on 2006-06-26 is too recent to require)
libtool: 1.5.22 (released 2005-12-18)
texinfo: 4.7 (released 2004-04-10; 4.8 is not yet common)
- GNU AWK: 3.1.5 (released 2005-08-12)
For running tests, one also needs:
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am
index 5176a8e048..fb5b2375de 100644
--- a/bgpd/Makefile.am
+++ b/bgpd/Makefile.am
@@ -11,6 +11,7 @@ sbin_PROGRAMS = bgpd
bin_PROGRAMS = bgp_btoa
libbgp_a_SOURCES = \
+ bgp_memory.c \
bgpd.c bgp_fsm.c bgp_aspath.c bgp_community.c bgp_attr.c \
bgp_debug.c bgp_route.c bgp_zebra.c bgp_open.c bgp_routemap.c \
bgp_packet.c bgp_network.c bgp_filter.c bgp_regex.c bgp_clist.c \
@@ -20,6 +21,7 @@ libbgp_a_SOURCES = \
bgp_encap.c bgp_encap_tlv.c
noinst_HEADERS = \
+ bgp_memory.h \
bgp_aspath.h bgp_attr.h bgp_community.h bgp_debug.h bgp_fsm.h \
bgp_network.h bgp_open.h bgp_packet.h bgp_regex.h bgp_route.h \
bgpd.h bgp_filter.h bgp_clist.h bgp_dump.h bgp_zebra.h \
diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h
index 86c959478d..6dc9bb647c 100644
--- a/bgpd/bgp_advertise.h
+++ b/bgpd/bgp_advertise.h
@@ -21,6 +21,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGP_ADVERTISE_H
#define _QUAGGA_BGP_ADVERTISE_H
+#include <lib/fifo.h>
+
struct update_subgroup;
/* BGP advertise FIFO. */
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index d7aa4c1e38..450cbddcfa 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -23,6 +23,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "hash.h"
#include "memory.h"
+#include "bgpd/bgp_memory.h"
#include "bgpd/bgp_community.h"
/* Hash of community attribute. */
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index 046767177b..f775bd048f 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -51,6 +51,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_updgrp.h"
#include "bgpd/bgp_nht.h"
#include "bgpd/bgp_bfd.h"
+#include "bgpd/bgp_memory.h"
/* Definition of display strings corresponding to FSM events. This should be
* kept consistent with the events defined in bgpd.h
@@ -166,12 +167,12 @@ peer_xfer_conn(struct peer *from_peer)
{
if (peer->hostname)
{
- XFREE(MTYPE_HOST, peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
peer->hostname = NULL;
}
- peer->hostname = XSTRDUP(MTYPE_HOST, from_peer->hostname);
- XFREE(MTYPE_HOST, from_peer->hostname);
+ peer->hostname = XSTRDUP(MTYPE_BGP_PEER_HOST, from_peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, from_peer->hostname);
from_peer->hostname = NULL;
}
@@ -179,12 +180,12 @@ peer_xfer_conn(struct peer *from_peer)
{
if (peer->domainname)
{
- XFREE(MTYPE_HOST, peer->domainname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer->domainname= NULL;
}
- peer->domainname = XSTRDUP(MTYPE_HOST, from_peer->domainname);
- XFREE(MTYPE_HOST, from_peer->domainname);
+ peer->domainname = XSTRDUP(MTYPE_BGP_PEER_HOST, from_peer->domainname);
+ XFREE(MTYPE_BGP_PEER_HOST, from_peer->domainname);
from_peer->domainname = NULL;
}
@@ -1329,10 +1330,10 @@ bgp_start (struct peer *peer)
if (!bgp_find_or_add_nexthop(peer->bgp, family2afi(peer->su.sa.sa_family),
NULL, peer, connected))
{
+#if defined (HAVE_CUMULUS)
if (bgp_debug_neighbor_events(peer))
zlog_debug ("%s [FSM] Waiting for NHT", peer->host);
-#if !defined (HAVE_BGP_STANDALONE)
BGP_EVENT_ADD(peer, TCP_connection_open_failed);
return 0;
#endif
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 5ef8154faf..68d6cb7f38 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_memory.c b/bgpd/bgp_memory.c
new file mode 100644
index 0000000000..166400b745
--- /dev/null
+++ b/bgpd/bgp_memory.c
@@ -0,0 +1,110 @@
+/* bgpd 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 Quagga; 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 "bgp_memory.h"
+
+/* this file is temporary in nature; definitions should be moved to the
+ * files they're used in */
+
+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")
diff --git a/bgpd/bgp_memory.h b/bgpd/bgp_memory.h
new file mode 100644
index 0000000000..b2956f07ed
--- /dev/null
+++ b/bgpd/bgp_memory.h
@@ -0,0 +1,108 @@
+/* bgpd 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_BGP_MEMORY_H
+#define _QUAGGA_BGP_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(BGPD)
+DECLARE_MTYPE(BGP)
+DECLARE_MTYPE(BGP_LISTENER)
+DECLARE_MTYPE(BGP_PEER)
+DECLARE_MTYPE(BGP_PEER_HOST)
+DECLARE_MTYPE(BGP_PEER_IFNAME)
+DECLARE_MTYPE(PEER_GROUP)
+DECLARE_MTYPE(PEER_GROUP_HOST)
+DECLARE_MTYPE(PEER_DESC)
+DECLARE_MTYPE(PEER_PASSWORD)
+DECLARE_MTYPE(BGP_PEER_AF)
+DECLARE_MTYPE(BGP_UPDGRP)
+DECLARE_MTYPE(BGP_UPD_SUBGRP)
+DECLARE_MTYPE(BGP_PACKET)
+DECLARE_MTYPE(ATTR)
+DECLARE_MTYPE(ATTR_EXTRA)
+DECLARE_MTYPE(AS_PATH)
+DECLARE_MTYPE(AS_SEG)
+DECLARE_MTYPE(AS_SEG_DATA)
+DECLARE_MTYPE(AS_STR)
+
+DECLARE_MTYPE(BGP_TABLE)
+DECLARE_MTYPE(BGP_NODE)
+DECLARE_MTYPE(BGP_ROUTE)
+DECLARE_MTYPE(BGP_ROUTE_EXTRA)
+DECLARE_MTYPE(BGP_CONN)
+DECLARE_MTYPE(BGP_STATIC)
+DECLARE_MTYPE(BGP_ADVERTISE_ATTR)
+DECLARE_MTYPE(BGP_ADVERTISE)
+DECLARE_MTYPE(BGP_SYNCHRONISE)
+DECLARE_MTYPE(BGP_ADJ_IN)
+DECLARE_MTYPE(BGP_ADJ_OUT)
+DECLARE_MTYPE(BGP_MPATH_INFO)
+
+DECLARE_MTYPE(AS_LIST)
+DECLARE_MTYPE(AS_FILTER)
+DECLARE_MTYPE(AS_FILTER_STR)
+
+DECLARE_MTYPE(COMMUNITY)
+DECLARE_MTYPE(COMMUNITY_VAL)
+DECLARE_MTYPE(COMMUNITY_STR)
+
+DECLARE_MTYPE(ECOMMUNITY)
+DECLARE_MTYPE(ECOMMUNITY_VAL)
+DECLARE_MTYPE(ECOMMUNITY_STR)
+
+DECLARE_MTYPE(COMMUNITY_LIST)
+DECLARE_MTYPE(COMMUNITY_LIST_NAME)
+DECLARE_MTYPE(COMMUNITY_LIST_ENTRY)
+DECLARE_MTYPE(COMMUNITY_LIST_CONFIG)
+DECLARE_MTYPE(COMMUNITY_LIST_HANDLER)
+
+DECLARE_MTYPE(CLUSTER)
+DECLARE_MTYPE(CLUSTER_VAL)
+
+DECLARE_MTYPE(BGP_PROCESS_QUEUE)
+DECLARE_MTYPE(BGP_CLEAR_NODE_QUEUE)
+
+DECLARE_MTYPE(TRANSIT)
+DECLARE_MTYPE(TRANSIT_VAL)
+
+DECLARE_MTYPE(BGP_DEBUG_FILTER)
+DECLARE_MTYPE(BGP_DEBUG_STR)
+
+DECLARE_MTYPE(BGP_DISTANCE)
+DECLARE_MTYPE(BGP_NEXTHOP_CACHE)
+DECLARE_MTYPE(BGP_CONFED_LIST)
+DECLARE_MTYPE(PEER_UPDATE_SOURCE)
+DECLARE_MTYPE(PEER_CONF_IF)
+DECLARE_MTYPE(BGP_DAMP_INFO)
+DECLARE_MTYPE(BGP_DAMP_ARRAY)
+DECLARE_MTYPE(BGP_REGEXP)
+DECLARE_MTYPE(BGP_AGGREGATE)
+DECLARE_MTYPE(BGP_ADDR)
+
+DECLARE_MTYPE(BGP_REDIST)
+DECLARE_MTYPE(BGP_FILTER_NAME)
+DECLARE_MTYPE(BGP_DUMP_STR)
+DECLARE_MTYPE(ENCAP_TLV)
+
+#endif /* _QUAGGA_BGP_MEMORY_H */
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index c22dbb05a9..5c1df6715c 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -559,10 +559,9 @@ enum bgp_show_type
};
static int
-bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type type,
- void *output_arg, int tags, u_char use_json)
+bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
+ enum bgp_show_type type, void *output_arg, int tags, u_char use_json)
{
- afi_t afi = AFI_IP;
struct bgp *bgp;
struct bgp_table *table;
struct bgp_node *rn;
@@ -572,6 +571,8 @@ bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type ty
int header = 1;
char v4_header[] = " Network Next Hop Metric LocPrf Weight Path%s";
char v4_header_tag[] = " Network Next Hop In tag/Out tag%s";
+ unsigned long output_count = 0;
+ unsigned long total_count = 0;
json_object *json = NULL;
json_object *json_mroute = NULL;
json_object *json_nroute = NULL;
@@ -624,6 +625,7 @@ bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type ty
for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
{
+ total_count++;
if (use_json)
json_array = json_object_new_array();
else
@@ -712,6 +714,7 @@ bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type ty
route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_MPLS_VPN, json_array);
else
route_vty_out (vty, &rm->p, ri, 0, SAFI_MPLS_VPN, json_array);
+ output_count++;
}
if (use_json)
@@ -743,9 +746,87 @@ bgp_show_mpls_vpn (struct vty *vty, struct prefix_rd *prd, enum bgp_show_type ty
vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
json_object_free(json);
}
+ else
+ {
+ if (output_count == 0)
+ vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
+ else
+ vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
+ VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
+ }
+
return CMD_SUCCESS;
}
+DEFUN (show_bgp_ivp4_vpn,
+ show_bgp_ipv4_vpn_cmd,
+ "show bgp ipv4 vpn {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n")
+{
+ return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_vpn,
+ show_bgp_ipv6_vpn_cmd,
+ "show bgp ipv6 vpn {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n")
+{
+ return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv4_vpn_rd,
+ show_bgp_ipv4_vpn_rd_cmd,
+ "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n"
+ "Display information for a route distinguisher\n"
+ "VPN Route Distinguisher\n"
+ JSON_STR)
+{
+ int ret;
+ struct prefix_rd prd;
+
+ ret = str2prefix_rd (argv[0], &prd);
+ if (! ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_vpn_rd,
+ show_bgp_ipv6_vpn_rd_cmd,
+ "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n"
+ "Display information for a route distinguisher\n"
+ "VPN Route Distinguisher\n"
+ JSON_STR)
+{
+ int ret;
+ struct prefix_rd prd;
+
+ ret = str2prefix_rd (argv[0], &prd);
+ if (!ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv));
+}
+
DEFUN (show_ip_bgp_vpnv4_all,
show_ip_bgp_vpnv4_all_cmd,
"show ip bgp vpnv4 all",
@@ -755,7 +836,7 @@ DEFUN (show_ip_bgp_vpnv4_all,
"Display VPNv4 NLRI specific information\n"
"Display information about all VPNv4 NLRIs\n")
{
- return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_normal, NULL, 0, 0);
+ return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0);
}
DEFUN (show_ip_bgp_vpnv4_rd,
@@ -777,7 +858,7 @@ DEFUN (show_ip_bgp_vpnv4_rd,
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_normal, NULL, 0, 0);
+ return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, 0);
}
DEFUN (show_ip_bgp_vpnv4_all_tags,
@@ -790,7 +871,7 @@ DEFUN (show_ip_bgp_vpnv4_all_tags,
"Display information about all VPNv4 NLRIs\n"
"Display BGP tags for prefixes\n")
{
- return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_normal, NULL, 1, 0);
+ return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1, 0);
}
DEFUN (show_ip_bgp_vpnv4_rd_tags,
@@ -813,7 +894,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags,
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_normal, NULL, 1, 0);
+ return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1, 0);
}
DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
@@ -866,7 +947,7 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes,
return CMD_WARNING;
}
- return bgp_show_mpls_vpn (vty, NULL, bgp_show_type_neighbor, &su, 0, uj);
+ return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0, uj);
}
DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
@@ -937,7 +1018,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes,
return CMD_WARNING;
}
- return bgp_show_mpls_vpn (vty, &prd, bgp_show_type_neighbor, &su, 0, uj);
+ return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0, uj);
}
DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes,
@@ -1069,7 +1150,10 @@ bgp_mplsvpn_init (void)
install_element (BGP_VPNV4_NODE, &vpnv4_network_route_map_cmd);
install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd);
-
+ install_element (VIEW_NODE, &show_bgp_ipv4_vpn_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd);
@@ -1079,6 +1163,10 @@ bgp_mplsvpn_init (void)
install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_tags_cmd);
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index a6e9b7de00..bceeea6489 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -253,7 +253,7 @@ bgp_get_instance_for_inc_conn (int sock, struct bgp **bgp_inst)
rc = getsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, name, &name_len);
if (rc != 0)
{
-#if !defined (HAVE_BGP_STANDALONE)
+#if defined (HAVE_CUMULUS)
zlog_err ("[Error] BGP SO_BINDTODEVICE get failed (%s), sock %d",
safe_strerror (errno), sock);
return -1;
@@ -674,9 +674,9 @@ bgp_getsockname (struct peer *peer)
if (bgp_nexthop_set (peer->su_local, peer->su_remote,
&peer->nexthop, peer))
{
+#if defined (HAVE_CUMULUS)
zlog_err ("%s: nexthop_set failed, resetting connection - intf %p",
peer->host, peer->nexthop.ifp);
-#if !defined (HAVE_BGP_STANDALONE)
return -1;
#endif
}
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 1e5c4cf8b0..19f5428d88 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -47,8 +47,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "zebra/rib.h"
#include "zebra/zserv.h" /* For ZEBRA_SERV_PATH. */
-
-
char *
bnc_str (struct bgp_nexthop_cache *bnc, char *buf, int size)
{
@@ -59,14 +57,7 @@ bnc_str (struct bgp_nexthop_cache *bnc, char *buf, int size)
void
bnc_nexthop_free (struct bgp_nexthop_cache *bnc)
{
- struct nexthop *nexthop;
- struct nexthop *next = NULL;
-
- for (nexthop = bnc->nexthop; nexthop; nexthop = next)
- {
- next = nexthop->next;
- XFREE (MTYPE_NEXTHOP, nexthop);
- }
+ nexthops_free(bnc->nexthop);
}
struct bgp_nexthop_cache *
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index 6001092ce2..02026a004a 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -39,6 +39,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_open.h"
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_vty.h"
+#include "bgpd/bgp_memory.h"
/* BGP-4 Multiprotocol Extentions lead us to the complex world. We can
negotiate remote peer supports extentions or not. But if
@@ -638,17 +639,17 @@ bgp_capability_hostname (struct peer *peer, struct capability_header *hdr)
if (peer->hostname != NULL)
{
- XFREE(MTYPE_HOST, peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
peer->hostname = NULL;
}
if (peer->domainname != NULL)
{
- XFREE(MTYPE_HOST, peer->domainname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer->domainname = NULL;
}
- peer->hostname = XSTRDUP(MTYPE_HOST, str);
+ peer->hostname = XSTRDUP(MTYPE_BGP_PEER_HOST, str);
}
if (stream_get_getp(s) +1 > end)
@@ -678,7 +679,7 @@ bgp_capability_hostname (struct peer *peer, struct capability_header *hdr)
if (len)
{
str[len] = '\0';
- peer->domainname = XSTRDUP(MTYPE_HOST, str);
+ peer->domainname = XSTRDUP(MTYPE_BGP_PEER_HOST, str);
}
if (bgp_debug_neighbor_events(peer))
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 2f9fdd5a75..ae54cd43d3 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1163,7 +1163,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
{
if (!peer->nexthop.v4.s_addr)
{
-#if !defined (HAVE_BGP_STANDALONE)
+#if defined (HAVE_CUMULUS)
zlog_err ("%s: No local IPv4 addr resetting connection, fd %d",
peer->host, peer->fd);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_SUBCODE_UNSPECIFIC);
@@ -1178,7 +1178,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
{
if (IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_global))
{
-#if !defined (HAVE_BGP_STANDALONE)
+#if defined (HAVE_CUMULUS)
zlog_err ("%s: No local IPv6 addr resetting connection, fd %d",
peer->host, peer->fd);
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_SUBCODE_UNSPECIFIC);
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 7295ff147f..67ea246c1e 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -8022,6 +8022,42 @@ DEFUN (show_bgp_ipv4_safi_route_pathtype,
return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
}
+DEFUN (show_bgp_ipv4_prefix,
+ show_bgp_ipv4_prefix_cmd,
+ "show bgp ipv4 A.B.C.D/M {json}",
+ SHOW_STR
+ BGP_STR
+ IP_STR
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ JSON_STR)
+{
+ return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_route,
+ show_bgp_ipv6_route_cmd,
+ "show bgp ipv6 X:X::X:X {JSON}",
+ SHOW_STR
+ BGP_STR
+ "Address family\n"
+ "Network in the BGP routing table to display\n"
+ JSON_STR)
+{
+ return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_prefix,
+ show_bgp_ipv6_prefix_cmd,
+ "show bgp ipv6 X:X::X:X/M {json}",
+ SHOW_STR
+ BGP_STR
+ IP_STR
+ "IPv6 prefix <network>/<length>\n"
+ JSON_STR)
+{
+ return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv));
+}
+
DEFUN (show_ip_bgp_ipv4_route,
show_ip_bgp_ipv4_route_cmd,
"show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
@@ -8067,6 +8103,79 @@ DEFUN (show_ip_bgp_vpnv4_all_route,
return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
}
+DEFUN (show_bgp_ipv4_vpn_route,
+ show_bgp_ipv4_vpn_route_cmd,
+ "show bgp ipv4 vpn A.B.C.D {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n"
+ "Network in the BGP routing table to display\n"
+ JSON_STR)
+{
+ return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_vpn_route,
+ show_bgp_ipv6_vpn_route_cmd,
+ "show bgp ipv6 vpn X:X::X:X {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n"
+ "Network in the BGP routing table to display\n"
+ JSON_STR)
+{
+ return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv4_vpn_rd_route,
+ show_bgp_ipv4_vpn_rd_route_cmd,
+ "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
+ SHOW_STR
+ BGP_STR
+ IP_STR
+ "Display VPN NLRI specific information\n"
+ "Display information for a route distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "Network in the BGP routing table to display\n"
+ JSON_STR)
+{
+ int ret;
+ struct prefix_rd prd;
+
+ ret = str2prefix_rd (argv[0], &prd);
+ if (! ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
+
+DEFUN (show_bgp_ipv6_vpn_rd_route,
+ show_bgp_ipv6_vpn_rd_route_cmd,
+ "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
+ SHOW_STR
+ BGP_STR
+ "Address Family\n"
+ "Display VPN NLRI specific information\n"
+ "Display information for a route distinguisher\n"
+ "VPN Route Distinguisher\n"
+ "Network in the BGP routing table to display\n"
+ JSON_STR)
+{
+ int ret;
+ struct prefix_rd prd;
+
+ ret = str2prefix_rd (argv[0], &prd);
+ if (! ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
+}
DEFUN (show_ip_bgp_vpnv4_rd_route,
show_ip_bgp_vpnv4_rd_route_cmd,
@@ -8406,15 +8515,6 @@ DEFUN (show_bgp_route,
return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
}
-ALIAS (show_bgp_route,
- show_bgp_ipv6_route_cmd,
- "show bgp ipv6 X:X::X:X {json}",
- SHOW_STR
- BGP_STR
- "Address family\n"
- "Network in the BGP routing table to display\n"
- "JavaScript Object Notation\n")
-
DEFUN (show_bgp_ipv6_safi_route,
show_bgp_ipv6_safi_route_cmd,
"show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
@@ -8512,15 +8612,6 @@ DEFUN (show_bgp_prefix,
return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv));
}
-ALIAS (show_bgp_prefix,
- show_bgp_ipv6_prefix_cmd,
- "show bgp ipv6 X:X::X:X/M {json}",
- SHOW_STR
- BGP_STR
- "Address family\n"
- "IPv6 prefix <network>/<length>\n"
- "JavaScript Object Notation\n")
-
DEFUN (show_bgp_ipv6_safi_prefix,
show_bgp_ipv6_safi_prefix_cmd,
"show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
@@ -14757,6 +14848,18 @@ bgp_route_init (void)
install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
+
+ install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
+
/* BGP dampening clear commands */
install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
install_element (ENABLE_NODE, &clear_ip_bgp_dampening_prefix_cmd);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index c83d751743..012d1d25a2 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -30,6 +30,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 "queue.h"
#include "filter.h"
@@ -10246,7 +10247,7 @@ DEFUN (show_bgp_memory,
count * sizeof (struct peer)),
VTY_NEWLINE);
- if ((count = mtype_stats_alloc (MTYPE_BGP_PEER_GROUP)))
+ if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
vty_out (vty, "%ld peer groups, using %s of memory%s", count,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct peer_group)),
@@ -10739,6 +10740,33 @@ ALIAS (show_ip_bgp_ipv4_summary,
"Address Family modifier\n"
"Summary of BGP neighbor status\n")
+DEFUN (show_bgp_ipv4_vpn_summary,
+ show_bgp_ipv4_vpn_summary_cmd,
+ "show bgp ipv4 vpn summary {json}",
+ SHOW_STR
+ BGP_STR
+ "IPv4\n"
+ "Display VPN NLRI specific information\n"
+ "Summary of BGP neighbor status\n"
+ JSON_STR)
+{
+ return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv));
+}
+
+/* `show ip bgp summary' commands. */
+DEFUN (show_bgp_ipv6_vpn_summary,
+ show_bgp_ipv6_vpn_summary_cmd,
+ "show bgp ipv6 vpn summary {json}",
+ SHOW_STR
+ BGP_STR
+ "IPv6\n"
+ "Display VPN NLRI specific information\n"
+ "Summary of BGP neighbor status\n"
+ JSON_STR)
+{
+ return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv));
+}
+
DEFUN (show_ip_bgp_instance_ipv4_summary,
show_ip_bgp_instance_ipv4_summary_cmd,
"show ip bgp view WORD ipv4 (unicast|multicast) summary {json}",
@@ -16010,6 +16038,12 @@ bgp_vty_init (void)
install_element (ENABLE_NODE, &show_bgp_instance_ipv6_safi_summary_cmd);
#endif /* HAVE_IPV6 */
+ install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_summary_cmd);
+
+ install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_summary_cmd);
+
/* "show ip bgp neighbors" commands. */
install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd);
diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h
index ba520af067..573e8c7072 100644
--- a/bgpd/bgp_vty.h
+++ b/bgpd/bgp_vty.h
@@ -21,7 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGP_VTY_H
#define _QUAGGA_BGP_VTY_H
-#include "bgpd/bgpd.h"
+struct bgp;
#define CMD_AS_RANGE "<1-4294967295>"
#define DYNAMIC_NEIGHBOR_LIMIT_RANGE "<1-5000>"
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index bfde53d3e4..f4a16d6ba2 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -73,6 +73,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#endif /* HAVE_SNMP */
#include "bgpd/bgp_updgrp.h"
#include "bgpd/bgp_bfd.h"
+#include "bgpd/bgp_memory.h"
/* BGP process wide configuration. */
static struct bgp_master bgp_master;
@@ -2083,13 +2084,13 @@ peer_delete (struct peer *peer)
if (peer->hostname)
{
- XFREE(MTYPE_HOST, peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
peer->hostname = NULL;
}
if (peer->domainname)
{
- XFREE(MTYPE_HOST, peer->domainname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer->domainname = NULL;
}
@@ -2108,14 +2109,14 @@ peer_group_cmp (struct peer_group *g1, struct peer_group *g2)
static struct peer_group *
peer_group_new (void)
{
- return (struct peer_group *) XCALLOC (MTYPE_BGP_PEER_GROUP,
+ return (struct peer_group *) XCALLOC (MTYPE_PEER_GROUP,
sizeof (struct peer_group));
}
static void
peer_group_free (struct peer_group *group)
{
- XFREE (MTYPE_BGP_PEER_GROUP, group);
+ XFREE (MTYPE_PEER_GROUP, group);
}
struct peer_group *
@@ -2145,8 +2146,8 @@ peer_group_get (struct bgp *bgp, const char *name)
group = peer_group_new ();
group->bgp = bgp;
if (group->name)
- XFREE(MTYPE_BGP_PEER_GROUP_HOST, group->name);
- group->name = XSTRDUP(MTYPE_BGP_PEER_GROUP_HOST, name);
+ XFREE(MTYPE_PEER_GROUP_HOST, group->name);
+ group->name = XSTRDUP(MTYPE_PEER_GROUP_HOST, name);
group->peer = list_new ();
for (afi = AFI_IP; afi < AFI_MAX; afi++)
group->listen_range[afi] = list_new ();
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index e8827ca91f..a6d3b61e55 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -29,6 +29,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "sockunion.h"
#include "routemap.h"
#include "linklist.h"
+#include "bgp_memory.h"
#define BGP_MAX_HOSTNAME 64 /* Linux max, is larger than most other sys */
diff --git a/configure.ac b/configure.ac
index 8a1131d347..be8d27fbf6 100755
--- a/configure.ac
+++ b/configure.ac
@@ -26,12 +26,6 @@ AM_SILENT_RULES([yes])
AC_CONFIG_HEADERS(config.h)
AC_PATH_PROG(PERL, perl)
-AC_CHECK_PROG([GAWK],[gawk],[gawk],[not-in-PATH])
-if test "x$GAWK" = "xnot-in-PATH" ; then
- AC_MSG_ERROR([GNU awk is required for lib/memtype.h made by memtypes.awk.
-BSD awk complains: awk: gensub doesn't support backreferences (subst "\1") ])
-fi
-AC_ARG_VAR([GAWK],[GNU AWK])
dnl default is to match previous behavior
exampledir=${sysconfdir}
@@ -317,8 +311,6 @@ AC_ARG_ENABLE(werror,
AS_HELP_STRING([--enable-werror], [enable -Werror (recommended for developers only)]))
AC_ARG_ENABLE(cumulus,
AS_HELP_STRING([--enable-cumulus], [enable Cumulus Switch Special Extensions]))
-AC_ARG_ENABLE(bgp-standalone,
- AS_HELP_STRING([--enable-bgp-standalone], [Modify code to allow BGP to work without Zebra]))
AC_ARG_ENABLE(rr-semantics,
AS_HELP_STRING([--disable-rr-semantics], [disable the v6 Route Replace semantics]))
@@ -370,10 +362,6 @@ if test "${enable_cumulus}" = "yes" ; then
AC_DEFINE(HAVE_CUMULUS,,Compile Special Cumulus Code in)
fi
-if test "${enable_bgp_standalone}" = "yes" ; then
- AC_DEFINE(HAVE_BGP_STANDALONE,,Allow BGP to work without Zebra)
-fi
-
if test "${enable_shell_access}" = "yes"; then
AC_DEFINE(HAVE_SHELL_ACCESS,,Allow user to use ssh/telnet/bash)
fi
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 5c54484980..4a39f0b011 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -50,7 +50,7 @@ quagga_TEXINFOS = appendix.texi basic.texi bgpd.texi filter.texi \
install.texi ipv6.texi kernel.texi main.texi ospf6d.texi ospfd.texi \
overview.texi protocol.texi ripd.texi ripngd.texi routemap.texi \
snmp.texi vtysh.texi routeserver.texi defines.texi $(figures_png) \
- snmptrap.texi ospf_fundamentals.texi $(figures_txt)
+ snmptrap.texi ospf_fundamentals.texi isisd.texi $(figures_txt)
.png.eps:
$(PNGTOEPS) $< "$@"
diff --git a/isisd/Makefile.am b/isisd/Makefile.am
index bfe2e94779..c14351ca3a 100644
--- a/isisd/Makefile.am
+++ b/isisd/Makefile.am
@@ -13,6 +13,7 @@ sbin_PROGRAMS = isisd
SUBDIRS = topology
libisis_a_SOURCES = \
+ isis_memory.c \
isis_adjacency.c isis_lsp.c dict.c isis_circuit.c isis_pdu.c \
isis_tlv.c isisd.c isis_misc.c isis_zebra.c isis_dr.c \
isis_flags.c isis_dynhn.c iso_checksum.c isis_csm.c isis_events.c \
@@ -21,6 +22,7 @@ libisis_a_SOURCES = \
noinst_HEADERS = \
+ isis_memory.h \
isisd.h isis_pdu.h isis_tlv.h isis_adjacency.h isis_constants.h \
isis_lsp.h dict.h isis_circuit.h isis_misc.h isis_network.h \
isis_zebra.h isis_dr.h isis_flags.h isis_dynhn.h isis_common.h \
diff --git a/isisd/dict.c b/isisd/dict.c
index bbcb42134d..a038028d22 100644
--- a/isisd/dict.c
+++ b/isisd/dict.c
@@ -18,6 +18,7 @@
#include "zebra.h"
#include "zassert.h"
#include "memory.h"
+#include "isis_memory.h"
#include "dict.h"
/*
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 81ca1e20c6..163a4e051c 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/isisd/isis_memory.c b/isisd/isis_memory.c
new file mode 100644
index 0000000000..f3ecc6cd7a
--- /dev/null
+++ b/isisd/isis_memory.c
@@ -0,0 +1,48 @@
+/* isisd 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 Quagga; 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 "isis_memory.h"
+
+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_EXT_ROUTE, "ISIS redistributed route")
+DEFINE_MTYPE(ISISD, ISIS_EXT_INFO, "ISIS redistributed route info")
+DEFINE_MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters")
diff --git a/isisd/isis_memory.h b/isisd/isis_memory.h
new file mode 100644
index 0000000000..9345229daa
--- /dev/null
+++ b/isisd/isis_memory.h
@@ -0,0 +1,49 @@
+/* isisd 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_ISIS_MEMORY_H
+#define _QUAGGA_ISIS_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(ISISD)
+DECLARE_MTYPE(ISIS)
+DECLARE_MTYPE(ISIS_TMP)
+DECLARE_MTYPE(ISIS_CIRCUIT)
+DECLARE_MTYPE(ISIS_LSP)
+DECLARE_MTYPE(ISIS_ADJACENCY)
+DECLARE_MTYPE(ISIS_AREA)
+DECLARE_MTYPE(ISIS_AREA_ADDR)
+DECLARE_MTYPE(ISIS_TLV)
+DECLARE_MTYPE(ISIS_DYNHN)
+DECLARE_MTYPE(ISIS_SPFTREE)
+DECLARE_MTYPE(ISIS_VERTEX)
+DECLARE_MTYPE(ISIS_ROUTE_INFO)
+DECLARE_MTYPE(ISIS_NEXTHOP)
+DECLARE_MTYPE(ISIS_NEXTHOP6)
+DECLARE_MTYPE(ISIS_DICT)
+DECLARE_MTYPE(ISIS_DICT_NODE)
+DECLARE_MTYPE(ISIS_EXT_ROUTE)
+DECLARE_MTYPE(ISIS_EXT_INFO)
+DECLARE_MTYPE(ISIS_MPLS_TE)
+
+#endif /* _QUAGGA_ISIS_MEMORY_H */
diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c
index 690ae4720c..5311b5c69c 100644
--- a/isisd/isis_redist.c
+++ b/isisd/isis_redist.c
@@ -24,7 +24,7 @@
#include "if.h"
#include "linklist.h"
#include "memory.h"
-#include "memtypes.h"
+#include "isis_memory.h"
#include "prefix.h"
#include "routemap.h"
#include "stream.h"
@@ -95,7 +95,7 @@ isis_redist_route_node_create(route_table_delegate_t *delegate,
struct route_table *table)
{
struct route_node *node;
- node = XCALLOC(MTYPE_ROUTE_NODE, sizeof(*node));
+ node = XCALLOC(MTYPE_ISIS_EXT_ROUTE, sizeof(*node));
return node;
}
@@ -105,8 +105,8 @@ isis_redist_route_node_destroy(route_table_delegate_t *delegate,
struct route_node *node)
{
if (node->info)
- XFREE(MTYPE_ISIS, node->info);
- XFREE (MTYPE_ROUTE_NODE, node);
+ XFREE(MTYPE_ISIS_EXT_INFO, node->info);
+ XFREE (MTYPE_ISIS_EXT_ROUTE, node);
}
static route_table_delegate_t isis_redist_rt_delegate = {
@@ -143,7 +143,7 @@ isis_redist_install(struct isis_area *area, int level,
}
else
{
- er_node->info = XMALLOC(MTYPE_ISIS, sizeof(*info));
+ er_node->info = XMALLOC(MTYPE_ISIS_EXT_INFO, sizeof(*info));
}
memcpy(er_node->info, info, sizeof(*info));
@@ -243,7 +243,7 @@ isis_redist_ensure_default(struct isis *isis, int family)
return;
}
- ei_node->info = XCALLOC(MTYPE_ISIS, sizeof(struct isis_ext_info));
+ ei_node->info = XCALLOC(MTYPE_ISIS_EXT_INFO, sizeof(struct isis_ext_info));
info = ei_node->info;
info->origin = DEFAULT_ROUTE;
@@ -281,7 +281,7 @@ isis_redist_add(int type, struct prefix *p, u_char distance, uint32_t metric)
if (ei_node->info)
route_unlock_node(ei_node);
else
- ei_node->info = XCALLOC(MTYPE_ISIS, sizeof(struct isis_ext_info));
+ ei_node->info = XCALLOC(MTYPE_ISIS_EXT_INFO, sizeof(struct isis_ext_info));
info = ei_node->info;
info->origin = type;
@@ -537,20 +537,20 @@ isis_redist_area_finish(struct isis_area *area)
isis_redist_update_zebra_subscriptions(area->isis);
}
-DEFUN(isis_redistribute,
- isis_redistribute_cmd,
- "redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
- " (level-1|level-2) {metric <0-16777215>|route-map WORD}",
- REDIST_STR
- "Redistribute IPv4 routes\n"
- "Redistribute IPv6 routes\n"
- QUAGGA_REDIST_HELP_STR_ISISD
- "Redistribute into level-1\n"
- "Redistribute into level-2\n"
- "Metric for redistributed routes\n"
- "ISIS default metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
+DEFUN (isis_redistribute,
+ isis_redistribute_cmd,
+ "redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
+ " (level-1|level-2) {metric <0-16777215>|route-map WORD}",
+ REDIST_STR
+ "Redistribute IPv4 routes\n"
+ "Redistribute IPv6 routes\n"
+ QUAGGA_REDIST_HELP_STR_ISISD
+ "Redistribute into level-1\n"
+ "Redistribute into level-2\n"
+ "Metric for redistributed routes\n"
+ "ISIS default metric\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
{
struct isis_area *area = vty->index;
int family;
@@ -606,17 +606,17 @@ DEFUN(isis_redistribute,
return 0;
}
-DEFUN(no_isis_redistribute,
- no_isis_redistribute_cmd,
- "no redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
- " (level-1|level-2)",
- NO_STR
- REDIST_STR
- "Redistribute IPv4 routes\n"
- "Redistribute IPv6 routes\n"
- QUAGGA_REDIST_HELP_STR_ISISD
- "Redistribute into level-1\n"
- "Redistribute into level-2\n")
+DEFUN (no_isis_redistribute,
+ no_isis_redistribute_cmd,
+ "no redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD
+ " (level-1|level-2)",
+ NO_STR
+ REDIST_STR
+ "Redistribute IPv4 routes\n"
+ "Redistribute IPv6 routes\n"
+ QUAGGA_REDIST_HELP_STR_ISISD
+ "Redistribute into level-1\n"
+ "Redistribute into level-2\n")
{
struct isis_area *area = vty->index;
int type;
@@ -650,21 +650,21 @@ DEFUN(no_isis_redistribute,
return 0;
}
-DEFUN(isis_default_originate,
- isis_default_originate_cmd,
- "default-information originate (ipv4|ipv6) (level-1|level-2) "
- "{always|metric <0-16777215>|route-map WORD}",
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Distribute default route for IPv4\n"
- "Distribute default route for IPv6\n"
- "Distribute default route into level-1\n"
- "Distribute default route into level-2\n"
- "Always advertise default route\n"
- "Metric for default route\n"
- "ISIS default metric\n"
- "Route map reference\n"
- "Pointer to route-map entries\n")
+DEFUN (isis_default_originate,
+ isis_default_originate_cmd,
+ "default-information originate (ipv4|ipv6) (level-1|level-2) "
+ "{always|metric <0-16777215>|route-map WORD}",
+ "Control distribution of default information\n"
+ "Distribute a default route\n"
+ "Distribute default route for IPv4\n"
+ "Distribute default route for IPv6\n"
+ "Distribute default route into level-1\n"
+ "Distribute default route into level-2\n"
+ "Always advertise default route\n"
+ "Metric for default route\n"
+ "ISIS default metric\n"
+ "Route map reference\n"
+ "Pointer to route-map entries\n")
{
struct isis_area *area = vty->index;
int family;
@@ -722,16 +722,16 @@ DEFUN(isis_default_originate,
return 0;
}
-DEFUN(no_isis_default_originate,
- no_isis_default_originate_cmd,
- "no default-information originate (ipv4|ipv6) (level-1|level-2)",
- NO_STR
- "Control distribution of default information\n"
- "Distribute a default route\n"
- "Distribute default route for IPv4\n"
- "Distribute default route for IPv6\n"
- "Distribute default route into level-1\n"
- "Distribute default route into level-2\n")
+DEFUN (no_isis_default_originate,
+ no_isis_default_originate_cmd,
+ "no default-information originate (ipv4|ipv6) (level-1|level-2)",
+ NO_STR
+ "Control distribution of default information\n"
+ "Distribute a default route\n"
+ "Distribute default route for IPv4\n"
+ "Distribute default route for IPv6\n"
+ "Distribute default route into level-1\n"
+ "Distribute default route into level-2\n")
{
struct isis_area *area = vty->index;
diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c
index 3e0ab047ed..fdc0100e77 100644
--- a/isisd/isis_routemap.c
+++ b/isisd/isis_routemap.c
@@ -344,164 +344,160 @@ isis_route_set_delete (struct vty *vty, struct route_map_index *index,
/* ------------------------------------------------------------*/
-DEFUN(match_ip_address,
- match_ip_address_cmd,
- "match ip address (<1-199>|<1300-2699>|WORD)",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
+DEFUN (match_ip_address,
+ match_ip_address_cmd,
+ "match ip address (<1-199>|<1300-2699>|WORD)",
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
{
return isis_route_match_add(vty, vty->index, "ip address", argv[0]);
}
-DEFUN(no_match_ip_address,
- no_match_ip_address_val_cmd,
- "no match ip address (<1-199>|<1300-2699>|WORD)",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
+DEFUN (no_match_ip_address,
+ no_match_ip_address_val_cmd,
+ "no match ip address (<1-199>|<1300-2699>|WORD)",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
{
if (argc == 0)
return isis_route_match_delete(vty, vty->index, "ip address", NULL);
return isis_route_match_delete(vty, vty->index, "ip address", argv[0]);
}
-ALIAS(no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
-);
+ALIAS (no_match_ip_address,
+ no_match_ip_address_cmd,
+ "no match ip address",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n")
/* ------------------------------------------------------------*/
-DEFUN(match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
+DEFUN (match_ip_address_prefix_list,
+ match_ip_address_prefix_list_cmd,
+ "match ip address prefix-list WORD",
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
{
return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[0]);
}
-DEFUN(no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n")
+DEFUN (no_match_ip_address_prefix_list,
+ no_match_ip_address_prefix_list_cmd,
+ "no match ip address prefix-list",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n")
{
if (argc == 0)
return isis_route_match_delete (vty, vty->index, "ip address prefix-list", NULL);
return isis_route_match_delete (vty, vty->index, "ip address prefix-list", argv[0]);
}
-ALIAS(no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_val_cmd,
- "no match ip address prefix-list WORD",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n"
-);
+ALIAS (no_match_ip_address_prefix_list,
+ no_match_ip_address_prefix_list_val_cmd,
+ "no match ip address prefix-list WORD",
+ NO_STR
+ MATCH_STR
+ IP_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
/* ------------------------------------------------------------*/
-DEFUN(match_ipv6_address,
- match_ipv6_address_cmd,
- "match ipv6 address WORD",
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
+DEFUN (match_ipv6_address,
+ match_ipv6_address_cmd,
+ "match ipv6 address WORD",
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 address of route\n"
+ "IPv6 access-list name\n")
{
return isis_route_match_add(vty, vty->index, "ipv6 address", argv[0]);
}
-DEFUN(no_match_ipv6_address,
- no_match_ipv6_address_val_cmd,
- "no match ipv6 address WORD",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
- "IPv6 access-list name\n")
+DEFUN (no_match_ipv6_address,
+ no_match_ipv6_address_val_cmd,
+ "no match ipv6 address WORD",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 address of route\n"
+ "IPv6 access-list name\n")
{
if (argc == 0)
return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL);
return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[0]);
}
-ALIAS(no_match_ipv6_address,
- no_match_ipv6_address_cmd,
- "no match ipv6 address",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match IPv6 address of route\n"
-);
+ALIAS (no_match_ipv6_address,
+ no_match_ipv6_address_cmd,
+ "no match ipv6 address",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match IPv6 address of route\n")
/* ------------------------------------------------------------*/
-DEFUN(match_ipv6_address_prefix_list,
- match_ipv6_address_prefix_list_cmd,
- "match ipv6 address prefix-list WORD",
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
+DEFUN (match_ipv6_address_prefix_list,
+ match_ipv6_address_prefix_list_cmd,
+ "match ipv6 address prefix-list WORD",
+ MATCH_STR
+ IPV6_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
{
return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[0]);
}
-DEFUN(no_match_ipv6_address_prefix_list,
- no_match_ipv6_address_prefix_list_cmd,
- "no match ipv6 address prefix-list",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n")
+DEFUN (no_match_ipv6_address_prefix_list,
+ no_match_ipv6_address_prefix_list_cmd,
+ "no match ipv6 address prefix-list",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n")
{
if (argc == 0)
return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", NULL);
return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[0]);
}
-ALIAS(no_match_ipv6_address_prefix_list,
- no_match_ipv6_address_prefix_list_val_cmd,
- "no match ipv6 address prefix-list WORD",
- NO_STR
- MATCH_STR
- IPV6_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n"
-);
+ALIAS (no_match_ipv6_address_prefix_list,
+ no_match_ipv6_address_prefix_list_val_cmd,
+ "no match ipv6 address prefix-list WORD",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match address of route\n"
+ "Match entries of prefix-lists\n"
+ "IP prefix-list name\n")
/* ------------------------------------------------------------*/
/* set metric already exists e.g. in the ospf routemap. vtysh doesn't cope well with different
* commands at the same node, therefore add set metric with the same 32-bit range as ospf and
* verify that the input is a valid isis metric */
-DEFUN(set_metric,
+DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
SET_STR
@@ -511,7 +507,7 @@ DEFUN(set_metric,
return isis_route_set_add(vty, vty->index, "metric", argv[0]);
}
-DEFUN(no_set_metric,
+DEFUN (no_set_metric,
no_set_metric_val_cmd,
"no set metric <0-4294967295>",
NO_STR
@@ -524,13 +520,12 @@ DEFUN(no_set_metric,
return isis_route_set_delete(vty, vty->index, "metric", argv[0]);
}
-ALIAS(no_set_metric,
- no_set_metric_cmd,
- "no set metric",
- NO_STR
- SET_STR
- "Metric vale for destination routing protocol\n"
-);
+ALIAS (no_set_metric,
+ no_set_metric_cmd,
+ "no set metric",
+ NO_STR
+ SET_STR
+ "Metric vale for destination routing protocol\n");
void
isis_route_map_init(void)
diff --git a/isisd/isis_te.c b/isisd/isis_te.c
index deaaa7104b..022722f760 100644
--- a/isisd/isis_te.c
+++ b/isisd/isis_te.c
@@ -1,7 +1,7 @@
/*
* IS-IS Rout(e)ing protocol - isis_te.c
*
- * This is an implementation of RFC5305
+ * This is an implementation of RFC5305 & RFC 7810
*
* Copyright (C) 2014 Orange Labs
* http://www.orange.com
diff --git a/isisd/isis_te.h b/isisd/isis_te.h
index 4cec1735ae..1578d37706 100644
--- a/isisd/isis_te.h
+++ b/isisd/isis_te.h
@@ -1,7 +1,7 @@
/*
* IS-IS Rout(e)ing protocol - isis_te.c
*
- * This is an implementation of RFC5305, RFC 5307 and draft-ietf-isis-te-metric-extensions-11
+ * This is an implementation of RFC5305, RFC 5307 and RFC 7810
*
* Copyright (C) 2014 Orange Labs
* http://www.orange.com
@@ -183,7 +183,7 @@ struct te_subtlv_rip
} __attribute__((__packed__));
-/* draft-ietf-isis-te-metric-extensions-11.txt */
+/* TE Metric Extensions - RFC 7810 */
/* Link Sub-TLV: Average Link Delay */
#define TE_SUBTLV_AV_DELAY 33
struct te_subtlv_av_delay
@@ -305,7 +305,7 @@ struct mpls_te_circuit
/* RFC5316 */
struct te_subtlv_ras ras;
struct te_subtlv_rip rip;
- /* draft-ietf-isis-te-metric-extension */
+ /* RFC7810 */
struct te_subtlv_av_delay av_delay;
struct te_subtlv_mm_delay mm_delay;
struct te_subtlv_delay_var delay_var;
diff --git a/isisd/isis_vty.c b/isisd/isis_vty.c
index 4148eb55b9..53c635ea61 100644
--- a/isisd/isis_vty.c
+++ b/isisd/isis_vty.c
@@ -1566,21 +1566,21 @@ DEFUN (area_lsp_mtu,
return area_lsp_mtu_set(vty, lsp_mtu);
}
-DEFUN(no_area_lsp_mtu,
- no_area_lsp_mtu_cmd,
- "no lsp-mtu",
- NO_STR
- "Configure the maximum size of generated LSPs\n")
+DEFUN (no_area_lsp_mtu,
+ no_area_lsp_mtu_cmd,
+ "no lsp-mtu",
+ NO_STR
+ "Configure the maximum size of generated LSPs\n")
{
return area_lsp_mtu_set(vty, DEFAULT_LSP_MTU);
}
-ALIAS(no_area_lsp_mtu,
- no_area_lsp_mtu_arg_cmd,
- "no lsp-mtu <128-4352>",
- NO_STR
- "Configure the maximum size of generated LSPs\n"
- "Maximum size of generated LSPs\n");
+ALIAS (no_area_lsp_mtu,
+ no_area_lsp_mtu_arg_cmd,
+ "no lsp-mtu <128-4352>",
+ NO_STR
+ "Configure the maximum size of generated LSPs\n"
+ "Maximum size of generated LSPs\n");
DEFUN (is_type,
is_type_cmd,
diff --git a/isisd/isisd.c b/isisd/isisd.c
index 5a90115127..4d7f475616 100644
--- a/isisd/isisd.c
+++ b/isisd/isisd.c
@@ -1236,7 +1236,7 @@ DEFUN (debug_isis_lsp_sched,
DEFUN (no_debug_isis_lsp_sched,
no_debug_isis_lsp_sched_cmd,
- "no debug isis lsp-gen",
+ "no debug isis lsp-sched",
UNDEBUG_STR
"IS-IS information\n"
"IS-IS scheduling of LSP generation\n")
diff --git a/isisd/isisd.h b/isisd/isisd.h
index 9a4f360a2b..ca3e570063 100644
--- a/isisd/isisd.h
+++ b/isisd/isisd.h
@@ -32,6 +32,7 @@
#include "isisd/isis_redist.h"
#include "isis_flags.h"
#include "dict.h"
+#include "isis_memory.h"
/* uncomment if you are a developer in bug hunt */
/* #define EXTREME_DEBUG */
diff --git a/lib/.gitignore b/lib/.gitignore
index 8174bda7d8..e45fec1786 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -14,7 +14,6 @@ gitversion.h.tmp
.arch-ids
*~
*.loT
-memtypes.h
route_types.h
command_lex.c
command_parse.c
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3dfd09e2e6..acaf7e6744 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -13,13 +13,13 @@ libzebra_la_SOURCES = \
checksum.c vector.c linklist.c vty.c \
graph.c command_parse.y command_lex.l command_match.c \
command.c \
- sockunion.c prefix.c thread.c if.c memory.c buffer.c table.c hash.c \
+ 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 \
- ptm_lib.c csv.c bfd.c vrf.c systemd.c ns.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 command_parse.h
+BUILT_SOURCES = route_types.h gitversion.h command_parse.h
libzebra_la_DEPENDENCIES = @LIB_REGEX@
@@ -33,9 +33,10 @@ 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
+ ptm_lib.h csv.h bfd.h vrf.h ns.h systemd.h bitfield.h \
+ fifo.h memory_vty.h
noinst_HEADERS = \
plist_int.h
@@ -43,13 +44,9 @@ noinst_HEADERS = \
EXTRA_DIST = \
regex.c regex-gnu.h \
queue.h \
- memtypes.awk \
route_types.pl route_types.txt \
gitversion.pl
-memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.awk
- ($(GAWK) -f $(srcdir)/memtypes.awk $(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/bfd.c b/lib/bfd.c
index 67a84c95f9..a498daf762 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -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 ee9310100e..1dfcdb4732 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 b4ef30a300..b6f97c317e 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -34,10 +34,13 @@ Boston, MA 02111-1307, USA. */
#include "command.h"
#include "workqueue.h"
#include "vrf.h"
-
#include "command_match.h"
#include "command_parse.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 5e1b48c68f..ddb61c686f 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -27,6 +27,12 @@
#include "vty.h"
#include "lib/route_types.h"
#include "graph.h"
+#include "memory.h"
+
+DECLARE_MTYPE(HOST)
+
+/* for test-commands.c */
+DECLARE_MTYPE(STRVEC)
/* Host configuration variable */
struct host
diff --git a/lib/command_match.c b/lib/command_match.c
index d7c2222ce6..dd68ca477e 100644
--- a/lib/command_match.c
+++ b/lib/command_match.c
@@ -23,10 +23,13 @@
*/
#include <zebra.h>
+
#include "command_match.h"
#include "command_parse.h"
#include "memory.h"
+DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens")
+
/* matcher helper prototypes */
static int
add_nexthops (struct list *, struct graph_node *);
diff --git a/lib/command_parse.y b/lib/command_parse.y
index 089b506b03..6a5d75aabf 100644
--- a/lib/command_parse.y
+++ b/lib/command_parse.y
@@ -33,9 +33,10 @@
/* required external units */
%code requires {
+ #include "stdlib.h"
+ #include "string.h"
#include "command.h"
#include "graph.h"
- #include "memory.h"
extern int
yylex (void);
@@ -145,7 +146,7 @@
set_lexer_string (element->string);
/* copy docstring and keep a pointer to the copy */
- docstr = element->doc ? XSTRDUP(MTYPE_TMP, element->doc) : NULL;
+ docstr = element->doc ? strdup(element->doc) : NULL;
docstr_start = docstr;
}
@@ -174,7 +175,7 @@ start:
sentence_root: WORD
{
struct graph_node *root =
- new_token_node (graph, WORD_TKN, XSTRDUP (MTYPE_CMD_TOKENS, $1), doc_next());
+ new_token_node (graph, WORD_TKN, strdup ($1), doc_next());
if ((currnode = add_edge_dedup (startnode, root)) != root)
graph_delete_node (graph, root);
@@ -199,7 +200,7 @@ cmd_token:
{
graph_add_edge (currnode, $1->start);
currnode = $1->end;
- XFREE (MTYPE_TMP, $1);
+ free ($1);
}
;
@@ -215,7 +216,7 @@ compound_token:
literal_token: WORD
{
- $$ = new_token_node (graph, WORD_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, WORD_TKN, strdup($1), doc_next());
free ($1);
}
;
@@ -223,32 +224,32 @@ literal_token: WORD
placeholder_token:
IPV4
{
- $$ = new_token_node (graph, IPV4_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, IPV4_TKN, strdup($1), doc_next());
free ($1);
}
| IPV4_PREFIX
{
- $$ = new_token_node (graph, IPV4_PREFIX_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, IPV4_PREFIX_TKN, strdup($1), doc_next());
free ($1);
}
| IPV6
{
- $$ = new_token_node (graph, IPV6_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, IPV6_TKN, strdup($1), doc_next());
free ($1);
}
| IPV6_PREFIX
{
- $$ = new_token_node (graph, IPV6_PREFIX_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, IPV6_PREFIX_TKN, strdup($1), doc_next());
free ($1);
}
| VARIABLE
{
- $$ = new_token_node (graph, VARIABLE_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, VARIABLE_TKN, strdup($1), doc_next());
free ($1);
}
| RANGE
{
- $$ = new_token_node (graph, RANGE_TKN, XSTRDUP(MTYPE_CMD_TOKENS, $1), doc_next());
+ $$ = new_token_node (graph, RANGE_TKN, strdup($1), doc_next());
struct cmd_token *token = $$->data;
// get the numbers out
@@ -266,7 +267,7 @@ placeholder_token:
/* <selector|set> productions */
selector: '<' selector_seq_seq '>'
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = new_token_node (graph, SELECTOR_TKN, NULL, NULL);
$$->end = new_token_node (graph, NUL_TKN, NULL, NULL);
for (unsigned int i = 0; i < vector_active ($2->start->to); i++)
@@ -278,20 +279,20 @@ selector: '<' selector_seq_seq '>'
}
graph_delete_node (graph, $2->start);
graph_delete_node (graph, $2->end);
- XFREE (MTYPE_TMP, $2);
+ free ($2);
};
selector_seq_seq:
selector_seq_seq '|' selector_token_seq
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = graph_new_node (graph, NULL, NULL);
$$->end = graph_new_node (graph, NULL, NULL);
// link in last sequence
graph_add_edge ($$->start, $3->start);
graph_add_edge ($3->end, $$->end);
- XFREE (MTYPE_TMP, $3);
+ free ($3);
for (unsigned int i = 0; i < vector_active ($1->start->to); i++)
{
@@ -302,44 +303,44 @@ selector_seq_seq:
}
graph_delete_node (graph, $1->start);
graph_delete_node (graph, $1->end);
- XFREE (MTYPE_TMP, $1);
- XFREE (MTYPE_TMP, $3);
+ free ($1);
+ free ($3);
}
| selector_token_seq '|' selector_token_seq
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = graph_new_node (graph, NULL, NULL);
$$->end = graph_new_node (graph, NULL, NULL);
graph_add_edge ($$->start, $1->start);
graph_add_edge ($1->end, $$->end);
graph_add_edge ($$->start, $3->start);
graph_add_edge ($3->end, $$->end);
- XFREE (MTYPE_TMP, $1);
- XFREE (MTYPE_TMP, $3);
+ free ($1);
+ free ($3);
}
;
selector_token_seq:
simple_token
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| selector_token_seq selector_token
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
graph_add_edge ($1->end, $2->start);
$$->start = $1->start;
$$->end = $2->end;
- XFREE (MTYPE_TMP, $1);
- XFREE (MTYPE_TMP, $2);
+ free ($1);
+ free ($2);
}
;
selector_token:
simple_token
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| option
@@ -349,7 +350,7 @@ selector_token:
option: '[' option_token_seq ']'
{
// make a new option
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = new_token_node (graph, OPTION_TKN, NULL, NULL);
$$->end = new_token_node (graph, NUL_TKN, NULL, NULL);
// add a path through the sequence to the end
@@ -357,7 +358,7 @@ option: '[' option_token_seq ']'
graph_add_edge ($2->end, $$->end);
// add a path directly from the start to the end
graph_add_edge ($$->start, $$->end);
- XFREE (MTYPE_TMP, $2);
+ free ($2);
}
;
@@ -365,18 +366,18 @@ option_token_seq:
option_token
| option_token_seq option_token
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
graph_add_edge ($1->end, $2->start);
$$->start = $1->start;
$$->end = $2->end;
- XFREE (MTYPE_TMP, $1);
+ free ($1);
}
;
option_token:
simple_token
{
- $$ = XMALLOC (MTYPE_TMP, sizeof (struct subgraph));
+ $$ = malloc (sizeof (struct subgraph));
$$->start = $$->end = $1;
}
| compound_token
@@ -429,8 +430,8 @@ terminate_graph (struct graph *graph, struct graph_node *finalnode, struct cmd_e
struct graph_node *end_token_node =
new_token_node (graph,
END_TKN,
- XSTRDUP (MTYPE_CMD_TOKENS, CMD_CR_TEXT),
- XSTRDUP (MTYPE_CMD_TOKENS, ""));
+ strdup (CMD_CR_TEXT),
+ strdup (""));
struct graph_node *end_element_node =
graph_new_node (graph, element, (void (*)(void *)) &del_cmd_element);
@@ -446,8 +447,8 @@ doc_next()
{
char *piece = NULL;
if (!docstr || !(piece = strsep (&docstr, "\n")))
- return XSTRDUP (MTYPE_CMD_TOKENS, "");
- return XSTRDUP (MTYPE_CMD_TOKENS, piece);
+ return strdup ("");
+ return strdup (piece);
}
static struct graph_node *
diff --git a/lib/distribute.c b/lib/distribute.c
index 757525fd71..d0d637fbb4 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/fifo.h b/lib/fifo.h
new file mode 100644
index 0000000000..6be75b7611
--- /dev/null
+++ b/lib/fifo.h
@@ -0,0 +1,62 @@
+/* FIFO common header.
+ Copyright (C) 2015 Kunihiro Ishiguro
+
+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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+#ifndef __LIB_FIFO_H__
+#define __LIB_FIFO_H__
+
+/* FIFO -- first in first out structure and macros. */
+struct fifo
+{
+ struct fifo *next;
+ struct fifo *prev;
+};
+
+#define FIFO_INIT(F) \
+ do { \
+ struct fifo *Xfifo = (struct fifo *)(F); \
+ Xfifo->next = Xfifo->prev = Xfifo; \
+ } while (0)
+
+#define FIFO_ADD(F,N) \
+ do { \
+ struct fifo *Xfifo = (struct fifo *)(F); \
+ struct fifo *Xnode = (struct fifo *)(N); \
+ Xnode->next = Xfifo; \
+ Xnode->prev = Xfifo->prev; \
+ Xfifo->prev = Xfifo->prev->next = Xnode; \
+ } while (0)
+
+#define FIFO_DEL(N) \
+ do { \
+ struct fifo *Xnode = (struct fifo *)(N); \
+ Xnode->prev->next = Xnode->next; \
+ Xnode->next->prev = Xnode->prev; \
+ } while (0)
+
+#define FIFO_HEAD(F) \
+ ((((struct fifo *)(F))->next == (struct fifo *)(F)) \
+ ? NULL : (F)->next)
+
+#define FIFO_EMPTY(F) \
+ (((struct fifo *)(F))->next == (struct fifo *)(F))
+
+#define FIFO_TOP(F) \
+ (FIFO_EMPTY(F) ? NULL : ((struct fifo *)(F))->next)
+
+#endif /* __LIB_FIFO_H__ */
diff --git a/lib/filter.c b/lib/filter.c
index 0eeb8f1872..e9ba715c92 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/graph.c b/lib/graph.c
index 7c59fe95b5..891ecc33c0 100644
--- a/lib/graph.c
+++ b/lib/graph.c
@@ -25,6 +25,8 @@
#include "graph.h"
#include "memory.h"
+DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph")
+DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node")
struct graph *
graph_new ()
{
diff --git a/lib/hash.c b/lib/hash.c
index a20093cd64..cb8531fccf 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 0bc3089f34..11ecf75ec9 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. */
diff --git a/lib/if.c b/lib/if.c
index e44882a43e..bd6079c0fd 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -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;
diff --git a/lib/if.h b/lib/if.h
index 17f8565595..d1875e695a 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -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 f2d76c69d6..736f2e237d 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/json.h b/lib/json.h
index 561f7cc405..5dbad601a3 100644
--- a/lib/json.h
+++ b/lib/json.h
@@ -40,4 +40,6 @@ extern void json_object_boolean_true_add(struct json_object* obj,
extern struct json_object* json_object_lock(struct json_object *obj);
extern void json_object_free(struct json_object *obj);
+#define JSON_STR "JavaScript Object Notation\n"
+
#endif /* _QUAGGA_JSON_H */
diff --git a/lib/keychain.c b/lib/keychain.c
index c4a007edd0..ac2083cf4b 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 d27a2da848..6fe91c75fc 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)
diff --git a/lib/log.c b/lib/log.c
index ea50ae18cc..b9edb12fbd 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -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;
@@ -680,6 +682,14 @@ _zlog_assert_failed (const char *assertion, const char *file,
abort();
}
+void
+memory_oom (size_t size, const char *name)
+{
+ zlog_err("out of memory: failed to allocate %zu bytes for %s"
+ "object", size, name);
+ zlog_backtrace(LOG_ERR);
+ abort();
+}
/* Open log stream */
struct zlog *
@@ -898,11 +908,6 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY (ZEBRA_REDISTRIBUTE_DELETE),
DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_ADD),
DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE),
- DESC_ENTRY (ZEBRA_IPV4_NEXTHOP_LOOKUP),
- DESC_ENTRY (ZEBRA_IPV6_NEXTHOP_LOOKUP),
- DESC_ENTRY (ZEBRA_IPV4_IMPORT_LOOKUP),
- DESC_ENTRY (ZEBRA_IPV6_IMPORT_LOOKUP),
- DESC_ENTRY (ZEBRA_INTERFACE_RENAME),
DESC_ENTRY (ZEBRA_ROUTER_ID_ADD),
DESC_ENTRY (ZEBRA_ROUTER_ID_DELETE),
DESC_ENTRY (ZEBRA_ROUTER_ID_UPDATE),
diff --git a/lib/memory.c b/lib/memory.c
index 8d1a03743e..38e424da7d 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -1,487 +1,149 @@
/*
- * Memory management routine
- * Copyright (C) 1998 Kunihiro Ishiguro
+ * Copyright (c) 2015-16 David Lamparter, for NetDEF, Inc.
*
- * This file is part of GNU Zebra.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
*
- * GNU Zebra 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.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
*/
#include <zebra.h>
-/* malloc.h is generally obsolete, however GNU Libc mallinfo wants it. */
-#if !defined(HAVE_STDLIB_H) || (defined(GNU_LINUX) && defined(HAVE_MALLINFO))
-#include <malloc.h>
-#endif /* !HAVE_STDLIB_H || HAVE_MALLINFO */
-#include "log.h"
+#include <stdlib.h>
+
#include "memory.h"
-static void alloc_inc (int);
-static void alloc_dec (int);
-static void log_memstats(int log_priority);
+static struct memgroup *mg_first = NULL;
+struct memgroup **mg_insert = &mg_first;
-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();
-}
+DEFINE_MGROUP(LIB, "libzebra")
+DEFINE_MTYPE(LIB, TMP, "Temporary memory")
-/*
- * 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)
+static inline void
+mt_count_alloc (struct memtype *mt, size_t size)
{
- void *memory;
-
- memory = malloc (size);
+ mt->n_alloc++;
- if (memory == NULL)
- zerror ("malloc", type, size);
-
- alloc_inc (type);
-
- return memory;
+ if (mt->size == 0)
+ mt->size = size;
+ else if (mt->size != size)
+ mt->size = SIZE_VAR;
}
-/*
- * Allocate memory as in zmalloc, and also clear the memory.
- * Add an extra 'z' prefix to function name to avoid collision when linking
- * statically with zlib that exports the 'zcalloc' symbol.
- */
-void *
-zzcalloc (int type, size_t size)
+static inline void
+mt_count_free (struct memtype *mt)
{
- void *memory;
-
- memory = calloc (1, size);
-
- if (memory == NULL)
- zerror ("calloc", type, size);
-
- alloc_inc (type);
-
- return memory;
+ mt->n_alloc--;
}
-/*
- * Given a pointer returned by zmalloc or zzcalloc, free it and
- * return a pointer to a new size, basically acting like realloc().
- * Requires: ptr was returned by zmalloc, zzcalloc, 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)
+static inline void *
+mt_checkalloc (struct memtype *mt, void *ptr, size_t size)
{
- void *memory;
-
- if (ptr == NULL) /* is really alloc */
- return zzcalloc(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, zzcalloc, 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)
+ if (__builtin_expect(ptr == NULL, 0))
{
- alloc_dec (type);
- free (ptr);
+ memory_oom (size, mt->name);
+ return NULL;
}
-}
-
-/*
- * 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);
+ mt_count_alloc (mt, size);
+ return ptr;
}
void *
-mtype_zmalloc (const char *file, int line, int type, size_t size)
+qmalloc (struct memtype *mt, 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;
+ return mt_checkalloc (mt, malloc (size), size);
}
void *
-mtype_zcalloc (const char *file, int line, int type, size_t size)
+qcalloc (struct memtype *mt, size_t size)
{
- void *memory;
-
- mstat[type].c_calloc++;
- mstat[type].t_calloc++;
-
- memory = zzcalloc (type, size);
- mtype_log ("xcalloc", memory, file, line, type);
-
- return memory;
+ return mt_checkalloc (mt, calloc (size, 1), size);
}
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)
+qrealloc (struct memtype *mt, void *ptr, size_t size)
{
- mstat[type].alloc++;
+ if (ptr)
+ mt_count_free (mt);
+ return mt_checkalloc (mt, ptr ? realloc (ptr, size) : malloc (size), size);
}
-/* Decrement allocation counter. */
-static void
-alloc_dec (int type)
+void *
+qstrdup (struct memtype *mt, const char *str)
{
- mstat[type].alloc--;
-}
-
-/* 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);
- }
+ return mt_checkalloc (mt, strdup (str), strlen (str) + 1);
}
void
-log_memstats_stderr (const char *prefix)
+qfree (struct memtype *mt, void *ptr)
{
- struct mlist *ml;
- struct memory_list *m;
- int i;
- int j = 0;
-
- for (ml = mlists; ml->list; ml++)
- {
- i = 0;
-
- for (m = ml->list; m->index >= 0; m++)
- if (m->index && mstat[m->index].alloc)
- {
- if (!i)
- fprintf (stderr,
- "%s: memstats: Current memory utilization in module %s:\n",
- prefix,
- ml->name);
- fprintf (stderr,
- "%s: memstats: %-30s: %10ld%s\n",
- prefix,
- m->format,
- mstat[m->index].alloc,
- mstat[m->index].alloc < 0 ? " (REPORT THIS BUG!)" : "");
- i = j = 1;
- }
- }
-
- if (j)
- fprintf (stderr,
- "%s: memstats: NOTE: If configuration exists, utilization may be "
- "expected.\n",
- prefix);
- else
- fprintf (stderr,
- "%s: memstats: No remaining tracked memory utilization.\n",
- prefix);
+ if (ptr)
+ mt_count_free (mt);
+ free (ptr);
}
-static void
-show_separator(struct vty *vty)
+int
+qmem_walk (qmem_walk_fn *func, void *arg)
{
- vty_out (vty, "-----------------------------\r\n");
-}
+ struct memgroup *mg;
+ struct memtype *mt;
+ int rv;
-static int
-show_memory_vty (struct vty *vty, struct memory_list *list)
-{
- struct memory_list *m;
- int needsep = 0;
-
- for (m = list; m->index >= 0; m++)
- if (m->index == 0)
- {
- if (needsep)
- {
- show_separator (vty);
- needsep = 0;
- }
- }
- else if (mstat[m->index].alloc)
- {
- vty_out (vty, "%-30s: %10ld\r\n", m->format, mstat[m->index].alloc);
- needsep = 1;
- }
- return needsep;
-}
-
-#ifdef HAVE_MALLINFO
-static int
-show_memory_mallinfo (struct vty *vty)
-{
- struct mallinfo minfo = mallinfo();
- char buf[MTYPE_MEMSTR_LEN];
-
- vty_out (vty, "System allocator statistics:%s", VTY_NEWLINE);
- vty_out (vty, " Total heap allocated: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.arena),
- VTY_NEWLINE);
- vty_out (vty, " Holding block headers: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.hblkhd),
- VTY_NEWLINE);
- vty_out (vty, " Used small blocks: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.usmblks),
- VTY_NEWLINE);
- vty_out (vty, " Used ordinary blocks: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.uordblks),
- VTY_NEWLINE);
- vty_out (vty, " Free small blocks: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fsmblks),
- VTY_NEWLINE);
- vty_out (vty, " Free ordinary blocks: %s%s",
- mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fordblks),
- VTY_NEWLINE);
- vty_out (vty, " Ordinary blocks: %ld%s",
- (unsigned long)minfo.ordblks,
- VTY_NEWLINE);
- vty_out (vty, " Small blocks: %ld%s",
- (unsigned long)minfo.smblks,
- VTY_NEWLINE);
- vty_out (vty, " Holding blocks: %ld%s",
- (unsigned long)minfo.hblks,
- VTY_NEWLINE);
- vty_out (vty, "(see system documentation for 'mallinfo' for meaning)%s",
- VTY_NEWLINE);
- return 1;
-}
-#endif /* HAVE_MALLINFO */
-
-DEFUN (show_memory,
- show_memory_cmd,
- "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 */
-
- for (ml = mlists; ml->list; ml++)
+ for (mg = mg_first; mg; mg = mg->next)
{
- if (needsep)
- show_separator (vty);
- needsep = show_memory_vty (vty, ml->list);
+ if ((rv = func (arg, mg, NULL)))
+ return rv;
+ for (mt = mg->types; mt; mt = mt->next)
+ if ((rv = func (arg, mg, mt)))
+ return rv;
}
-
- return CMD_SUCCESS;
+ return 0;
}
-void
-memory_init (void)
+struct exit_dump_args
{
- install_element (RESTRICTED_NODE, &show_memory_cmd);
-
- install_element (VIEW_NODE, &show_memory_cmd);
-
- install_element (ENABLE_NODE, &show_memory_cmd);
-}
+ const char *prefix;
+ int error;
+};
-/* Stats querying from users */
-/* Return a pointer to a human friendly string describing
- * the byte count passed in. E.g:
- * "0 bytes", "2048 bytes", "110kB", "500MiB", "11GiB", etc.
- * Up to 4 significant figures will be given.
- * The pointer returned may be NULL (indicating an error)
- * or point to the given buffer, or point to static storage.
- */
-const char *
-mtype_memstr (char *buf, size_t len, unsigned long bytes)
+static int
+qmem_exit_walker (void *arg, struct memgroup *mg, struct memtype *mt)
{
- unsigned int m, k;
-
- /* easy cases */
- if (!bytes)
- return "0 bytes";
- if (bytes == 1)
- return "1 byte";
-
- /*
- * When we pass the 2gb barrier mallinfo() can no longer report
- * correct data so it just does something odd...
- * Reporting like Terrabytes of data. Which makes users...
- * edgy.. yes edgy that's the term for it.
- * So let's just give up gracefully
- */
- if (bytes > 0x7fffffff)
- return "> 2GB";
+ struct exit_dump_args *eda = arg;
- m = bytes >> 20;
- k = bytes >> 10;
-
- if (m > 10)
+ if (!mt)
{
- if (bytes & (1 << 19))
- m++;
- snprintf (buf, len, "%d MiB", m);
+ fprintf (stderr, "%s: showing active allocations in memory group %s\n",
+ eda->prefix, mg->name);
}
- else if (k > 10)
+ else if (mt->n_alloc)
{
- if (bytes & (1 << 9))
- k++;
- snprintf (buf, len, "%d KiB", k);
+ char size[32];
+ eda->error++;
+ snprintf (size, sizeof (size), "%10zu", mt->size);
+ fprintf (stderr, "%s: %-30s: %6zu * %s\n",
+ eda->prefix, mt->name, mt->n_alloc,
+ mt->size == SIZE_VAR ? "(variably sized)" : size);
}
- else
- snprintf (buf, len, "%ld bytes", bytes);
-
- return buf;
+ return 0;
}
-unsigned long
-mtype_stats_alloc (int type)
+void
+log_memstats_stderr (const char *prefix)
{
- return mstat[type].alloc;
+ struct exit_dump_args eda = { .prefix = prefix, .error = 0 };
+ qmem_walk (qmem_exit_walker, &eda);
}
diff --git a/lib/memory.h b/lib/memory.h
index 501352993d..d287f229f7 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -1,96 +1,198 @@
-/* Memory management routine
- Copyright (C) 1998 Kunihiro Ishiguro
-
-This file is part of GNU Zebra.
-
-GNU Zebra 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.
-
-GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
-
-#ifndef _ZEBRA_MEMORY_H
-#define _ZEBRA_MEMORY_H
+/*
+ * Copyright (c) 2015-16 David Lamparter, for NetDEF, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _QUAGGA_MEMORY_H
+#define _QUAGGA_MEMORY_H
+
+#include <stdlib.h>
#define array_size(ar) (sizeof(ar) / sizeof(ar[0]))
-/* For pretty printing of memory allocate information. */
-struct memory_list
+#define SIZE_VAR ~0UL
+struct memtype
{
- int index;
- const char *format;
+ struct memtype *next, **ref;
+ const char *name;
+ size_t n_alloc;
+ size_t size;
};
-struct mlist {
- struct memory_list *list;
+struct memgroup
+{
+ struct memgroup *next, **ref;
+ struct memtype *types, **insert;
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) zzcalloc ((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 *zzcalloc (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);
+
+#if defined(__clang__)
+# if __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 5)
+# define _RET_NONNULL , returns_nonnull
+# endif
+# define _CONSTRUCTOR(x) constructor(x)
+#elif defined(__GNUC__)
+# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
+# define _RET_NONNULL , returns_nonnull
+# endif
+# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+# define _CONSTRUCTOR(x) constructor(x)
+# define _DESTRUCTOR(x) destructor(x)
+# define _ALLOC_SIZE(x) alloc_size(x)
+# endif
+#endif
+
+#ifdef __sun
+/* Solaris doesn't do constructor priorities due to linker restrictions */
+# undef _CONSTRUCTOR
+# undef _DESTRUCTOR
+#endif
+
+#ifndef _RET_NONNULL
+# define _RET_NONNULL
+#endif
+#ifndef _CONSTRUCTOR
+# define _CONSTRUCTOR(x) constructor
+#endif
+#ifndef _DESTRUCTOR
+# define _DESTRUCTOR(x) destructor
+#endif
+#ifndef _ALLOC_SIZE
+# define _ALLOC_SIZE(x)
+#endif
+
+/* macro usage:
+ *
+ * mydaemon.h
+ * DECLARE_MGROUP(MYDAEMON)
+ * DECLARE_MTYPE(MYDAEMON_COMMON)
+ *
+ * mydaemon.c
+ * DEFINE_MGROUP(MYDAEMON, "my daemon memory")
+ * DEFINE_MTYPE(MYDAEMON, MYDAEMON_COMMON,
+ * "this mtype is used in multiple files in mydaemon")
+ * foo = qmalloc (MTYPE_MYDAEMON_COMMON, sizeof (*foo))
+ *
+ * mydaemon_io.c
+ * bar = qmalloc (MTYPE_MYDAEMON_COMMON, sizeof (*bar))
+ *
+ * DEFINE_MTYPE_STATIC(MYDAEMON, MYDAEMON_IO,
+ * "this mtype is used only in this file")
+ * baz = qmalloc (MTYPE_MYDAEMON_IO, sizeof (*baz))
+ *
+ * Note: Naming conventions (MGROUP_ and MTYPE_ prefixes are enforced
+ * by not having these as part of the macro arguments)
+ * Note: MTYPE_* are symbols to the compiler (of type struct memtype *),
+ * but MGROUP_* aren't.
+ */
+
+#define DECLARE_MGROUP(name) \
+ extern struct memgroup _mg_##name;
+#define DEFINE_MGROUP(mname, desc) \
+ struct memgroup _mg_##mname \
+ __attribute__ ((section (".data.mgroups"))) = { \
+ .name = desc, \
+ .types = NULL, .next = NULL, .insert = NULL, .ref = NULL, \
+ }; \
+ static void _mginit_##mname (void) \
+ __attribute__ ((_CONSTRUCTOR (1000))); \
+ static void _mginit_##mname (void) \
+ { extern struct memgroup **mg_insert; \
+ _mg_##mname.ref = mg_insert; \
+ *mg_insert = &_mg_##mname; \
+ mg_insert = &_mg_##mname.next; } \
+ static void _mgfini_##mname (void) \
+ __attribute__ ((_DESTRUCTOR (1000))); \
+ static void _mgfini_##mname (void) \
+ { if (_mg_##mname.next) \
+ _mg_##mname.next->ref = _mg_##mname.ref; \
+ *_mg_##mname.ref = _mg_##mname.next; }
+
+
+#define DECLARE_MTYPE(name) \
+ extern struct memtype _mt_##name; \
+ static struct memtype * const MTYPE_ ## name = &_mt_##name;
+
+#define DEFINE_MTYPE_ATTR(group, mname, attr, desc) \
+ attr struct memtype _mt_##mname \
+ __attribute__ ((section (".data.mtypes"))) = { \
+ .name = desc, \
+ .next = NULL, .n_alloc = 0, .size = 0, .ref = NULL, \
+ }; \
+ static void _mtinit_##mname (void) \
+ __attribute__ ((_CONSTRUCTOR (1001))); \
+ static void _mtinit_##mname (void) \
+ { if (_mg_##group.insert == NULL) \
+ _mg_##group.insert = &_mg_##group.types; \
+ _mt_##mname.ref = _mg_##group.insert; \
+ *_mg_##group.insert = &_mt_##mname; \
+ _mg_##group.insert = &_mt_##mname.next; } \
+ static void _mtfini_##mname (void) \
+ __attribute__ ((_DESTRUCTOR (1001))); \
+ static void _mtfini_##mname (void) \
+ { if (_mt_##mname.next) \
+ _mt_##mname.next->ref = _mt_##mname.ref; \
+ *_mt_##mname.ref = _mt_##mname.next; }
+
+#define DEFINE_MTYPE(group, name, desc) \
+ DEFINE_MTYPE_ATTR(group, name, , desc)
+#define DEFINE_MTYPE_STATIC(group, name, desc) \
+ 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));
+extern void *qcalloc (struct memtype *mt, size_t size)
+ __attribute__ ((malloc, _ALLOC_SIZE(2), nonnull (1) _RET_NONNULL));
+extern void *qrealloc (struct memtype *mt, void *ptr, size_t size)
+ __attribute__ ((_ALLOC_SIZE(3), nonnull (1) _RET_NONNULL));
+extern void *qstrdup (struct memtype *mt, const char *str)
+ __attribute__ ((malloc, nonnull (1) _RET_NONNULL));
+extern void qfree (struct memtype *mt, void *ptr)
+ __attribute__ ((nonnull (1)));
+
+#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)
+ *
+ * return value: 0: continue, !0: abort walk. qmem_walk will return the
+ * last value from qmem_walk_fn. */
+typedef int qmem_walk_fn (void *arg, struct memgroup *mg, struct memtype *mt);
+extern int qmem_walk (qmem_walk_fn *func, void *arg);
extern void log_memstats_stderr (const char *);
-/* return number of allocations outstanding for the type */
-extern unsigned long mtype_stats_alloc (int);
+extern void memory_oom (size_t size, const char *name);
-/* Human friendly string for given byte count */
-#define MTYPE_MEMSTR_LEN 20
-extern const char *mtype_memstr (char *, size_t, unsigned long);
-#endif /* _ZEBRA_MEMORY_H */
+#endif /* _QUAGGA_MEMORY_H */
diff --git a/lib/memory_vty.c b/lib/memory_vty.c
new file mode 100644
index 0000000000..e4cb295cf0
--- /dev/null
+++ b/lib/memory_vty.c
@@ -0,0 +1,169 @@
+/*
+ * Memory management routine
+ * Copyright (C) 1998 Kunihiro Ishiguro
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra 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.
+ *
+ * GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <zebra.h>
+/* malloc.h is generally obsolete, however GNU Libc mallinfo wants it. */
+#if !defined(HAVE_STDLIB_H) || (defined(GNU_LINUX) && defined(HAVE_MALLINFO))
+#include <malloc.h>
+#endif /* !HAVE_STDLIB_H || HAVE_MALLINFO */
+
+#include "log.h"
+#include "memory.h"
+#include "memory_vty.h"
+
+/* Looking up memory status from vty interface. */
+#include "vector.h"
+#include "vty.h"
+#include "command.h"
+
+#ifdef HAVE_MALLINFO
+static int
+show_memory_mallinfo (struct vty *vty)
+{
+ struct mallinfo minfo = mallinfo();
+ char buf[MTYPE_MEMSTR_LEN];
+
+ vty_out (vty, "System allocator statistics:%s", VTY_NEWLINE);
+ vty_out (vty, " Total heap allocated: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.arena),
+ VTY_NEWLINE);
+ vty_out (vty, " Holding block headers: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.hblkhd),
+ VTY_NEWLINE);
+ vty_out (vty, " Used small blocks: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.usmblks),
+ VTY_NEWLINE);
+ vty_out (vty, " Used ordinary blocks: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.uordblks),
+ VTY_NEWLINE);
+ vty_out (vty, " Free small blocks: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fsmblks),
+ VTY_NEWLINE);
+ vty_out (vty, " Free ordinary blocks: %s%s",
+ mtype_memstr (buf, MTYPE_MEMSTR_LEN, minfo.fordblks),
+ VTY_NEWLINE);
+ vty_out (vty, " Ordinary blocks: %ld%s",
+ (unsigned long)minfo.ordblks,
+ VTY_NEWLINE);
+ vty_out (vty, " Small blocks: %ld%s",
+ (unsigned long)minfo.smblks,
+ VTY_NEWLINE);
+ vty_out (vty, " Holding blocks: %ld%s",
+ (unsigned long)minfo.hblks,
+ VTY_NEWLINE);
+ vty_out (vty, "(see system documentation for 'mallinfo' for meaning)%s",
+ VTY_NEWLINE);
+ return 1;
+}
+#endif /* HAVE_MALLINFO */
+
+static int qmem_walker(void *arg, struct memgroup *mg, struct memtype *mt)
+{
+ struct vty *vty = arg;
+ if (!mt)
+ vty_out (vty, "--- qmem %s ---%s", mg->name, VTY_NEWLINE);
+ else {
+ char size[32];
+ snprintf(size, sizeof(size), "%6zu", mt->size);
+ vty_out (vty, "%-30s: %10zu %s%s",
+ mt->name, mt->n_alloc,
+ mt->size == 0 ? "" :
+ mt->size == SIZE_VAR ? "(variably sized)" :
+ size, VTY_NEWLINE);
+ }
+ return 0;
+}
+
+
+DEFUN (show_memory,
+ show_memory_cmd,
+ "show memory",
+ "Show running system information\n"
+ "Memory statistics\n")
+{
+#ifdef HAVE_MALLINFO
+ show_memory_mallinfo (vty);
+#endif /* HAVE_MALLINFO */
+
+ qmem_walk(qmem_walker, vty);
+ return CMD_SUCCESS;
+}
+
+void
+memory_init (void)
+{
+ install_element (RESTRICTED_NODE, &show_memory_cmd);
+
+ install_element (VIEW_NODE, &show_memory_cmd);
+
+ install_element (ENABLE_NODE, &show_memory_cmd);
+}
+
+/* Stats querying from users */
+/* Return a pointer to a human friendly string describing
+ * the byte count passed in. E.g:
+ * "0 bytes", "2048 bytes", "110kB", "500MiB", "11GiB", etc.
+ * Up to 4 significant figures will be given.
+ * The pointer returned may be NULL (indicating an error)
+ * or point to the given buffer, or point to static storage.
+ */
+const char *
+mtype_memstr (char *buf, size_t len, unsigned long bytes)
+{
+ unsigned int m, k;
+
+ /* easy cases */
+ if (!bytes)
+ return "0 bytes";
+ if (bytes == 1)
+ return "1 byte";
+
+ /*
+ * When we pass the 2gb barrier mallinfo() can no longer report
+ * correct data so it just does something odd...
+ * Reporting like Terrabytes of data. Which makes users...
+ * edgy.. yes edgy that's the term for it.
+ * So let's just give up gracefully
+ */
+ if (bytes > 0x7fffffff)
+ return "> 2GB";
+
+ m = bytes >> 20;
+ k = bytes >> 10;
+
+ if (m > 10)
+ {
+ if (bytes & (1 << 19))
+ m++;
+ snprintf (buf, len, "%d MiB", m);
+ }
+ else if (k > 10)
+ {
+ if (bytes & (1 << 9))
+ k++;
+ snprintf (buf, len, "%d KiB", k);
+ }
+ else
+ snprintf (buf, len, "%ld bytes", bytes);
+
+ return buf;
+}
diff --git a/lib/memory_vty.h b/lib/memory_vty.h
new file mode 100644
index 0000000000..565a75aa98
--- /dev/null
+++ b/lib/memory_vty.h
@@ -0,0 +1,31 @@
+/* Memory management routine
+ Copyright (C) 1998 Kunihiro Ishiguro
+
+This file is part of GNU Zebra.
+
+GNU Zebra 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.
+
+GNU Zebra 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 GNU Zebra; see the file COPYING. If not, write to the Free
+Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
+
+#ifndef _ZEBRA_MEMORY_VTY_H
+#define _ZEBRA_MEMORY_VTY_H
+
+#include "memory.h"
+
+extern void memory_init (void);
+
+/* Human friendly string for given byte count */
+#define MTYPE_MEMSTR_LEN 20
+extern const char *mtype_memstr (char *, size_t, unsigned long);
+#endif /* _ZEBRA_MEMORY_VTY_H */
diff --git a/lib/memtypes.awk b/lib/memtypes.awk
deleted file mode 100644
index bd13327db5..0000000000
--- 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
deleted file mode 100644
index 510312f336..0000000000
--- a/lib/memtypes.c
+++ /dev/null
@@ -1,317 +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"
-
-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_NBR_CONNECTED, "Neighbor 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_DISTRIBUTE_NAME, "Dist-list name" },
- { 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_PREFIX_LIST_TRIE, "Prefix List Trie Table" },
- { 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_ROUTE_MAP_DEP, "Route map dependency" },
- { 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_BFD_INFO, "BFD info" },
- { MTYPE_VRF, "VRF" },
- { MTYPE_VRF_NAME, "VRF name" },
- { MTYPE_VRF_BITMAP, "VRF bit-map" },
- { MTYPE_NS, "Logical-Router" },
- { MTYPE_NS_NAME, "Logical-Router Name" },
- { MTYPE_NS_BITMAP, "Logical-Router bit-map" },
- { MTYPE_IF_LINK_PARAMS, "Informational Link Parameters" },
- { -1, NULL },
-};
-
-struct memory_list memory_list_zebra[] =
-{
- { MTYPE_RTADV_PREFIX, "Router Advertisement Prefix" },
- { MTYPE_ZEBRA_NS, "Zebra Name Space" },
- { 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_RNH, "Nexthop tracking object" },
- { 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_BGP_PEER_IFNAME, "BGP peer ifname" },
- { MTYPE_BGP_PEER_GROUP, "BGP Peer group" },
- { MTYPE_BGP_PEER_GROUP_HOST, "BGP Peer group hostname" },
- { MTYPE_PEER_DESC, "Peer description" },
- { MTYPE_PEER_PASSWORD, "Peer password string" },
- { MTYPE_BGP_PEER_AF, "BGP peer af" },
- { MTYPE_BGP_UPDGRP, "BGP update group" },
- { MTYPE_BGP_UPD_SUBGRP, "BGP update subgroup" },
- { MTYPE_BGP_PACKET, "BGP packet" },
- { 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_DEBUG_FILTER, "BGP debug filter" },
- { MTYPE_BGP_DEBUG_STR, "BGP debug filter string" },
- { 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_PEER_CONF_IF, "BGP peer config 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" },
- { 0 , NULL},
- { MTYPE_BGP_REDIST, "BGP redistribution" },
- { MTYPE_BGP_FILTER_NAME, "BGP Filter Information" },
- { MTYPE_BGP_DUMP_STR, "BGP Dump String Information" },
- { 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_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" },
- { MTYPE_OSPF_MPLS_TE, "OSPF MPLS parameters" },
- { MTYPE_OSPF_PCE_PARAMS, "OSPF PCE parameters" },
- { -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" },
- { MTYPE_ISIS_MPLS_TE, "ISIS MPLS_TE parameters" },
- { -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" },
- { MTYPE_PIM_BR, "PIM Bridge Router info" },
- { -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},
-};
diff --git a/lib/nexthop.c b/lib/nexthop.c
index 14486ea157..427f77f87a 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)
diff --git a/lib/ns.c b/lib/ns.c
index 4765a18ef2..556350ed17 100644
--- a/lib/ns.c
+++ b/lib/ns.c
@@ -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 7bb80fa2a4..eedb830c1a 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 69ab8e65d6..0f870564da 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 d2bb028315..34bb1a493a 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 3fb96aed12..9228a56d35 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 9267056df6..10e5ed304c 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 f5981a87f3..7006e43f66 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 9184e500fc..96408965ab 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 809e749fb9..301ebc6275 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 da21361684..8858aea0fd 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 2ffd79b53f..34c196aa47 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 a128786c3d..a26eb6bfd2 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>
@@ -287,13 +291,13 @@ cpu_record_print(struct vty *vty, thread_type filter)
vty_out_cpu_thread_history(vty, &tmp);
}
-DEFUN(show_thread_cpu,
- show_thread_cpu_cmd,
- "show thread cpu [FILTER]",
- SHOW_STR
- "Thread information\n"
- "Thread CPU usage\n"
- "Display filter (rwtexb)\n")
+DEFUN (show_thread_cpu,
+ show_thread_cpu_cmd,
+ "show thread cpu [FILTER]",
+ SHOW_STR
+ "Thread information\n"
+ "Thread CPU usage\n"
+ "Display filter (rwtexb)\n")
{
int i = 0;
thread_type filter = (thread_type) -1U;
@@ -369,13 +373,13 @@ cpu_record_clear (thread_type filter)
tmp);
}
-DEFUN(clear_thread_cpu,
- clear_thread_cpu_cmd,
- "clear thread cpu [FILTER]",
- "Clear stored data\n"
- "Thread information\n"
- "Thread CPU usage\n"
- "Display filter (rwtexb)\n")
+DEFUN (clear_thread_cpu,
+ clear_thread_cpu_cmd,
+ "clear thread cpu [FILTER]",
+ "Clear stored data\n"
+ "Thread information\n"
+ "Thread CPU usage\n"
+ "Display filter (rwtexb)\n")
{
int i = 0;
thread_type filter = (thread_type) -1U;
diff --git a/lib/vector.c b/lib/vector.c
index 7c1486285f..03ad3171d6 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 6b27fd96d4..d8f4c78608 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
{
diff --git a/lib/vrf.c b/lib/vrf.c
index bffcbca54e..7d79b3dc9a 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -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.
diff --git a/lib/vty.c b/lib/vty.c
index 61b0c3b4be..ff559d1705 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -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 d351beb124..549bb2360a 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
@@ -178,11 +182,11 @@ work_queue_item_requeue (struct work_queue *wq, struct listnode *ln)
LISTNODE_ATTACH (wq->items, ln); /* attach to end of list */
}
-DEFUN(show_work_queues,
- show_work_queues_cmd,
- "show work-queues",
- SHOW_STR
- "Work Queue information\n")
+DEFUN (show_work_queues,
+ show_work_queues_cmd,
+ "show work-queues",
+ SHOW_STR
+ "Work Queue information\n")
{
struct listnode *node;
struct work_queue *wq;
diff --git a/lib/workqueue.h b/lib/workqueue.h
index 19b44041d7..eaf8574907 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 753954fd84..057fa77580 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};
diff --git a/lib/zebra.h b/lib/zebra.h
index fdfd471825..d7a441c2e9 100644
--- a/lib/zebra.h
+++ b/lib/zebra.h
@@ -318,26 +318,6 @@ struct in_pktinfo
#endif
/*
- * OSPF Fragmentation / fragmented writes
- *
- * ospfd can support writing fragmented packets, for cases where
- * kernel will not fragment IP_HDRINCL and/or multicast destined
- * packets (ie TTBOMK all kernels, BSD, SunOS, Linux). However,
- * SunOS, probably BSD too, clobber the user supplied IP ID and IP
- * flags fields, hence user-space fragmentation will not work.
- * Only Linux is known to leave IP header unmolested.
- * Further, fragmentation really should be done the kernel, which already
- * supports it, and which avoids nasty IP ID state problems.
- *
- * Fragmentation of OSPF packets can be required on networks with router
- * with many many interfaces active in one area, or on networks with links
- * with low MTUs.
- */
-#ifdef GNU_LINUX
-#define WANT_OSPF_WRITE_FRAGMENT
-#endif
-
-/*
* IP_HDRINCL / struct ip byte order
*
* Linux: network byte order
@@ -396,57 +376,53 @@ struct in_pktinfo
#define ZEBRA_PORT 2600
/* Zebra message types. */
-#define ZEBRA_INTERFACE_ADD 1
-#define ZEBRA_INTERFACE_DELETE 2
-#define ZEBRA_INTERFACE_ADDRESS_ADD 3
-#define ZEBRA_INTERFACE_ADDRESS_DELETE 4
-#define ZEBRA_INTERFACE_UP 5
-#define ZEBRA_INTERFACE_DOWN 6
-#define ZEBRA_IPV4_ROUTE_ADD 7
-#define ZEBRA_IPV4_ROUTE_DELETE 8
-#define ZEBRA_IPV6_ROUTE_ADD 9
-#define ZEBRA_IPV6_ROUTE_DELETE 10
-#define ZEBRA_REDISTRIBUTE_ADD 11
-#define ZEBRA_REDISTRIBUTE_DELETE 12
-#define ZEBRA_REDISTRIBUTE_DEFAULT_ADD 13
-#define ZEBRA_REDISTRIBUTE_DEFAULT_DELETE 14
-#define ZEBRA_IPV4_NEXTHOP_LOOKUP 15
-#define ZEBRA_IPV6_NEXTHOP_LOOKUP 16
-#define ZEBRA_IPV4_IMPORT_LOOKUP 17
-#define ZEBRA_IPV6_IMPORT_LOOKUP 18
-#define ZEBRA_INTERFACE_RENAME 19
-#define ZEBRA_ROUTER_ID_ADD 20
-#define ZEBRA_ROUTER_ID_DELETE 21
-#define ZEBRA_ROUTER_ID_UPDATE 22
-#define ZEBRA_HELLO 23
-#define ZEBRA_NEXTHOP_REGISTER 24
-#define ZEBRA_NEXTHOP_UNREGISTER 25
-#define ZEBRA_NEXTHOP_UPDATE 26
-#define ZEBRA_INTERFACE_NBR_ADDRESS_ADD 27
-#define ZEBRA_INTERFACE_NBR_ADDRESS_DELETE 28
-#define ZEBRA_INTERFACE_BFD_DEST_UPDATE 29
-#define ZEBRA_IMPORT_ROUTE_REGISTER 30
-#define ZEBRA_IMPORT_ROUTE_UNREGISTER 31
-#define ZEBRA_IMPORT_CHECK_UPDATE 32
-#define ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD 33
-#define ZEBRA_BFD_DEST_REGISTER 34
-#define ZEBRA_BFD_DEST_DEREGISTER 35
-#define ZEBRA_BFD_DEST_UPDATE 36
-#define ZEBRA_BFD_DEST_REPLAY 37
-#define ZEBRA_REDISTRIBUTE_IPV4_ADD 38
-#define ZEBRA_REDISTRIBUTE_IPV4_DEL 39
-#define ZEBRA_REDISTRIBUTE_IPV6_ADD 40
-#define ZEBRA_REDISTRIBUTE_IPV6_DEL 41
-#define ZEBRA_VRF_UNREGISTER 42
-#define ZEBRA_VRF_ADD 43
-#define ZEBRA_VRF_DELETE 44
-#define ZEBRA_INTERFACE_VRF_UPDATE 45
-#define ZEBRA_BFD_CLIENT_REGISTER 46
-#define ZEBRA_INTERFACE_ENABLE_RADV 47
-#define ZEBRA_INTERFACE_DISABLE_RADV 48
-#define ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB 49
-#define ZEBRA_INTERFACE_LINK_PARAMS 50
-#define ZEBRA_MESSAGE_MAX 51
+typedef enum {
+ ZEBRA_INTERFACE_ADD,
+ ZEBRA_INTERFACE_DELETE,
+ ZEBRA_INTERFACE_ADDRESS_ADD,
+ ZEBRA_INTERFACE_ADDRESS_DELETE,
+ ZEBRA_INTERFACE_UP,
+ ZEBRA_INTERFACE_DOWN,
+ ZEBRA_IPV4_ROUTE_ADD,
+ ZEBRA_IPV4_ROUTE_DELETE,
+ ZEBRA_IPV6_ROUTE_ADD,
+ ZEBRA_IPV6_ROUTE_DELETE,
+ ZEBRA_REDISTRIBUTE_ADD,
+ ZEBRA_REDISTRIBUTE_DELETE,
+ ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
+ ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
+ ZEBRA_ROUTER_ID_ADD,
+ ZEBRA_ROUTER_ID_DELETE,
+ ZEBRA_ROUTER_ID_UPDATE,
+ ZEBRA_HELLO,
+ ZEBRA_NEXTHOP_REGISTER,
+ ZEBRA_NEXTHOP_UNREGISTER,
+ ZEBRA_NEXTHOP_UPDATE,
+ ZEBRA_INTERFACE_NBR_ADDRESS_ADD,
+ ZEBRA_INTERFACE_NBR_ADDRESS_DELETE,
+ ZEBRA_INTERFACE_BFD_DEST_UPDATE,
+ ZEBRA_IMPORT_ROUTE_REGISTER,
+ ZEBRA_IMPORT_ROUTE_UNREGISTER,
+ ZEBRA_IMPORT_CHECK_UPDATE,
+ ZEBRA_IPV4_ROUTE_IPV6_NEXTHOP_ADD,
+ ZEBRA_BFD_DEST_REGISTER,
+ ZEBRA_BFD_DEST_DEREGISTER,
+ ZEBRA_BFD_DEST_UPDATE,
+ ZEBRA_BFD_DEST_REPLAY,
+ ZEBRA_REDISTRIBUTE_IPV4_ADD,
+ ZEBRA_REDISTRIBUTE_IPV4_DEL,
+ ZEBRA_REDISTRIBUTE_IPV6_ADD,
+ ZEBRA_REDISTRIBUTE_IPV6_DEL,
+ ZEBRA_VRF_UNREGISTER,
+ ZEBRA_VRF_ADD,
+ ZEBRA_VRF_DELETE,
+ ZEBRA_INTERFACE_VRF_UPDATE,
+ ZEBRA_BFD_CLIENT_REGISTER,
+ ZEBRA_INTERFACE_ENABLE_RADV,
+ ZEBRA_INTERFACE_DISABLE_RADV,
+ ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
+ ZEBRA_INTERFACE_LINK_PARAMS,
+} zebra_message_types_t;
/* Marker value used in new Zserv, in the byte location corresponding
* the command value in the old zserv header. To allow old and new
@@ -542,43 +518,4 @@ typedef u_int16_t zebra_command_t;
/* VRF ID type. */
typedef u_int16_t vrf_id_t;
-/* FIFO -- first in first out structure and macros. */
-struct fifo
-{
- struct fifo *next;
- struct fifo *prev;
-};
-
-#define FIFO_INIT(F) \
- do { \
- struct fifo *Xfifo = (struct fifo *)(F); \
- Xfifo->next = Xfifo->prev = Xfifo; \
- } while (0)
-
-#define FIFO_ADD(F,N) \
- do { \
- struct fifo *Xfifo = (struct fifo *)(F); \
- struct fifo *Xnode = (struct fifo *)(N); \
- Xnode->next = Xfifo; \
- Xnode->prev = Xfifo->prev; \
- Xfifo->prev = Xfifo->prev->next = Xnode; \
- } while (0)
-
-#define FIFO_DEL(N) \
- do { \
- struct fifo *Xnode = (struct fifo *)(N); \
- Xnode->prev->next = Xnode->next; \
- Xnode->next->prev = Xnode->prev; \
- } while (0)
-
-#define FIFO_HEAD(F) \
- ((((struct fifo *)(F))->next == (struct fifo *)(F)) \
- ? NULL : (F)->next)
-
-#define FIFO_EMPTY(F) \
- (((struct fifo *)(F))->next == (struct fifo *)(F))
-
-#define FIFO_TOP(F) \
- (FIFO_EMPTY(F) ? NULL : ((struct fifo *)(F))->next)
-
#endif /* _ZEBRA_H */
diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am
index f4181167e1..7551503dae 100644
--- a/ospf6d/Makefile.am
+++ b/ospf6d/Makefile.am
@@ -10,6 +10,7 @@ noinst_LIBRARIES = libospf6.a
sbin_PROGRAMS = ospf6d
libospf6_a_SOURCES = \
+ ospf6_memory.c \
ospf6_network.c ospf6_message.c ospf6_lsa.c ospf6_lsdb.c \
ospf6_top.c ospf6_area.c ospf6_interface.c ospf6_neighbor.c \
ospf6_flood.c ospf6_route.c ospf6_intra.c ospf6_zebra.c \
@@ -17,6 +18,7 @@ libospf6_a_SOURCES = \
ospf6d.c ospf6_bfd.c
noinst_HEADERS = \
+ ospf6_memory.h \
ospf6_network.h ospf6_message.h ospf6_lsa.h ospf6_lsdb.h \
ospf6_top.h ospf6_area.h ospf6_interface.h ospf6_neighbor.h \
ospf6_flood.h ospf6_route.h ospf6_intra.h ospf6_zebra.h \
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index f24ec46da7..f4835d0532 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -45,6 +45,8 @@
#include "ospf6d.h"
#include "ospf6_bfd.h"
+DEFINE_MTYPE_STATIC(OSPF6D, CFG_PLIST_NAME, "configured prefix list names")
+
unsigned char conf_debug_ospf6_interface = 0;
const char *ospf6_interface_state_str[] =
@@ -262,7 +264,7 @@ ospf6_interface_delete (struct ospf6_interface *oi)
/* plist_name */
if (oi->plist_name)
- XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
+ XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name);
ospf6_bfd_info_free(&(oi->bfd_info));
@@ -1668,8 +1670,8 @@ DEFUN (ipv6_ospf6_advertise_prefix_list,
assert (oi);
if (oi->plist_name)
- XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
- oi->plist_name = XSTRDUP (MTYPE_PREFIX_LIST_STR, argv[0]);
+ XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name);
+ oi->plist_name = XSTRDUP (MTYPE_CFG_PLIST_NAME, argv[0]);
ospf6_interface_connected_route_update (oi->interface);
@@ -1710,7 +1712,7 @@ DEFUN (no_ipv6_ospf6_advertise_prefix_list,
if (oi->plist_name)
{
- XFREE (MTYPE_PREFIX_LIST_STR, oi->plist_name);
+ XFREE (MTYPE_CFG_PLIST_NAME, oi->plist_name);
oi->plist_name = NULL;
}
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index a368b05304..11a77059be 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -29,6 +29,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/ospf6d/ospf6_memory.c b/ospf6d/ospf6_memory.c
new file mode 100644
index 0000000000..7f2fbbf0b7
--- /dev/null
+++ b/ospf6d/ospf6_memory.c
@@ -0,0 +1,44 @@
+/* ospf6d 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 Quagga; 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 "ospf6_memory.h"
+
+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")
diff --git a/ospf6d/ospf6_memory.h b/ospf6d/ospf6_memory.h
new file mode 100644
index 0000000000..3ff5de4c31
--- /dev/null
+++ b/ospf6d/ospf6_memory.h
@@ -0,0 +1,45 @@
+/* ospf6d 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_OSPF6_MEMORY_H
+#define _QUAGGA_OSPF6_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(OSPF6D)
+DECLARE_MTYPE(OSPF6_TOP)
+DECLARE_MTYPE(OSPF6_AREA)
+DECLARE_MTYPE(OSPF6_IF)
+DECLARE_MTYPE(OSPF6_NEIGHBOR)
+DECLARE_MTYPE(OSPF6_ROUTE)
+DECLARE_MTYPE(OSPF6_PREFIX)
+DECLARE_MTYPE(OSPF6_MESSAGE)
+DECLARE_MTYPE(OSPF6_LSA)
+DECLARE_MTYPE(OSPF6_LSA_SUMMARY)
+DECLARE_MTYPE(OSPF6_LSDB)
+DECLARE_MTYPE(OSPF6_VERTEX)
+DECLARE_MTYPE(OSPF6_SPFTREE)
+DECLARE_MTYPE(OSPF6_NEXTHOP)
+DECLARE_MTYPE(OSPF6_EXTERNAL_INFO)
+DECLARE_MTYPE(OSPF6_OTHER)
+
+#endif /* _QUAGGA_OSPF6_MEMORY_H */
diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h
index 9e2efb41d7..b41e8ff001 100644
--- a/ospf6d/ospf6d.h
+++ b/ospf6d/ospf6d.h
@@ -27,6 +27,8 @@
#include "libospf.h"
#include "thread.h"
+#include "ospf6_memory.h"
+
/* global variables */
extern struct thread_master *master;
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index ed7ca94756..453e05ce2e 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 809861995e..5a1de3b136 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/Makefile.am b/ospfd/Makefile.am
index 55f9bf2d8e..62db350c5b 100644
--- a/ospfd/Makefile.am
+++ b/ospfd/Makefile.am
@@ -17,7 +17,7 @@ libospf_la_SOURCES = \
ospf_spf.c ospf_route.c ospf_ase.c ospf_abr.c ospf_ia.c ospf_flood.c \
ospf_lsdb.c ospf_asbr.c ospf_routemap.c ospf_snmp.c \
ospf_opaque.c ospf_te.c ospf_ri.c ospf_vty.c ospf_api.c ospf_apiserver.c \
- ospf_bfd.c
+ ospf_bfd.c ospf_memory.c
ospfdheaderdir = $(pkgincludedir)/ospfd
@@ -29,7 +29,7 @@ noinst_HEADERS = \
ospf_interface.h ospf_neighbor.h ospf_network.h ospf_packet.h \
ospf_zebra.h ospf_spf.h ospf_route.h ospf_ase.h ospf_abr.h ospf_ia.h \
ospf_flood.h ospf_snmp.h ospf_te.h ospf_ri.h ospf_vty.h ospf_apiserver.h \
- ospf_bfd.h
+ ospf_bfd.h ospf_memory.h
ospfd_SOURCES = ospf_main.c
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 55ec2a306c..0ed39af411 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_memory.c b/ospfd/ospf_memory.c
new file mode 100644
index 0000000000..0181e1e1fe
--- /dev/null
+++ b/ospfd/ospf_memory.c
@@ -0,0 +1,56 @@
+/* ospfd 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 Quagga; 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 "ospf_memory.h"
+
+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")
diff --git a/ospfd/ospf_memory.h b/ospfd/ospf_memory.h
new file mode 100644
index 0000000000..b082c95031
--- /dev/null
+++ b/ospfd/ospf_memory.h
@@ -0,0 +1,57 @@
+/* ospfd 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_OSPF_MEMORY_H
+#define _QUAGGA_OSPF_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(OSPFD)
+DECLARE_MTYPE(OSPF_TOP)
+DECLARE_MTYPE(OSPF_AREA)
+DECLARE_MTYPE(OSPF_AREA_RANGE)
+DECLARE_MTYPE(OSPF_NETWORK)
+DECLARE_MTYPE(OSPF_NEIGHBOR_STATIC)
+DECLARE_MTYPE(OSPF_IF)
+DECLARE_MTYPE(OSPF_NEIGHBOR)
+DECLARE_MTYPE(OSPF_ROUTE)
+DECLARE_MTYPE(OSPF_TMP)
+DECLARE_MTYPE(OSPF_LSA)
+DECLARE_MTYPE(OSPF_LSA_DATA)
+DECLARE_MTYPE(OSPF_LSDB)
+DECLARE_MTYPE(OSPF_PACKET)
+DECLARE_MTYPE(OSPF_FIFO)
+DECLARE_MTYPE(OSPF_VERTEX)
+DECLARE_MTYPE(OSPF_VERTEX_PARENT)
+DECLARE_MTYPE(OSPF_NEXTHOP)
+DECLARE_MTYPE(OSPF_PATH)
+DECLARE_MTYPE(OSPF_VL_DATA)
+DECLARE_MTYPE(OSPF_CRYPT_KEY)
+DECLARE_MTYPE(OSPF_EXTERNAL_INFO)
+DECLARE_MTYPE(OSPF_DISTANCE)
+DECLARE_MTYPE(OSPF_IF_INFO)
+DECLARE_MTYPE(OSPF_IF_PARAMS)
+DECLARE_MTYPE(OSPF_MESSAGE)
+DECLARE_MTYPE(OSPF_MPLS_TE)
+DECLARE_MTYPE(OSPF_PCE_PARAMS)
+
+#endif /* _QUAGGA_OSPF_MEMORY_H */
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 9b395b3e8e..33980b35c6 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_packet.c b/ospfd/ospf_packet.c
index 399a558a0d..b7ef24409e 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -49,6 +49,26 @@
#include "ospfd/ospf_flood.h"
#include "ospfd/ospf_dump.h"
+/*
+ * OSPF Fragmentation / fragmented writes
+ *
+ * ospfd can support writing fragmented packets, for cases where
+ * kernel will not fragment IP_HDRINCL and/or multicast destined
+ * packets (ie TTBOMK all kernels, BSD, SunOS, Linux). However,
+ * SunOS, probably BSD too, clobber the user supplied IP ID and IP
+ * flags fields, hence user-space fragmentation will not work.
+ * Only Linux is known to leave IP header unmolested.
+ * Further, fragmentation really should be done the kernel, which already
+ * supports it, and which avoids nasty IP ID state problems.
+ *
+ * Fragmentation of OSPF packets can be required on networks with router
+ * with many many interfaces active in one area, or on networks with links
+ * with low MTUs.
+ */
+#ifdef GNU_LINUX
+#define WANT_OSPF_WRITE_FRAGMENT
+#endif
+
/* Packet Type String. */
const struct message ospf_packet_type_str[] =
{
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index b55105ac8f..12d589cd99 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -713,12 +713,14 @@ update_linkparams(struct mpls_te_link *lp)
/* Get the Interface structure */
if ((ifp = lp->ifp) == NULL)
{
- zlog_warn("OSPF MPLS-TE: Abort update TE parameters: no interface associated to Link Parameters");
+ if (IS_DEBUG_OSPF_TE)
+ zlog_debug("OSPF MPLS-TE: Abort update TE parameters: no interface associated to Link Parameters");
return;
}
if (!HAS_LINK_PARAMS(ifp))
{
- zlog_warn("OSPF MPLS-TE: Abort update TE parameters: no Link Parameters for interface");
+ if (IS_DEBUG_OSPF_TE)
+ zlog_debug("OSPF MPLS-TE: Abort update TE parameters: no Link Parameters for interface");
return;
}
@@ -1179,7 +1181,7 @@ build_link_tlv (struct stream *s, struct mpls_te_link *lp)
build_link_subtlv (s, &lp->pkt_loss.header);
build_link_subtlv (s, &lp->res_bw.header);
build_link_subtlv (s, &lp->ava_bw.header);
- build_link_subtlv (s, &lp->res_bw.header);
+ build_link_subtlv (s, &lp->use_bw.header);
return;
}
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index af238c53ae..bc4acf993b 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -29,6 +29,8 @@
#include "filter.h"
#include "log.h"
+#include "ospf_memory.h"
+
#define OSPF_VERSION 2
/* VTY port number. */
diff --git a/pimd/Makefile.am b/pimd/Makefile.am
index d578c97363..eba05076d5 100644
--- a/pimd/Makefile.am
+++ b/pimd/Makefile.am
@@ -46,6 +46,7 @@ sbin_PROGRAMS = pimd
noinst_PROGRAMS = test_igmpv3_join
libpim_a_SOURCES = \
+ pim_memory.c \
pimd.c pim_version.c pim_cmd.c pim_signals.c pim_iface.c \
pim_vty.c pim_igmp.c pim_sock.c pim_zebra.c \
pim_igmpv3.c pim_str.c pim_mroute.c pim_util.c pim_time.c \
@@ -56,6 +57,7 @@ libpim_a_SOURCES = \
pim_static.c pim_br.c pim_register.c pim_routemap.c
noinst_HEADERS = \
+ pim_memory.h \
pimd.h pim_version.h pim_cmd.h pim_signals.h pim_iface.h \
pim_vty.h pim_igmp.h pim_sock.h pim_zebra.h \
pim_igmpv3.h pim_str.h pim_mroute.h pim_util.h pim_time.h \
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index b65b925fad..aa3db3d5b2 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -31,6 +31,8 @@
#include <signal.h>
#include "memory.h"
+#include "vrf.h"
+#include "memory_vty.h"
#include "filter.h"
#include "vty.h"
#include "sigevent.h"
diff --git a/pimd/pim_memory.c b/pimd/pim_memory.c
new file mode 100644
index 0000000000..6014725020
--- /dev/null
+++ b/pimd/pim_memory.c
@@ -0,0 +1,41 @@
+/* pimd 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 Quagga; 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 "pim_memory.h"
+
+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")
diff --git a/pimd/pim_memory.h b/pimd/pim_memory.h
new file mode 100644
index 0000000000..81841e58b6
--- /dev/null
+++ b/pimd/pim_memory.h
@@ -0,0 +1,42 @@
+/* pimd 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_PIM_MEMORY_H
+#define _QUAGGA_PIM_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(PIMD)
+DECLARE_MTYPE(PIM_CHANNEL_OIL)
+DECLARE_MTYPE(PIM_INTERFACE)
+DECLARE_MTYPE(PIM_IGMP_JOIN)
+DECLARE_MTYPE(PIM_IGMP_SOCKET)
+DECLARE_MTYPE(PIM_IGMP_GROUP)
+DECLARE_MTYPE(PIM_IGMP_GROUP_SOURCE)
+DECLARE_MTYPE(PIM_NEIGHBOR)
+DECLARE_MTYPE(PIM_IFCHANNEL)
+DECLARE_MTYPE(PIM_UPSTREAM)
+DECLARE_MTYPE(PIM_SSMPINGD)
+DECLARE_MTYPE(PIM_STATIC_ROUTE)
+DECLARE_MTYPE(PIM_BR)
+
+#endif /* _QUAGGA_PIM_MEMORY_H */
diff --git a/pimd/pimd.h b/pimd/pimd.h
index 6d48d83621..8855a2ab3f 100644
--- a/pimd/pimd.h
+++ b/pimd/pimd.h
@@ -25,6 +25,7 @@
#include <stdint.h>
+#include "pim_memory.h"
#include "pim_assert.h"
#define PIMD_PROGNAME "pimd"
diff --git a/ripd/Makefile.am b/ripd/Makefile.am
index 571a4993dd..e7073a7902 100644
--- a/ripd/Makefile.am
+++ b/ripd/Makefile.am
@@ -10,10 +10,12 @@ noinst_LIBRARIES = librip.a
sbin_PROGRAMS = ripd
librip_a_SOURCES = \
+ rip_memory.c \
ripd.c rip_zebra.c rip_interface.c rip_debug.c rip_snmp.c \
rip_routemap.c rip_peer.c rip_offset.c
noinst_HEADERS = \
+ rip_memory.h \
ripd.h rip_debug.h rip_interface.h
ripd_SOURCES = \
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index aa1c4ff4df..796647c3e5 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/ripd/rip_memory.c b/ripd/rip_memory.c
new file mode 100644
index 0000000000..d2a958064f
--- /dev/null
+++ b/ripd/rip_memory.c
@@ -0,0 +1,35 @@
+/* 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 Quagga; 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 "rip_memory.h"
+
+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")
diff --git a/ripd/rip_memory.h b/ripd/rip_memory.h
new file mode 100644
index 0000000000..7aec219305
--- /dev/null
+++ b/ripd/rip_memory.h
@@ -0,0 +1,36 @@
+/* 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_RIP_MEMORY_H
+#define _QUAGGA_RIP_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(RIPD)
+DECLARE_MTYPE(RIP)
+DECLARE_MTYPE(RIP_INFO)
+DECLARE_MTYPE(RIP_INTERFACE)
+DECLARE_MTYPE(RIP_PEER)
+DECLARE_MTYPE(RIP_OFFSET_LIST)
+DECLARE_MTYPE(RIP_DISTANCE)
+
+#endif /* _QUAGGA_RIP_MEMORY_H */
diff --git a/ripd/ripd.h b/ripd/ripd.h
index d01d0b6bbe..7c77b26d41 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -22,6 +22,8 @@
#ifndef _ZEBRA_RIP_H
#define _ZEBRA_RIP_H
+#include "rip_memory.h"
+
/* RIP version number. */
#define RIPv1 1
#define RIPv2 2
diff --git a/ripngd/Makefile.am b/ripngd/Makefile.am
index df0f7d377e..c08e58a90c 100644
--- a/ripngd/Makefile.am
+++ b/ripngd/Makefile.am
@@ -10,10 +10,12 @@ noinst_LIBRARIES = libripng.a
sbin_PROGRAMS = ripngd
libripng_a_SOURCES = \
+ ripng_memory.c \
ripng_interface.c ripngd.c ripng_zebra.c ripng_route.c ripng_debug.c \
ripng_routemap.c ripng_offset.c ripng_peer.c ripng_nexthop.c
noinst_HEADERS = \
+ ripng_memory.h \
ripng_debug.h ripng_route.h ripngd.h ripng_nexthop.h
ripngd_SOURCES = \
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index f401a43156..e7ecbf9690 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/ripngd/ripng_memory.c b/ripngd/ripng_memory.c
new file mode 100644
index 0000000000..1d2320ee26
--- /dev/null
+++ b/ripngd/ripng_memory.c
@@ -0,0 +1,35 @@
+/* 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 Quagga; 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 "ripng_memory.h"
+
+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")
diff --git a/ripngd/ripng_memory.h b/ripngd/ripng_memory.h
new file mode 100644
index 0000000000..76b830afb4
--- /dev/null
+++ b/ripngd/ripng_memory.h
@@ -0,0 +1,36 @@
+/* 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_RIPNG_MEMORY_H
+#define _QUAGGA_RIPNG_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(RIPNGD)
+DECLARE_MTYPE(RIPNG)
+DECLARE_MTYPE(RIPNG_ROUTE)
+DECLARE_MTYPE(RIPNG_AGGREGATE)
+DECLARE_MTYPE(RIPNG_PEER)
+DECLARE_MTYPE(RIPNG_OFFSET_LIST)
+DECLARE_MTYPE(RIPNG_RTE_DATA)
+
+#endif /* _QUAGGA_RIPNG_MEMORY_H */
diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h
index b87b927f48..5337eb88f3 100644
--- a/ripngd/ripngd.h
+++ b/ripngd/ripngd.h
@@ -26,6 +26,8 @@
#include <zclient.h>
#include <vty.h>
+#include "ripng_memory.h"
+
/* RIPng version and port number. */
#define RIPNG_V1 1
#define RIPNG_PORT_DEFAULT 521
diff --git a/tests/common-cli.c b/tests/common-cli.c
index 7c34e6a559..aed20b2d53 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/heavy-wq.c b/tests/heavy-wq.c
index 2f133cc5d4..2d15dc37bd 100644
--- a/tests/heavy-wq.c
+++ b/tests/heavy-wq.c
@@ -38,6 +38,10 @@
#include "tests.h"
+DEFINE_MGROUP(TEST_HEAVYWQ, "heavy-wq test")
+DEFINE_MTYPE_STATIC(TEST_HEAVYWQ, WQ_NODE, "heavy_wq_node")
+DEFINE_MTYPE_STATIC(TEST_HEAVYWQ, WQ_NODE_STR, "heavy_wq_node->str")
+
extern struct thread_master *master;
static struct work_queue *heavy_wq;
@@ -61,17 +65,17 @@ heavy_wq_add (struct vty *vty, const char *str, int i)
{
struct heavy_wq_node *hn;
- if ((hn = XCALLOC (MTYPE_PREFIX_LIST, sizeof(struct heavy_wq_node))) == NULL)
+ if ((hn = XCALLOC (MTYPE_WQ_NODE, sizeof(struct heavy_wq_node))) == NULL)
{
zlog_err ("%s: unable to allocate hn", __func__);
return;
}
hn->i = i;
- if (!(hn->str = XSTRDUP (MTYPE_PREFIX_LIST_STR, str)))
+ if (!(hn->str = XSTRDUP (MTYPE_WQ_NODE_STR, str)))
{
zlog_err ("%s: unable to xstrdup", __func__);
- XFREE (MTYPE_PREFIX_LIST, hn);
+ XFREE (MTYPE_WQ_NODE, hn);
return;
}
@@ -92,9 +96,9 @@ slow_func_del (struct work_queue *wq, void *data)
struct heavy_wq_node *hn = data;
assert (hn && hn->str);
printf ("%s: %s\n", __func__, hn->str);
- XFREE (MTYPE_PREFIX_LIST_STR, hn->str);
+ XFREE (MTYPE_WQ_NODE_STR, hn->str);
hn->str = NULL;
- XFREE(MTYPE_PREFIX_LIST, hn);
+ XFREE(MTYPE_WQ_NODE, hn);
}
static wq_item_status
diff --git a/tests/main.c b/tests/main.c
index 5396c7d50f..885b8a2923 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 e95d6fb829..67e4035806 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-memory.c b/tests/test-memory.c
index 807249ea6d..6849b9dceb 100644
--- a/tests/test-memory.c
+++ b/tests/test-memory.c
@@ -20,6 +20,9 @@
#include <zebra.h>
#include <memory.h>
+DEFINE_MGROUP(TEST_MEMORY, "memory test")
+DEFINE_MTYPE_STATIC(TEST_MEMORY, TEST, "generic test mtype")
+
/* Memory torture tests
*
* Tests below are generic but comments are focused on interaction with
@@ -52,28 +55,28 @@ main(int argc, char **argv)
/* simple case, test cache */
for (i = 0; i < TIMES; i++)
{
- a[0] = XMALLOC (MTYPE_VTY, 1024);
+ a[0] = XMALLOC (MTYPE_TEST, 1024);
memset (a[0], 1, 1024);
- a[1] = XMALLOC (MTYPE_VTY, 1024);
+ a[1] = XMALLOC (MTYPE_TEST, 1024);
memset (a[1], 1, 1024);
- XFREE(MTYPE_VTY, a[0]); /* should go to cache */
- a[0] = XMALLOC (MTYPE_VTY, 1024); /* should be satisfied from cache */
- XFREE(MTYPE_VTY, a[0]);
- XFREE(MTYPE_VTY, a[1]);
+ XFREE(MTYPE_TEST, a[0]); /* should go to cache */
+ a[0] = XMALLOC (MTYPE_TEST, 1024); /* should be satisfied from cache */
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[1]);
}
printf ("malloc x, malloc y, free x, malloc y, free free\n\n");
/* cache should go invalid, valid, invalid, etc.. */
for (i = 0; i < TIMES; i++)
{
- a[0] = XMALLOC (MTYPE_VTY, 512);
+ a[0] = XMALLOC (MTYPE_TEST, 512);
memset (a[0], 1, 512);
- a[1] = XMALLOC (MTYPE_VTY, 1024); /* invalidate cache */
+ a[1] = XMALLOC (MTYPE_TEST, 1024); /* invalidate cache */
memset (a[1], 1, 1024);
- XFREE(MTYPE_VTY, a[0]);
- a[0] = XMALLOC (MTYPE_VTY, 1024);
- XFREE(MTYPE_VTY, a[0]);
- XFREE(MTYPE_VTY, a[1]);
+ XFREE(MTYPE_TEST, a[0]);
+ a[0] = XMALLOC (MTYPE_TEST, 1024);
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[1]);
/* cache should become valid again on next request */
}
@@ -81,12 +84,12 @@ main(int argc, char **argv)
/* test calloc */
for (i = 0; i < TIMES; i++)
{
- a[0] = XCALLOC (MTYPE_VTY, 1024);
+ a[0] = XCALLOC (MTYPE_TEST, 1024);
memset (a[0], 1, 1024);
- a[1] = XCALLOC (MTYPE_VTY, 512); /* invalidate cache */
+ a[1] = XCALLOC (MTYPE_TEST, 512); /* invalidate cache */
memset (a[1], 1, 512);
- XFREE(MTYPE_VTY, a[1]);
- XFREE(MTYPE_VTY, a[0]);
+ XFREE(MTYPE_TEST, a[1]);
+ XFREE(MTYPE_TEST, a[0]);
/* alloc == 0, cache can become valid again on next request */
}
@@ -95,27 +98,27 @@ main(int argc, char **argv)
for (i = 0; i < TIMES; i++)
{
printf ("calloc a0 1024\n");
- a[0] = XCALLOC (MTYPE_VTY, 1024);
+ a[0] = XCALLOC (MTYPE_TEST, 1024);
memset (a[0], 1, 1024/2);
printf ("calloc 1 1024\n");
- a[1] = XCALLOC (MTYPE_VTY, 1024);
+ a[1] = XCALLOC (MTYPE_TEST, 1024);
memset (a[1], 1, 1024/2);
printf ("realloc 0 1024\n");
- a[3] = XREALLOC (MTYPE_VTY, a[0], 2048); /* invalidate cache */
+ a[3] = XREALLOC (MTYPE_TEST, a[0], 2048); /* invalidate cache */
if (a[3] != NULL)
a[0] = a[3];
memset (a[0], 1, 1024);
printf ("calloc 2 512\n");
- a[2] = XCALLOC (MTYPE_VTY, 512);
+ a[2] = XCALLOC (MTYPE_TEST, 512);
memset (a[2], 1, 512);
printf ("free 1 0 2\n");
- XFREE(MTYPE_VTY, a[1]);
- XFREE(MTYPE_VTY, a[0]);
- XFREE(MTYPE_VTY, a[2]);
+ XFREE(MTYPE_TEST, a[1]);
+ XFREE(MTYPE_TEST, a[0]);
+ XFREE(MTYPE_TEST, a[2]);
/* alloc == 0, cache valid next request */
}
return 0;
diff --git a/tests/test-privs.c b/tests/test-privs.c
index beae81f693..e0118a881c 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/extract.pl.in b/vtysh/extract.pl.in
index 7563daa506..b7533881a3 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -212,7 +212,7 @@ foreach (@ARGV) {
}
}
-my $bad_cli_stomps = 109;
+my $bad_cli_stomps = 108;
# Currently we have $bad_cli_stomps. This was determined by
# running this script and counting up the collisions from what
# was returned.
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 18ca0dca29..f767c64d35 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -46,6 +46,8 @@
#include "lib/grammar_sandbox.h"
+DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy")
+
/* Struct VTY. */
struct vty *vty;
@@ -563,7 +565,7 @@ vtysh_mark_file (const char *filename)
vtysh_execute_no_pager ("enable");
vtysh_execute_no_pager ("configure terminal");
- vty_buf_copy = XCALLOC (MTYPE_VTY, VTY_BUFSIZ);
+ vty_buf_copy = XCALLOC (MTYPE_VTYSH_CMD, VTY_BUFSIZ);
while (fgets (vty->buf, VTY_BUFSIZ, confp))
{
@@ -643,25 +645,25 @@ vtysh_mark_file (const char *filename)
fprintf (stderr,"line %d: Warning...: %s\n", lineno, vty->buf);
fclose(confp);
vty_close(vty);
- XFREE(MTYPE_VTY, vty_buf_copy);
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
return CMD_WARNING;
case CMD_ERR_AMBIGUOUS:
fprintf (stderr,"line %d: %% Ambiguous command: %s\n", lineno, vty->buf);
fclose(confp);
vty_close(vty);
- XFREE(MTYPE_VTY, vty_buf_copy);
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
return CMD_ERR_AMBIGUOUS;
case CMD_ERR_NO_MATCH:
fprintf (stderr,"line %d: %% Unknown command: %s\n", lineno, vty->buf);
fclose(confp);
vty_close(vty);
- XFREE(MTYPE_VTY, vty_buf_copy);
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
return CMD_ERR_NO_MATCH;
case CMD_ERR_INCOMPLETE:
fprintf (stderr,"line %d: %% Command incomplete: %s\n", lineno, vty->buf);
fclose(confp);
vty_close(vty);
- XFREE(MTYPE_VTY, vty_buf_copy);
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
return CMD_ERR_INCOMPLETE;
case CMD_SUCCESS:
fprintf(stdout, "%s", vty->buf);
@@ -693,7 +695,7 @@ vtysh_mark_file (const char *filename)
/* This is the end */
fprintf(stdout, "end\n");
vty_close(vty);
- XFREE(MTYPE_VTY, vty_buf_copy);
+ XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
if (confp != stdin)
fclose(confp);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 75822b1363..3aa2bad81e 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -22,6 +22,9 @@
#ifndef VTYSH_H
#define VTYSH_H
+#include "memory.h"
+DECLARE_MGROUP(MVTYSH)
+
#define VTYSH_ZEBRA 0x01
#define VTYSH_RIPD 0x02
#define VTYSH_RIPNGD 0x04
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 118b7ba035..760003eb3b 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -27,6 +27,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "vtysh/vtysh.h"
#include "vtysh/vtysh_user.h"
+DEFINE_MGROUP(MVTYSH, "vtysh")
+DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG, "Vtysh configuration")
+DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line")
+
vector configvec;
extern int vtysh_writeconfig_integrated;
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 3c46194d31..751152e911 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -37,6 +37,7 @@
#include "memory.h"
#include "privs.h"
#include "linklist.h"
+#include "memory_vty.h"
#include "vtysh/vtysh.h"
#include "vtysh/vtysh_user.h"
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index 0218af81b7..32c94d3f0e 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -27,6 +27,7 @@ sbin_PROGRAMS = zebra
noinst_PROGRAMS = testzebra
zebra_SOURCES = \
+ zebra_memory.c \
zserv.c main.c interface.c connected.c zebra_rib.c zebra_routemap.c \
redistribute.c debug.c rtadv.c zebra_snmp.c zebra_vty.c \
irdp_main.c irdp_interface.c irdp_packet.c router-id.c zebra_fpm.c \
@@ -36,9 +37,11 @@ zebra_SOURCES = \
testzebra_SOURCES = test_main.c zebra_rib.c interface.c connected.c debug.c \
zebra_vty.c zebra_ptm.c zebra_routemap.c zebra_ns.c zebra_vrf.c \
kernel_null.c redistribute_null.c ioctl_null.c misc_null.c zebra_rnh_null.c \
- zebra_ptm_null.c rtadv_null.c if_null.c zserv_null.c zebra_static.c
+ zebra_ptm_null.c rtadv_null.c if_null.c zserv_null.c zebra_static.c \
+ zebra_memory.c
noinst_HEADERS = \
+ zebra_memory.h \
connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
interface.h ipforward.h irdp.h router-id.h kernel_socket.h \
rt_netlink.h zebra_fpm.h zebra_fpm_private.h zebra_rnh.h \
diff --git a/zebra/connected.c b/zebra/connected.c
index 6e82e6ec78..290973a5cb 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -30,6 +30,7 @@
#include "table.h"
#include "log.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "zebra/debug.h"
#include "zebra/zserv.h"
diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c
index 0a9807b8b9..101529c321 100644
--- a/zebra/if_ioctl.c
+++ b/zebra/if_ioctl.c
@@ -28,6 +28,7 @@
#include "ioctl.h"
#include "connected.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "log.h"
#include "vrf.h"
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index 55e2f203ca..45a45f3e81 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -28,6 +28,7 @@
#include "ioctl.h"
#include "connected.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "log.h"
#include "privs.h"
#include "vrf.h"
diff --git a/zebra/if_sysctl.c b/zebra/if_sysctl.c
index d2a506e329..0b71c76214 100644
--- a/zebra/if_sysctl.c
+++ b/zebra/if_sysctl.c
@@ -27,6 +27,7 @@
#include "prefix.h"
#include "connected.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "ioctl.h"
#include "log.h"
#include "interface.h"
diff --git a/zebra/interface.c b/zebra/interface.c
index 2b1e6f4ac6..9be97e2214 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -28,6 +28,7 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "ioctl.h"
#include "connected.h"
#include "log.h"
@@ -1255,6 +1256,19 @@ ALIAS (zebra_interface,
"Interface's name\n"
VRF_CMD_HELP_STR)
+static void
+interface_update_stats (void)
+{
+#ifdef HAVE_PROC_NET_DEV
+ /* If system has interface statistics via proc file system, update
+ statistics. */
+ ifstat_update_proc ();
+#endif /* HAVE_PROC_NET_DEV */
+#ifdef HAVE_NET_RT_IFLIST
+ ifstat_update_sysctl ();
+#endif /* HAVE_NET_RT_IFLIST */
+}
+
struct cmd_node interface_node =
{
INTERFACE_NODE,
@@ -1300,14 +1314,7 @@ DEFUN (show_interface, show_interface_cmd,
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
-#ifdef HAVE_PROC_NET_DEV
- /* If system has interface statistics via proc file system, update
- statistics. */
- ifstat_update_proc ();
-#endif /* HAVE_PROC_NET_DEV */
-#ifdef HAVE_NET_RT_IFLIST
- ifstat_update_sysctl ();
-#endif /* HAVE_NET_RT_IFLIST */
+ interface_update_stats ();
if (argc > 0)
VRF_GET_ID (vrf_id, argv[0]);
@@ -1337,14 +1344,7 @@ DEFUN (show_interface_vrf_all, show_interface_vrf_all_cmd,
struct interface *ifp;
vrf_iter_t iter;
-#ifdef HAVE_PROC_NET_DEV
- /* If system has interface statistics via proc file system, update
- statistics. */
- ifstat_update_proc ();
-#endif /* HAVE_PROC_NET_DEV */
-#ifdef HAVE_NET_RT_IFLIST
- ifstat_update_sysctl ();
-#endif /* HAVE_NET_RT_IFLIST */
+ interface_update_stats ();
/* All interface print. */
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
@@ -1367,14 +1367,7 @@ DEFUN (show_interface_name_vrf,
struct interface *ifp;
vrf_id_t vrf_id = VRF_DEFAULT;
-#ifdef HAVE_PROC_NET_DEV
- /* If system has interface statistics via proc file system, update
- statistics. */
- ifstat_update_proc ();
-#endif /* HAVE_PROC_NET_DEV */
-#ifdef HAVE_NET_RT_IFLIST
- ifstat_update_sysctl ();
-#endif /* HAVE_NET_RT_IFLIST */
+ interface_update_stats ();
if (argc > 1)
VRF_GET_ID (vrf_id, argv[1]);
@@ -1404,14 +1397,7 @@ DEFUN (show_interface_name_vrf_all, show_interface_name_vrf_all_cmd,
vrf_iter_t iter;
int found = 0;
-#ifdef HAVE_PROC_NET_DEV
- /* If system has interface statistics via proc file system, update
- statistics. */
- ifstat_update_proc ();
-#endif /* HAVE_PROC_NET_DEV */
-#ifdef HAVE_NET_RT_IFLIST
- ifstat_update_sysctl ();
-#endif /* HAVE_NET_RT_IFLIST */
+ interface_update_stats ();
/* All interface print. */
for (iter = vrf_first (); iter != VRF_ITER_INVALID; iter = vrf_next (iter))
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 31e6d4510c..8fb4fcad10 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -44,6 +44,7 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "stream.h"
#include "ioctl.h"
#include "connected.h"
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index c68eca42a6..cc3a4abaf3 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -45,6 +45,7 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "stream.h"
#include "ioctl.h"
#include "connected.h"
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index a2ca82099b..25c7aff26b 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -45,6 +45,7 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "stream.h"
#include "ioctl.h"
#include "connected.h"
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index 733e627265..3a232129b6 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -27,6 +27,7 @@
#include "sockunion.h"
#include "connected.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "ioctl.h"
#include "log.h"
#include "str.h"
diff --git a/zebra/main.c b/zebra/main.c
index d8892f582a..e67568140a 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -27,6 +27,8 @@
#include "thread.h"
#include "filter.h"
#include "memory.h"
+#include "zebra_memory.h"
+#include "memory_vty.h"
#include "prefix.h"
#include "log.h"
#include "plist.h"
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index fb9fa0216a..4e7538327f 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -40,6 +40,7 @@
#include "zebra/redistribute.h"
#include "zebra/debug.h"
#include "zebra/router-id.h"
+#include "zebra/zebra_memory.h"
#define ZEBRA_PTM_SUPPORT
diff --git a/zebra/rib.h b/zebra/rib.h
index 500d96cbe4..9867323e6e 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -354,7 +354,7 @@ extern int rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type,
extern struct rib *rib_match (afi_t afi, safi_t safi, vrf_id_t, union g_addr *,
struct route_node **rn_out);
-extern struct rib *rib_match_ipv4_multicast (struct in_addr addr,
+extern struct rib *rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr,
struct route_node **rn_out);
extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t);
diff --git a/zebra/router-id.c b/zebra/router-id.c
index 58c1c031cf..d5d9652c59 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -30,6 +30,7 @@
#include "stream.h"
#include "command.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "ioctl.h"
#include "connected.h"
#include "network.h"
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index fb9aef4aaf..a6984f7f2f 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -34,6 +34,7 @@
#include "connected.h"
#include "table.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "rib.h"
#include "thread.h"
#include "privs.h"
diff --git a/zebra/rtadv.c b/zebra/rtadv.c
index 8384b327ff..ac297890a5 100644
--- a/zebra/rtadv.c
+++ b/zebra/rtadv.c
@@ -23,6 +23,7 @@
#include <zebra.h>
#include "memory.h"
+#include "zebra_memory.h"
#include "sockopt.h"
#include "thread.h"
#include "if.h"
diff --git a/zebra/rtread_sysctl.c b/zebra/rtread_sysctl.c
index d74eef6c5a..b68e1cb74a 100644
--- a/zebra/rtread_sysctl.c
+++ b/zebra/rtread_sysctl.c
@@ -23,6 +23,7 @@
#include <zebra.h>
#include "memory.h"
+#include "zebra_memory.h"
#include "log.h"
#include "vrf.h"
diff --git a/zebra/test_main.c b/zebra/test_main.c
index 95c56bb046..bbaf450282 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -25,6 +25,8 @@
#include "thread.h"
#include "filter.h"
#include "memory.h"
+#include "zebra_memory.h"
+#include "memory_vty.h"
#include "prefix.h"
#include "log.h"
#include "privs.h"
diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c
new file mode 100644
index 0000000000..728051c34b
--- /dev/null
+++ b/zebra/zebra_memory.c
@@ -0,0 +1,37 @@
+/* zebra 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 Quagga; 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 "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, 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")
diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h
new file mode 100644
index 0000000000..fbd8f3261d
--- /dev/null
+++ b/zebra/zebra_memory.h
@@ -0,0 +1,40 @@
+/* zebra 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 Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_ZEBRA_MEMORY_H
+#define _QUAGGA_ZEBRA_MEMORY_H
+
+#include "memory.h"
+
+DECLARE_MGROUP(ZEBRA)
+DECLARE_MTYPE(RTADV_PREFIX)
+DECLARE_MTYPE(ZEBRA_NS)
+DECLARE_MTYPE(ZEBRA_VRF)
+DECLARE_MTYPE(RIB)
+DECLARE_MTYPE(RIB_QUEUE)
+DECLARE_MTYPE(STATIC_ROUTE)
+DECLARE_MTYPE(RIB_DEST)
+DECLARE_MTYPE(RIB_TABLE_INFO)
+DECLARE_MTYPE(RNH)
+DECLARE_MTYPE(NETLINK_NAME)
+
+#endif /* _QUAGGA_ZEBRA_MEMORY_H */
diff --git a/zebra/zebra_ns.c b/zebra/zebra_ns.c
index 084a5d181f..41034e1980 100644
--- a/zebra/zebra_ns.c
+++ b/zebra/zebra_ns.c
@@ -29,6 +29,10 @@
#include "rtadv.h"
#include "zebra_ns.h"
#include "zebra_vrf.h"
+#include "zebra_memory.h"
+
+DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space")
+DEFINE_MTYPE(ZEBRA, NETLINK_NAME, "Netlink name")
struct zebra_ns *dzns;
diff --git a/zebra/zebra_ptm_redistribute.c b/zebra/zebra_ptm_redistribute.c
index a255f5a1e5..396857bc1f 100644
--- a/zebra/zebra_ptm_redistribute.c
+++ b/zebra/zebra_ptm_redistribute.c
@@ -25,6 +25,7 @@
#include "stream.h"
#include "zebra/zserv.h"
#include "zebra/zebra_ptm_redistribute.h"
+#include "zebra/zebra_memory.h"
static int
zsend_interface_bfd_update (int cmd, struct zserv *client,
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 3812101431..e238f8e8eb 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -25,6 +25,7 @@
#include "prefix.h"
#include "table.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "str.h"
#include "command.h"
#include "log.h"
@@ -285,7 +286,7 @@ rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct in6_addr *ipv6,
{
struct nexthop *nexthop;
- nexthop = XCALLOC (MTYPE_NEXTHOP, sizeof (struct nexthop));
+ nexthop = nexthop_new();
nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
nexthop->gate.ipv6 = *ipv6;
nexthop->ifindex = ifindex;
@@ -457,7 +458,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
SET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
- resolved_hop = XCALLOC(MTYPE_NEXTHOP, sizeof (struct nexthop));
+ resolved_hop = nexthop_new();
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* If the resolving route specifies a gateway, use it */
if (newhop->type == NEXTHOP_TYPE_IPV4
@@ -507,7 +508,7 @@ nexthop_active_ipv4 (struct rib *rib, struct nexthop *nexthop, int set,
{
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
- resolved_hop = XCALLOC(MTYPE_NEXTHOP, sizeof (struct nexthop));
+ resolved_hop = nexthop_new();
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* If the resolving route specifies a gateway, use it */
if (newhop->type == NEXTHOP_TYPE_IPV4
@@ -665,7 +666,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
SET_FLAG(rib->status, RIB_ENTRY_NEXTHOPS_CHANGED);
- resolved_hop = XCALLOC(MTYPE_NEXTHOP, sizeof (struct nexthop));
+ resolved_hop = nexthop_new();
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* See nexthop_active_ipv4 for a description how the
* resolved nexthop is constructed. */
@@ -706,7 +707,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
{
SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
- resolved_hop = XCALLOC(MTYPE_NEXTHOP, sizeof (struct nexthop));
+ resolved_hop = nexthop_new();
SET_FLAG (resolved_hop->flags, NEXTHOP_FLAG_ACTIVE);
/* See nexthop_active_ipv4 for a description how the
* resolved nexthop is constructed. */
@@ -764,12 +765,16 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id,
memset (&p, 0, sizeof (struct prefix));
p.family = afi;
- p.u.prefix = *(u_char *)addr;
- p.prefixlen = IPV4_MAX_PREFIXLEN;
if (afi == AFI_IP)
- p.prefixlen = IPV4_MAX_PREFIXLEN;
+ {
+ p.u.prefix4 = addr->ipv4;
+ p.prefixlen = IPV4_MAX_PREFIXLEN;
+ }
else
- p.prefixlen = IPV6_MAX_PREFIXLEN;
+ {
+ p.u.prefix6 = addr->ipv6;
+ p.prefixlen = IPV6_MAX_PREFIXLEN;
+ }
rn = route_node_match (table, (struct prefix *) &p);
@@ -820,7 +825,7 @@ rib_match (afi_t afi, safi_t safi, vrf_id_t vrf_id,
}
struct rib *
-rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out)
+rib_match_ipv4_multicast (vrf_id_t vrf_id, struct in_addr addr, struct route_node **rn_out)
{
struct rib *rib = NULL, *mrib = NULL, *urib = NULL;
struct route_node *m_rn = NULL, *u_rn = NULL;
@@ -829,18 +834,18 @@ rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out)
switch (ipv4_multicast_mode)
{
case MCAST_MRIB_ONLY:
- return rib_match (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT, &gaddr, rn_out);
+ return rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, rn_out);
case MCAST_URIB_ONLY:
- return rib_match (AFI_IP, SAFI_UNICAST, VRF_DEFAULT, &gaddr, rn_out);
+ return rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, rn_out);
case MCAST_NO_CONFIG:
case MCAST_MIX_MRIB_FIRST:
- rib = mrib = rib_match (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT, &gaddr, &m_rn);
+ rib = mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn);
if (!mrib)
- rib = urib = rib_match (AFI_IP, SAFI_UNICAST, VRF_DEFAULT, &gaddr, &u_rn);
+ rib = urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn);
break;
case MCAST_MIX_DISTANCE:
- mrib = rib_match (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT, &gaddr, &m_rn);
- urib = rib_match (AFI_IP, SAFI_UNICAST, VRF_DEFAULT, &gaddr, &u_rn);
+ mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn);
+ urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn);
if (mrib && urib)
rib = urib->distance < mrib->distance ? urib : mrib;
else if (mrib)
@@ -849,8 +854,8 @@ rib_match_ipv4_multicast (struct in_addr addr, struct route_node **rn_out)
rib = urib;
break;
case MCAST_MIX_PFXLEN:
- mrib = rib_match (AFI_IP, SAFI_MULTICAST, VRF_DEFAULT, &gaddr, &m_rn);
- urib = rib_match (AFI_IP, SAFI_UNICAST, VRF_DEFAULT, &gaddr, &u_rn);
+ mrib = rib_match (AFI_IP, SAFI_MULTICAST, vrf_id, &gaddr, &m_rn);
+ urib = rib_match (AFI_IP, SAFI_UNICAST, vrf_id, &gaddr, &u_rn);
if (mrib && urib)
rib = u_rn->p.prefixlen > m_rn->p.prefixlen ? urib : mrib;
else if (mrib)
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index ef2357b99c..fdb187a23a 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -48,6 +48,7 @@
#include "zebra/zebra_rnh.h"
#include "zebra/zebra_routemap.h"
#include "zebra/interface.h"
+#include "zebra/zebra_memory.h"
static void free_state(vrf_id_t vrf_id, struct rib *rib, struct route_node *rn);
static void copy_state(struct rnh *rnh, struct rib *rib,
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 1417824d07..e6c5a3e917 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -22,6 +22,7 @@
#include <zebra.h>
#include "memory.h"
+#include "zebra_memory.h"
#include "prefix.h"
#include "rib.h"
#include "routemap.h"
diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c
index 7d47510635..18efe26d9f 100644
--- a/zebra/zebra_static.c
+++ b/zebra/zebra_static.c
@@ -32,6 +32,7 @@
#include "zebra/zebra_static.h"
#include "zebra/zebra_rnh.h"
#include "zebra/redistribute.h"
+#include "zebra/zebra_memory.h"
/* Install static route into rib. */
void
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index d9bd919bfe..890d749ca4 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -23,12 +23,14 @@
#include "log.h"
#include "linklist.h"
+#include "memory.h"
#include "zebra/debug.h"
#include "zebra/zserv.h"
#include "zebra/rib.h"
#include "zebra/zebra_vrf.h"
#include "zebra/router-id.h"
+#include "zebra/zebra_memory.h"
#include "zebra/zebra_static.h"
extern struct zebra_t zebrad;
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 72d0ced658..a7ee63d87f 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -22,6 +22,7 @@
#include <zebra.h>
#include "memory.h"
+#include "zebra_memory.h"
#include "if.h"
#include "prefix.h"
#include "command.h"
@@ -30,6 +31,7 @@
#include "nexthop.h"
#include "vrf.h"
#include "lib/json.h"
+#include "routemap.h"
#include "zebra/zserv.h"
#include "zebra/zebra_vrf.h"
@@ -311,7 +313,7 @@ DEFUN (show_ip_rpf_addr,
return CMD_WARNING;
}
- rib = rib_match_ipv4_multicast (addr, &rn);
+ rib = rib_match_ipv4_multicast (VRF_DEFAULT, addr, &rn);
if (rib)
vty_show_ip_route_detail (vty, rn, 1);
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 020a252371..3402bf1dfb 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -27,6 +27,7 @@
#include "thread.h"
#include "stream.h"
#include "memory.h"
+#include "zebra_memory.h"
#include "table.h"
#include "rib.h"
#include "network.h"
@@ -748,87 +749,33 @@ zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p,
}
static int
-zsend_nexthop_lookup (struct zserv *client, afi_t afi, safi_t safi,
- vrf_id_t vrf_id, union g_addr *addr)
+zsend_write_nexthop (struct stream *s, struct nexthop *nexthop)
{
- struct stream *s;
- struct rib *rib;
- unsigned long nump;
- u_char num;
- struct nexthop *nexthop;
-
- /* Lookup nexthop. */
- rib = rib_match (afi, safi, vrf_id, addr, NULL);
-
- /* Get output stream. */
- s = client->obuf;
- stream_reset (s);
-
- /* Fill in result. */
- if (afi == AFI_IP)
- {
- zserv_create_header (s, ZEBRA_IPV4_NEXTHOP_LOOKUP, vrf_id);
- stream_put_in_addr (s, &addr->ipv4);
- }
- else
- {
- zserv_create_header (s, ZEBRA_IPV6_NEXTHOP_LOOKUP, vrf_id);
- stream_put (s, &addr->ipv6, 16);
- }
-
- if (rib)
- {
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zlog_debug("%s: Matching rib entry found.", __func__);
- stream_putl (s, rib->metric);
- num = 0;
- nump = stream_get_endp(s);
- stream_putc (s, 0);
- /* Only non-recursive routes are elegible to resolve nexthop we
- * are looking up. Therefore, we will just iterate over the top
- * chain of nexthops. */
- for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
- if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
- {
- stream_putc (s, nexthop->type);
- switch (nexthop->type)
- {
- case NEXTHOP_TYPE_IPV4:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- stream_putl (s, nexthop->ifindex);
- break;
- case NEXTHOP_TYPE_IPV6:
- stream_put (s, &nexthop->gate.ipv6, 16);
- break;
- case NEXTHOP_TYPE_IPV6_IFINDEX:
- stream_put (s, &nexthop->gate.ipv6, 16);
- stream_putl (s, nexthop->ifindex);
- break;
- case NEXTHOP_TYPE_IFINDEX:
- stream_putl (s, nexthop->ifindex);
- break;
- default:
- /* do nothing */
- break;
- }
- num++;
- }
- stream_putc_at (s, nump, num);
- }
- else
+ stream_putc (s, nexthop->type);
+ switch (nexthop->type)
{
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zlog_debug("%s: No matching rib entry found.", __func__);
- stream_putl (s, 0);
- stream_putc (s, 0);
+ case NEXTHOP_TYPE_IPV4:
+ stream_put_in_addr (s, &nexthop->gate.ipv4);
+ break;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ stream_put_in_addr (s, &nexthop->gate.ipv4);
+ stream_putl (s, nexthop->ifindex);
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ stream_put (s, &nexthop->gate.ipv6, 16);
+ break;
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ stream_put (s, &nexthop->gate.ipv6, 16);
+ stream_putl (s, nexthop->ifindex);
+ break;
+ case NEXTHOP_TYPE_IFINDEX:
+ stream_putl (s, nexthop->ifindex);
+ break;
+ default:
+ /* do nothing */
+ break;
}
-
- stream_putw_at (s, 0, stream_get_endp (s));
-
- return zebra_server_send_message(client);
+ return 1;
}
/* Nexthop register */
@@ -977,26 +924,7 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc
* chain of nexthops. */
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_FIB))
- {
- stream_putc (s, nexthop->type);
- switch (nexthop->type)
- {
- case NEXTHOP_TYPE_IPV4:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- stream_putl (s, nexthop->ifindex);
- break;
- case NEXTHOP_TYPE_IFINDEX:
- stream_putl (s, nexthop->ifindex);
- break;
- default:
- /* do nothing */
- break;
- }
- num++;
- }
+ num += zsend_write_nexthop (s, nexthop);
stream_putc_at (s, nump, num); /* store nexthop_num */
}
@@ -1012,69 +940,6 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc
return zebra_server_send_message(client);
}
-static int
-zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p,
- vrf_id_t vrf_id)
-{
- struct stream *s;
- struct rib *rib;
- unsigned long nump;
- u_char num;
- struct nexthop *nexthop;
-
- /* Lookup nexthop. */
- rib = rib_lookup_ipv4 (p, vrf_id);
-
- /* Get output stream. */
- s = client->obuf;
- stream_reset (s);
-
- /* Fill in result. */
- zserv_create_header (s, ZEBRA_IPV4_IMPORT_LOOKUP, vrf_id);
- stream_put_in_addr (s, &p->prefix);
-
- if (rib)
- {
- stream_putl (s, rib->metric);
- num = 0;
- nump = stream_get_endp(s);
- stream_putc (s, 0);
- for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
- if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FIB)
- || nexthop_has_fib_child(nexthop))
- {
- stream_putc (s, nexthop->type);
- switch (nexthop->type)
- {
- case NEXTHOP_TYPE_IPV4:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- break;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- stream_put_in_addr (s, &nexthop->gate.ipv4);
- stream_putl (s, nexthop->ifindex);
- break;
- case NEXTHOP_TYPE_IFINDEX:
- stream_putl (s, nexthop->ifindex);
- break;
- default:
- /* do nothing */
- break;
- }
- num++;
- }
- stream_putc_at (s, nump, num);
- }
- else
- {
- stream_putl (s, 0);
- stream_putc (s, 0);
- }
-
- stream_putw_at (s, 0, stream_get_endp (s));
-
- return zebra_server_send_message(client);
-}
-
/* Router-id is updated. Send ZEBRA_ROUTER_ID_ADD to client. */
int
zsend_router_id_update (struct zserv *client, struct prefix *p,
@@ -1356,22 +1221,6 @@ zread_ipv4_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
return 0;
}
-/* Nexthop lookup for IPv4. */
-static int
-zread_ipv4_nexthop_lookup (struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
-{
- struct in_addr addr;
- char buf[BUFSIZ];
-
- addr.s_addr = stream_get_ipv4 (client->ibuf);
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zlog_debug("%s: looking up %s", __func__,
- inet_ntop (AF_INET, &addr, buf, BUFSIZ));
- return zsend_nexthop_lookup (client, AFI_IP, SAFI_UNICAST,
- zvrf->vrf_id, (union g_addr *)&addr);
-}
-
/* MRIB Nexthop lookup for IPv4. */
static int
zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
@@ -1380,24 +1229,10 @@ zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zeb
struct rib *rib;
addr.s_addr = stream_get_ipv4 (client->ibuf);
- rib = rib_match_ipv4_multicast (addr, NULL);
+ rib = rib_match_ipv4_multicast (zvrf->vrf_id, addr, NULL);
return zsend_ipv4_nexthop_lookup_mrib (client, addr, rib, zvrf);
}
-/* Nexthop lookup for IPv4. */
-static int
-zread_ipv4_import_lookup (struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
-{
- struct prefix_ipv4 p;
-
- p.family = AF_INET;
- p.prefixlen = stream_getc (client->ibuf);
- p.prefix.s_addr = stream_get_ipv4 (client->ibuf);
-
- return zsend_ipv4_import_lookup (client, &p, zvrf->vrf_id);
-}
-
/* Zebra server IPv6 prefix add function. */
static int
zread_ipv4_route_ipv6_nexthop_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
@@ -1638,7 +1473,7 @@ zread_ipv6_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
rib->vrf_id = zvrf->vrf_id;
rib->table = zvrf->table_id;
- ret = rib_add_multipath (AFI_IP, safi, &p, rib);
+ ret = rib_add_multipath (AFI_IP6, safi, &p, rib);
/* Stats */
if (ret > 0)
client->v6_route_add_cnt++;
@@ -1729,22 +1564,6 @@ zread_ipv6_delete (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
return 0;
}
-static int
-zread_ipv6_nexthop_lookup (struct zserv *client, u_short length,
- struct zebra_vrf *zvrf)
-{
- struct in6_addr addr;
- char buf[BUFSIZ];
-
- stream_get (&addr, client->ibuf, 16);
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zlog_debug("%s: looking up %s", __func__,
- inet_ntop (AF_INET6, &addr, buf, BUFSIZ));
-
- return zsend_nexthop_lookup (client, AFI_IP6, SAFI_UNICAST,
- zvrf->vrf_id, (union g_addr *)&addr);
-}
-
/* Register zebra server router-id information. Send current router-id */
static int
zread_router_id_add (struct zserv *client, u_short length, struct zebra_vrf *zvrf)
@@ -2068,18 +1887,9 @@ zebra_client_read (struct thread *thread)
case ZEBRA_REDISTRIBUTE_DEFAULT_DELETE:
zebra_redistribute_default_delete (command, client, length, zvrf);
break;
- case ZEBRA_IPV4_NEXTHOP_LOOKUP:
- zread_ipv4_nexthop_lookup (client, length, zvrf);
- break;
case ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB:
zread_ipv4_nexthop_lookup_mrib (client, length, zvrf);
break;
- case ZEBRA_IPV6_NEXTHOP_LOOKUP:
- zread_ipv6_nexthop_lookup (client, length, zvrf);
- break;
- case ZEBRA_IPV4_IMPORT_LOOKUP:
- zread_ipv4_import_lookup (client, length, zvrf);
- break;
case ZEBRA_HELLO:
zread_hello (client);
break;