From b7a24e50b0bb188be28a155ff5a3cd2272a10e5a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 13 Sep 2016 15:43:54 -0400 Subject: [PATCH 01/29] doc: Get isisd.text included properly When building from a 'make dist' allow the proper distribution of the new isisd.texi to build documentation properly. Signed-off-by: Donald Sharp --- doc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) $< "$@" From ebe209f252a676c819c7992eebf0fee220c7c41a Mon Sep 17 00:00:00 2001 From: David Lebrun Date: Tue, 24 May 2016 11:02:43 +0200 Subject: [PATCH 02/29] ospfd: Fix malformed link TLV when LP_USE_BW is set (cherry picked from commit 6e88e97786e1223e2b59a995ec330c1f49c55b26) --- ospfd/ospf_te.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index b55105ac8f..c118e46c55 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1179,7 +1179,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; } From 68558b13099589c5def8873448fa419293b789f3 Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Tue, 14 Jun 2016 15:57:31 +0200 Subject: [PATCH 03/29] Update isis_te.[c,h] to newly RFC7810 draft-ietf-isis-te-metric-extensions-11 has been published as RFC 7810 Signed-off-by: Olivier Dugeon (cherry picked from commit b2d48d2838ef4813f4c7c7d0ce1d55dc25e3acf1) --- isisd/isis_te.c | 2 +- isisd/isis_te.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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; From 10fbd59a57f5f5b9ebacd3d50c2529a984b637b9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 08:23:27 -0400 Subject: [PATCH 04/29] zebra: Refactor nexthop sending When building a stream of nexthop information, refactor the code that writes it to 1 function. Signed-off-by: Donald Sharp Reviewed-by: Daniel Walton --- zebra/zserv.c | 100 +++++++++++++++++--------------------------------- 1 file changed, 33 insertions(+), 67 deletions(-) diff --git a/zebra/zserv.c b/zebra/zserv.c index 020a252371..aad0b15a88 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -747,6 +747,36 @@ zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p, return zebra_server_send_message(client); } +static int +zsend_write_nexthop (struct stream *s, struct nexthop *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_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; + } + return 1; +} + static int zsend_nexthop_lookup (struct zserv *client, afi_t afi, safi_t safi, vrf_id_t vrf_id, union g_addr *addr) @@ -789,33 +819,7 @@ zsend_nexthop_lookup (struct zserv *client, afi_t afi, safi_t safi, * 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++; - } + num += zsend_write_nexthop (s, nexthop); stream_putc_at (s, nump, num); } else @@ -977,26 +981,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 */ } @@ -1042,26 +1027,7 @@ zsend_ipv4_import_lookup (struct zserv *client, struct prefix_ipv4 *p, 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++; - } + num += zsend_write_nexthop (s, nexthop); stream_putc_at (s, nump, num); } else From d71f1c4e6f97a6bb1250a962c1e875e6d65a6c93 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 15:17:50 -0400 Subject: [PATCH 05/29] zebra: Fix broken rib_match rib_match is broken because the prefix is being treated as a char * pointer instead of the correct data type. Signed-off-by: Donald Sharp (cherry picked from commit 8b5d6c95781b7c55faa957a2d3edf00c1ecb5c5a) --- zebra/zebra_rib.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 3812101431..1378d008ca 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -764,12 +764,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); From f86a2b82fe6be0163940d717a99103abb805a00e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 15:34:25 -0400 Subject: [PATCH 06/29] zebra: Pass in vrf to rib_match_ipv4_multicast Pass around the vrf_id to rib_match_ipv4_multicast so that proper lookup can be maintained. Not really needed yet, but future fixing now. Signed-off-by: Donald Sharp --- zebra/rib.h | 2 +- zebra/zebra_rib.c | 18 +++++++++--------- zebra/zebra_vty.c | 2 +- zebra/zserv.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) 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/zebra_rib.c b/zebra/zebra_rib.c index 1378d008ca..45df9ac7dc 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -824,7 +824,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; @@ -833,18 +833,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) @@ -853,8 +853,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_vty.c b/zebra/zebra_vty.c index 72d0ced658..bf1d0a49c6 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -311,7 +311,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 aad0b15a88..61f3393ed9 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -1346,7 +1346,7 @@ 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); } From b3d307ba4ac9657ccfc212cc6f9f7da8e6ceeccb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 15:57:31 -0400 Subject: [PATCH 07/29] lib: Make zebra messages types a enum The #define nature of zebra message types makes it stupidly difficult to add /remove message types. Switch to enum Signed-off-by: Donald Sharp (cherry picked from commit 0d63e3c7df981f5b50f27789672f30987911a8cd) --- lib/zebra.h | 103 ++++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/lib/zebra.h b/lib/zebra.h index fdfd471825..c2bb7123e6 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -396,57 +396,58 @@ 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_IPV4_NEXTHOP_LOOKUP, + ZEBRA_IPV6_NEXTHOP_LOOKUP, + ZEBRA_IPV4_IMPORT_LOOKUP, + ZEBRA_IPV6_IMPORT_LOOKUP, + ZEBRA_INTERFACE_RENAME, + 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 From bbcd757a257ca4a1e3faa451d61c0bba1c098456 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 16:04:07 -0400 Subject: [PATCH 08/29] lib, zebra: Remove unused zserv/zclient calls ZEBRA_IPV4_NEXTHOP_LOOKUP and ZEBRA_IPV6_NEXTHOP_LOOKUP were never used by any protocol. Remove dead code Signed-off-by: Donald Sharp (cherry picked from commit 22cd6214bf44863bfb5a34b40ab4abba3c5c4574) --- lib/log.c | 2 -- lib/zebra.h | 2 -- zebra/zserv.c | 96 --------------------------------------------------- 3 files changed, 100 deletions(-) diff --git a/lib/log.c b/lib/log.c index ea50ae18cc..1d251f4aae 100644 --- a/lib/log.c +++ b/lib/log.c @@ -898,8 +898,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), diff --git a/lib/zebra.h b/lib/zebra.h index c2bb7123e6..d393a05727 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -411,8 +411,6 @@ typedef enum { ZEBRA_REDISTRIBUTE_DELETE, ZEBRA_REDISTRIBUTE_DEFAULT_ADD, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - ZEBRA_IPV4_NEXTHOP_LOOKUP, - ZEBRA_IPV6_NEXTHOP_LOOKUP, ZEBRA_IPV4_IMPORT_LOOKUP, ZEBRA_IPV6_IMPORT_LOOKUP, ZEBRA_INTERFACE_RENAME, diff --git a/zebra/zserv.c b/zebra/zserv.c index 61f3393ed9..c6026b6795 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -777,64 +777,6 @@ zsend_write_nexthop (struct stream *s, struct nexthop *nexthop) return 1; } -static int -zsend_nexthop_lookup (struct zserv *client, afi_t afi, safi_t safi, - vrf_id_t vrf_id, union g_addr *addr) -{ - 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)) - num += zsend_write_nexthop (s, nexthop); - stream_putc_at (s, nump, num); - } - else - { - 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); - } - - stream_putw_at (s, 0, stream_get_endp (s)); - - return zebra_server_send_message(client); -} - /* Nexthop register */ static int zserv_rnh_register (struct zserv *client, int sock, u_short length, @@ -1322,22 +1264,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) @@ -1695,22 +1621,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) @@ -2034,15 +1944,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; From 2ae26387131aab068450f9fb9761f1f41c4cf4de Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 14 Sep 2016 19:13:11 -0400 Subject: [PATCH 09/29] lib, zebra: Remove ZEBRA_IPV[4|6]_IMPORT_NEXTHOP Zebra api that was never used. Signed-off-by: Donald Sharp (cherry picked from commit 33361d3992c8bff66247b76e5adaf4b0de8217df) --- lib/log.c | 2 -- lib/zebra.h | 2 -- zebra/zserv.c | 61 --------------------------------------------------- 3 files changed, 65 deletions(-) diff --git a/lib/log.c b/lib/log.c index 1d251f4aae..0d1a8eb4f0 100644 --- a/lib/log.c +++ b/lib/log.c @@ -898,8 +898,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_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), diff --git a/lib/zebra.h b/lib/zebra.h index d393a05727..884cd76e8a 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -411,8 +411,6 @@ typedef enum { ZEBRA_REDISTRIBUTE_DELETE, ZEBRA_REDISTRIBUTE_DEFAULT_ADD, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - ZEBRA_IPV4_IMPORT_LOOKUP, - ZEBRA_IPV6_IMPORT_LOOKUP, ZEBRA_INTERFACE_RENAME, ZEBRA_ROUTER_ID_ADD, ZEBRA_ROUTER_ID_DELETE, diff --git a/zebra/zserv.c b/zebra/zserv.c index c6026b6795..6acda98906 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -939,50 +939,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)) - num += zsend_write_nexthop (s, nexthop); - 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, @@ -1276,20 +1232,6 @@ zread_ipv4_nexthop_lookup_mrib (struct zserv *client, u_short length, struct zeb 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) @@ -1947,9 +1889,6 @@ zebra_client_read (struct thread *thread) case ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB: zread_ipv4_nexthop_lookup_mrib (client, length, zvrf); break; - case ZEBRA_IPV4_IMPORT_LOOKUP: - zread_ipv4_import_lookup (client, length, zvrf); - break; case ZEBRA_HELLO: zread_hello (client); break; From 78860b9f454804ae6026955fbe1ffa7181dd39d0 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Feb 2016 21:17:08 -0500 Subject: [PATCH 10/29] zebra: Refactor interface statistic calling Signed-off-by: Donald Sharp --- zebra/interface.c | 49 ++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/zebra/interface.c b/zebra/interface.c index 2b1e6f4ac6..af1aa08a6d 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1255,6 +1255,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 +1313,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 +1343,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 +1366,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 +1396,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)) From bb374626bbf21a49db0b6baef3e807c880dfbde7 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 16 Sep 2016 20:45:35 -0400 Subject: [PATCH 11/29] zebra: Fix afi mistake When sending the received route in to be added to the rib, actually use the correct Address family. Signed-off-by: Donald Sharp --- zebra/zserv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/zserv.c b/zebra/zserv.c index 6acda98906..b1bf5ed328 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -1472,7 +1472,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++; From 166b75c2595b0720b91f0c34dd64ede9d899d558 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 16 Sep 2016 20:59:35 -0400 Subject: [PATCH 12/29] lib, ospfd: Remove ospf specific #define from zebra.h zebra.h should not know or care about ospf specific code Signed-off-by: Donald Sharp --- lib/zebra.h | 20 -------------------- ospfd/ospf_packet.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/zebra.h b/lib/zebra.h index 884cd76e8a..9a9a12f41f 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -317,26 +317,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 * 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[] = { From ca531bd109351cbce075e9b373971826b6d3d9cc Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 16 Sep 2016 21:07:28 -0400 Subject: [PATCH 13/29] lib: Remove ZEBRA_INTERFACE_RENAME Api in name only. No code, so let's remove. Signed-off-by: Donald Sharp --- lib/log.c | 1 - lib/zebra.h | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/log.c b/lib/log.c index 0d1a8eb4f0..9821483d69 100644 --- a/lib/log.c +++ b/lib/log.c @@ -898,7 +898,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_INTERFACE_RENAME), DESC_ENTRY (ZEBRA_ROUTER_ID_ADD), DESC_ENTRY (ZEBRA_ROUTER_ID_DELETE), DESC_ENTRY (ZEBRA_ROUTER_ID_UPDATE), diff --git a/lib/zebra.h b/lib/zebra.h index 9a9a12f41f..e4ba3360b8 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -391,7 +391,6 @@ typedef enum { ZEBRA_REDISTRIBUTE_DELETE, ZEBRA_REDISTRIBUTE_DEFAULT_ADD, ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - ZEBRA_INTERFACE_RENAME, ZEBRA_ROUTER_ID_ADD, ZEBRA_ROUTER_ID_DELETE, ZEBRA_ROUTER_ID_UPDATE, From ea863ec6f7498d395333501ad34c4896407f86ac Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 8 Jan 2016 07:37:14 -0500 Subject: [PATCH 14/29] lib, bgpd: Remove 'struct fifo' from lib/zebra.h The 'struct fifo' and it's accompanying #defines do not belong in lib/zebra.h. Move them into their own header. Signed-off-by: Donald Sharp (cherry picked from commit b0d02889624eaafa0984873dcd78c086418bdf13) --- bgpd/bgp_advertise.h | 2 ++ lib/Makefile.am | 3 ++- lib/fifo.h | 62 ++++++++++++++++++++++++++++++++++++++++++++ lib/zebra.h | 39 ---------------------------- 4 files changed, 66 insertions(+), 40 deletions(-) create mode 100644 lib/fifo.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 + struct update_subgroup; /* BGP advertise FIFO. */ diff --git a/lib/Makefile.am b/lib/Makefile.am index 5a970c881d..3da6ef7faa 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -30,7 +30,8 @@ pkginclude_HEADERS = \ 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 \ 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 noinst_HEADERS = \ plist_int.h 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/zebra.h b/lib/zebra.h index e4ba3360b8..d7a441c2e9 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -518,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 */ From fdc7ce4a2f7c8c34ec875ed68135c5694c53c48a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 16 Sep 2016 22:21:29 -0400 Subject: [PATCH 15/29] isisd: Remove duplicate "no debug isis lsp-gen" The code for 'no debug isis lsp-gen' is in isisd.c twice. No need for this. Signed-off-by: Donald Sharp --- isisd/isisd.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/isisd/isisd.c b/isisd/isisd.c index 5a90115127..87d45aba37 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -1234,19 +1234,6 @@ DEFUN (debug_isis_lsp_sched, return CMD_SUCCESS; } -DEFUN (no_debug_isis_lsp_sched, - no_debug_isis_lsp_sched_cmd, - "no debug isis lsp-gen", - UNDEBUG_STR - "IS-IS information\n" - "IS-IS scheduling of LSP generation\n") -{ - isis->debugs &= ~DEBUG_LSP_SCHED; - print_debug (vty, DEBUG_LSP_SCHED, 0); - - return CMD_SUCCESS; -} - DEFUN (show_hostname, show_hostname_cmd, "show isis hostname", From 3176e70c104bd26d5fef587f9ed54dd4e9e7cac9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 17 Sep 2016 07:11:19 -0400 Subject: [PATCH 16/29] isisd, vtysh: Fix isis routemaps Apparently extract.pl requires in it's regular expression a space after the DEFUN or ALIAS before the opening ( or it completely skips the command. Brilliant? Signed-off-by: Donald Sharp --- isisd/isis_routemap.c | 167 ++++++++++++++++++++---------------------- vtysh/extract.pl.in | 2 +- 2 files changed, 82 insertions(+), 87 deletions(-) diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index 3e0ab047ed..6ae12d3d10 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -373,75 +373,73 @@ DEFUN(no_match_ip_address, 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); @@ -454,54 +452,52 @@ ALIAS(no_match_ipv6_address, NO_STR MATCH_STR IPV6_STR - "Match IPv6 address of route\n" -); + "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/vtysh/extract.pl.in b/vtysh/extract.pl.in index 7563daa506..293a8a2fe4 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 = 107; # Currently we have $bad_cli_stomps. This was determined by # running this script and counting up the collisions from what # was returned. From 49d41a26c649aa3a098c4316262adcabc7bb840c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 17 Sep 2016 07:25:35 -0400 Subject: [PATCH 17/29] isisd, lib, vtysh: Allow extract.pl to fully work The regular expression for finding DEFUN/ALIAS in extract.pl looks for "DEFUN (" or "ALIAS (" if the *.c file does not have this then it will just silently ignore the cli. Signed-off-by: Donald Sharp --- isisd/isis_redist.c | 100 +++++++++++++++++++++--------------------- isisd/isis_routemap.c | 52 +++++++++++----------- isisd/isis_vty.c | 22 +++++----- isisd/isisd.c | 13 ++++++ lib/thread.c | 28 ++++++------ lib/workqueue.c | 10 ++--- vtysh/extract.pl.in | 2 +- 7 files changed, 120 insertions(+), 107 deletions(-) diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 690ae4720c..6ad3b7ccd1 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -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 6ae12d3d10..fdc0100e77 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -344,29 +344,29 @@ 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); @@ -446,13 +446,13 @@ DEFUN (no_match_ipv6_address, 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") /* ------------------------------------------------------------*/ 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 87d45aba37..4d7f475616 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -1234,6 +1234,19 @@ DEFUN (debug_isis_lsp_sched, return CMD_SUCCESS; } +DEFUN (no_debug_isis_lsp_sched, + no_debug_isis_lsp_sched_cmd, + "no debug isis lsp-sched", + UNDEBUG_STR + "IS-IS information\n" + "IS-IS scheduling of LSP generation\n") +{ + isis->debugs &= ~DEBUG_LSP_SCHED; + print_debug (vty, DEBUG_LSP_SCHED, 0); + + return CMD_SUCCESS; +} + DEFUN (show_hostname, show_hostname_cmd, "show isis hostname", diff --git a/lib/thread.c b/lib/thread.c index a128786c3d..573e9f725d 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -287,13 +287,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 +369,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/workqueue.c b/lib/workqueue.c index d351beb124..772749403c 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -178,11 +178,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/vtysh/extract.pl.in b/vtysh/extract.pl.in index 293a8a2fe4..b7533881a3 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -212,7 +212,7 @@ foreach (@ARGV) { } } -my $bad_cli_stomps = 107; +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. From 6ba26ad5d2bc863917914db0d8354eb834bba264 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 29 May 2015 04:32:33 +0200 Subject: [PATCH 18/29] lib: move memory.[ch] out of the way The following commit will recreate memory.[ch]. Signed-off-by: David Lamparter Acked-by: Vincent JARDIN Acked-by: Donald Sharp --- lib/Makefile.am | 6 +-- lib/memory.h | 98 +--------------------------------- lib/{memory.c => memory_vty.c} | 0 lib/memory_vty.h | 96 +++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 99 deletions(-) rename lib/{memory.c => memory_vty.c} (100%) create mode 100644 lib/memory_vty.h diff --git a/lib/Makefile.am b/lib/Makefile.am index 3da6ef7faa..3d204ce25d 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,11 +10,11 @@ libzebra_la_LDFLAGS = -version-info 0:0:0 libzebra_la_SOURCES = \ network.c pid_output.c getopt.c getopt1.c daemon.c \ checksum.c vector.c linklist.c vty.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 + ptm_lib.c csv.c bfd.c vrf.c systemd.c ns.c memory_vty.c BUILT_SOURCES = memtypes.h route_types.h gitversion.h @@ -31,7 +31,7 @@ pkginclude_HEADERS = \ privs.h sigevent.h pqueue.h jhash.h zassert.h memtypes.h \ workqueue.h route_types.h libospf.h nexthop.h json.h \ ptm_lib.h csv.h bfd.h vrf.h ns.h systemd.h bitfield.h \ - fifo.h + fifo.h memory_vty.h noinst_HEADERS = \ plist_int.h diff --git a/lib/memory.h b/lib/memory.h index 501352993d..15bf280199 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -1,96 +1,2 @@ -/* 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 - -#define array_size(ar) (sizeof(ar) / sizeof(ar[0])) - -/* For pretty printing of memory allocate information. */ -struct memory_list -{ - int index; - const char *format; -}; - -struct mlist { - struct memory_list *list; - const char *name; -}; - -#include "lib/memtypes.h" - -extern struct mlist mlists[]; - -/* #define MEMORY_LOG */ -#ifdef MEMORY_LOG -#define XMALLOC(mtype, size) \ - mtype_zmalloc (__FILE__, __LINE__, (mtype), (size)) -#define XCALLOC(mtype, size) \ - mtype_zcalloc (__FILE__, __LINE__, (mtype), (size)) -#define XREALLOC(mtype, ptr, size) \ - mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size)) -#define XFREE(mtype, ptr) \ - do { \ - mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)); \ - ptr = NULL; } \ - while (0) -#define XSTRDUP(mtype, str) \ - mtype_zstrdup (__FILE__, __LINE__, (mtype), (str)) -#else -#define XMALLOC(mtype, size) zmalloc ((mtype), (size)) -#define XCALLOC(mtype, size) 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); -extern void log_memstats_stderr (const char *); - -/* return number of allocations outstanding for the type */ -extern unsigned long mtype_stats_alloc (int); - -/* Human friendly string for given byte count */ -#define MTYPE_MEMSTR_LEN 20 -extern const char *mtype_memstr (char *, size_t, unsigned long); -#endif /* _ZEBRA_MEMORY_H */ +/* temporary */ +#include "memory_vty.h" diff --git a/lib/memory.c b/lib/memory_vty.c similarity index 100% rename from lib/memory.c rename to lib/memory_vty.c diff --git a/lib/memory_vty.h b/lib/memory_vty.h new file mode 100644 index 0000000000..4d7601607a --- /dev/null +++ b/lib/memory_vty.h @@ -0,0 +1,96 @@ +/* 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 + +#define array_size(ar) (sizeof(ar) / sizeof(ar[0])) + +/* For pretty printing of memory allocate information. */ +struct memory_list +{ + int index; + const char *format; +}; + +struct mlist { + struct memory_list *list; + const char *name; +}; + +#include "lib/memtypes.h" + +extern struct mlist mlists[]; + +/* #define MEMORY_LOG */ +#ifdef MEMORY_LOG +#define XMALLOC(mtype, size) \ + mtype_zmalloc (__FILE__, __LINE__, (mtype), (size)) +#define XCALLOC(mtype, size) \ + mtype_zcalloc (__FILE__, __LINE__, (mtype), (size)) +#define XREALLOC(mtype, ptr, size) \ + mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size)) +#define XFREE(mtype, ptr) \ + do { \ + mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)); \ + ptr = NULL; } \ + while (0) +#define XSTRDUP(mtype, str) \ + mtype_zstrdup (__FILE__, __LINE__, (mtype), (str)) +#else +#define XMALLOC(mtype, size) zmalloc ((mtype), (size)) +#define XCALLOC(mtype, size) zcalloc ((mtype), (size)) +#define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size)) +#define XFREE(mtype, ptr) do { \ + zfree ((mtype), (ptr)); \ + ptr = NULL; } \ + while (0) +#define XSTRDUP(mtype, str) zstrdup ((mtype), (str)) +#endif /* MEMORY_LOG */ + +/* Prototypes of memory function. */ +extern void *zmalloc (int type, size_t size); +extern void *zcalloc (int type, size_t size); +extern void *zrealloc (int type, void *ptr, size_t size); +extern void zfree (int type, void *ptr); +extern char *zstrdup (int type, const char *str); + +extern void *mtype_zmalloc (const char *file, int line, int type, size_t size); + +extern void *mtype_zcalloc (const char *file, int line, int type, size_t size); + +extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr, + size_t size); + +extern void mtype_zfree (const char *file, int line, int type, + void *ptr); + +extern char *mtype_zstrdup (const char *file, int line, int type, + const char *str); +extern void memory_init (void); +extern void log_memstats_stderr (const char *); + +/* return number of allocations outstanding for the type */ +extern unsigned long mtype_stats_alloc (int); + +/* Human friendly string for given byte count */ +#define MTYPE_MEMSTR_LEN 20 +extern const char *mtype_memstr (char *, size_t, unsigned long); +#endif /* _ZEBRA_MEMORY_VTY_H */ From 3b4cd7837562cd78fe80bde94f5aa6729b2f755d Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 27 May 2015 03:45:30 +0200 Subject: [PATCH 19/29] lib: add new extensible memory-type handling This rewrites Quagga's memory per-type allocation counting, without using a fixed global list of types. Instead, source files can declare memory types which get handled through constructor functions called by the dynamic linker during startup. Acked-by: Vincent JARDIN Acked-by: Donald Sharp [DL: v3: forgot "nonnull" attribute on XFREE] Signed-off-by: David Lamparter --- lib/Makefile.am | 2 +- lib/log.c | 8 +++ lib/memory.c | 111 +++++++++++++++++++++++++++++ lib/memory.h | 179 ++++++++++++++++++++++++++++++++++++++++++++++- lib/memory_vty.c | 19 +++++ lib/memory_vty.h | 2 - 6 files changed, 317 insertions(+), 4 deletions(-) create mode 100644 lib/memory.c diff --git a/lib/Makefile.am b/lib/Makefile.am index 3d204ce25d..f7737edcf8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -14,7 +14,7 @@ libzebra_la_SOURCES = \ 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 memory_vty.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 diff --git a/lib/log.c b/lib/log.c index 9821483d69..1ecc5b6df6 100644 --- a/lib/log.c +++ b/lib/log.c @@ -680,6 +680,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 * diff --git a/lib/memory.c b/lib/memory.c new file mode 100644 index 0000000000..60008d4b5b --- /dev/null +++ b/lib/memory.c @@ -0,0 +1,111 @@ +/* + * 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. + */ + +#include + +#include + +#include "memory.h" + +static struct memgroup *mg_first = NULL; +struct memgroup **mg_insert = &mg_first; + +static inline void +mt_count_alloc (struct memtype *mt, size_t size) +{ + mt->n_alloc++; + + if (mt->size == 0) + mt->size = size; + else if (mt->size != size) + mt->size = SIZE_VAR; +} + +static inline void +mt_count_free (struct memtype *mt) +{ + mt->n_alloc--; +} + +static inline void * +mt_checkalloc (struct memtype *mt, void *ptr, size_t size) +{ + if (__builtin_expect(ptr == NULL, 0)) + { + memory_oom (size, mt->name); + return NULL; + } + mt_count_alloc (mt, size); + return ptr; +} + +void * +qmalloc (struct memtype *mt, size_t size) +{ + return mt_checkalloc (mt, malloc (size), size); +} + +void * +qcalloc (struct memtype *mt, size_t size) +{ + return mt_checkalloc (mt, calloc (size, 1), size); +} + +void * +qrealloc (struct memtype *mt, void *ptr, size_t size) +{ + if (ptr) + mt_count_free (mt); + return mt_checkalloc (mt, ptr ? realloc (ptr, size) : malloc (size), size); +} + +void * +qstrdup (struct memtype *mt, const char *str) +{ + return mt_checkalloc (mt, strdup (str), strlen (str) + 1); +} + +void +qfree (struct memtype *mt, void *ptr) +{ + if (ptr) + mt_count_free (mt); + free (ptr); +} + +int +qmem_walk (qmem_walk_fn *func, void *arg) +{ + struct memgroup *mg; + struct memtype *mt; + int rv; + + for (mg = mg_first; mg; mg = mg->next) + { + 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 0; +} diff --git a/lib/memory.h b/lib/memory.h index 15bf280199..0f3ceee1be 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -1,2 +1,179 @@ -/* temporary */ +/* + * 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 + +#define array_size(ar) (sizeof(ar) / sizeof(ar[0])) + +#define SIZE_VAR ~0UL +struct memtype +{ + struct memtype *next; + const char *name; + size_t n_alloc; + size_t size; +}; + +struct memgroup +{ + struct memgroup *next; + struct memtype *types, **insert; + const char *name; +}; + +#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 _ALLOC_SIZE(x) alloc_size(x) +# endif +#endif + +#ifdef __sun +/* Solaris doesn't do constructor priorities due to linker restrictions */ +# undef _CONSTRUCTOR +#endif + +#ifndef _RET_NONNULL +# define _RET_NONNULL +#endif +#ifndef _CONSTRUCTOR +# define _CONSTRUCTOR(x) constructor +#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, \ + }; \ + static void _mginit_##mname (void) \ + __attribute__ ((_CONSTRUCTOR (1000))); \ + static void _mginit_##mname (void) \ + { extern struct memgroup **mg_insert; \ + *mg_insert = &_mg_##mname; \ + mg_insert = &_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, \ + }; \ + static void _mtinit_##mname (void) \ + __attribute__ ((_CONSTRUCTOR (1001))); \ + static void _mtinit_##mname (void) \ + { if (_mg_##group.insert == NULL) \ + _mg_##group.insert = &_mg_##group.types; \ + *_mg_##group.insert = &_mt_##mname; \ + _mg_##group.insert = &_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; + + +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))); + +#if 0 +#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; +} +#endif +/* still here until next commit */ #include "memory_vty.h" + +/* 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 memory_oom (size_t size, const char *name); + +#endif /* _QUAGGA_MEMORY_H */ diff --git a/lib/memory_vty.c b/lib/memory_vty.c index 8d1a03743e..8084aeba0f 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -397,6 +397,24 @@ show_memory_mallinfo (struct vty *vty) } #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", @@ -417,6 +435,7 @@ DEFUN (show_memory, needsep = show_memory_vty (vty, ml->list); } + qmem_walk(qmem_walker, vty); return CMD_SUCCESS; } diff --git a/lib/memory_vty.h b/lib/memory_vty.h index 4d7601607a..d691b9b2b8 100644 --- a/lib/memory_vty.h +++ b/lib/memory_vty.h @@ -21,8 +21,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _ZEBRA_MEMORY_VTY_H #define _ZEBRA_MEMORY_VTY_H -#define array_size(ar) (sizeof(ar) / sizeof(ar[0])) - /* For pretty printing of memory allocate information. */ struct memory_list { From fc7948fafee457874a21aa955c56a617b563f85c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 6 Jan 2016 10:37:22 +0100 Subject: [PATCH 20/29] lib: migrate to new memory-type handling Move over to the new allocation counting added in the previous commit. (This commit is mostly mechanical.) Signed-off-by: David Lamparter Acked-by: Vincent JARDIN --- bgpd/bgp_main.c | 1 + bgpd/bgp_vty.c | 1 + isisd/isis_main.c | 1 + isisd/isis_redist.c | 1 - lib/Makefile.am | 6 +- lib/memory.h | 6 +- lib/memory_vty.c | 270 +---------------- lib/memory_vty.h | 64 +--- lib/memtypes.awk | 87 ------ lib/memtypes.c | 565 +++++++++++++++++------------------- lib/memtypes.pl | 6 + ospf6d/ospf6_main.c | 1 + ospfclient/ospf_apiclient.c | 2 + ospfclient/ospf_apiclient.h | 2 - ospfd/ospf_main.c | 1 + ospfd/ospf_opaque.c | 9 +- ospfd/ospf_te.c | 2 + pimd/pim_main.c | 2 + ripd/rip_main.c | 1 + ripngd/ripng_main.c | 1 + tests/common-cli.c | 1 + tests/main.c | 1 + tests/test-buffer.c | 1 + tests/test-privs.c | 1 + vtysh/vtysh_main.c | 1 + zebra/main.c | 1 + zebra/test_main.c | 1 + 27 files changed, 316 insertions(+), 720 deletions(-) delete mode 100644 lib/memtypes.awk create mode 100755 lib/memtypes.pl 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 #include "memory.h" +#include "memory_vty.h" #include "prefix.h" #include "log.h" #include "privs.h" diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index c83d751743..56db697502 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" 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_redist.c b/isisd/isis_redist.c index 6ad3b7ccd1..cc77785ced 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -24,7 +24,6 @@ #include "if.h" #include "linklist.h" #include "memory.h" -#include "memtypes.h" #include "prefix.h" #include "routemap.h" #include "stream.h" diff --git a/lib/Makefile.am b/lib/Makefile.am index f7737edcf8..7a21511510 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -39,12 +39,12 @@ noinst_HEADERS = \ EXTRA_DIST = \ regex.c regex-gnu.h \ queue.h \ - memtypes.awk \ + memtypes.pl \ route_types.pl route_types.txt \ gitversion.pl -memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.awk - ($(GAWK) -f $(srcdir)/memtypes.awk $(srcdir)/memtypes.c > $@) +memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.pl + @PERL@ $(srcdir)/memtypes.pl < $(srcdir)/memtypes.c > $@ route_types.h: $(srcdir)/route_types.txt $(srcdir)/route_types.pl @PERL@ $(srcdir)/route_types.pl < $(srcdir)/route_types.txt > $@ diff --git a/lib/memory.h b/lib/memory.h index 0f3ceee1be..e8243f1733 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -150,7 +150,6 @@ extern void *qstrdup (struct memtype *mt, const char *str) extern void qfree (struct memtype *mt, void *ptr) __attribute__ ((nonnull (1))); -#if 0 #define XMALLOC(mtype, size) qmalloc(mtype, size) #define XCALLOC(mtype, size) qcalloc(mtype, size) #define XREALLOC(mtype, ptr, size) qrealloc(mtype, ptr, size) @@ -162,9 +161,6 @@ static inline size_t mtype_stats_alloc(struct memtype *mt) { return mt->n_alloc; } -#endif -/* still here until next commit */ -#include "memory_vty.h" /* 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) @@ -176,4 +172,6 @@ extern int qmem_walk (qmem_walk_fn *func, void *arg); extern void memory_oom (size_t size, const char *name); +#include "memtypes.h" + #endif /* _QUAGGA_MEMORY_H */ diff --git a/lib/memory_vty.c b/lib/memory_vty.c index 8084aeba0f..fa9f50a23a 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -28,267 +28,17 @@ #include "log.h" #include "memory.h" - -static void alloc_inc (int); -static void alloc_dec (int); -static void log_memstats(int log_priority); - -static const struct message mstr [] = -{ - { MTYPE_THREAD, "thread" }, - { MTYPE_THREAD_MASTER, "thread_master" }, - { MTYPE_VECTOR, "vector" }, - { MTYPE_VECTOR_INDEX, "vector_index" }, - { MTYPE_IF, "interface" }, - { 0, NULL }, -}; - -/* Fatal memory allocation error occured. */ -static void __attribute__ ((noreturn)) -zerror (const char *fname, int type, size_t size) -{ - zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n", - fname, lookup (mstr, type), (int) size, safe_strerror(errno)); - log_memstats(LOG_WARNING); - /* N.B. It might be preferable to call zlog_backtrace_sigsafe here, since - that function should definitely be safe in an OOM condition. But - unfortunately zlog_backtrace_sigsafe does not support syslog logging at - this time... */ - zlog_backtrace(LOG_WARNING); - abort(); -} - -/* - * Allocate memory of a given size, to be tracked by a given type. - * Effects: Returns a pointer to usable memory. If memory cannot - * be allocated, aborts execution. - */ -void * -zmalloc (int type, size_t size) -{ - void *memory; - - memory = malloc (size); - - if (memory == NULL) - zerror ("malloc", type, size); - - alloc_inc (type); - - return memory; -} - -/* - * Allocate memory as in zmalloc, and also clear the memory. - * 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) -{ - void *memory; - - memory = calloc (1, size); - - if (memory == NULL) - zerror ("calloc", type, size); - - alloc_inc (type); - - return memory; -} - -/* - * Given a pointer returned by zmalloc or 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) -{ - 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) - { - alloc_dec (type); - free (ptr); - } -} - -/* - * Duplicate a string, counting memory usage by type. - * Effects: The string is duplicated, and the return value must - * eventually be passed to zfree with the same type. The function will - * succeed or abort. - */ -char * -zstrdup (int type, const char *str) -{ - void *dup; - - dup = strdup (str); - if (dup == NULL) - zerror ("strdup", type, strlen (str)); - alloc_inc (type); - return dup; -} - -#ifdef MEMORY_LOG -static struct -{ - const char *name; - long alloc; - unsigned long t_malloc; - unsigned long c_malloc; - unsigned long t_calloc; - unsigned long c_calloc; - unsigned long t_realloc; - unsigned long t_free; - unsigned long c_strdup; -} mstat [MTYPE_MAX]; - -static void -mtype_log (char *func, void *memory, const char *file, int line, int type) -{ - zlog_debug ("%s: %s %p %s %d", func, lookup (mstr, type), memory, file, line); -} - -void * -mtype_zmalloc (const char *file, int line, int type, size_t size) -{ - void *memory; - - mstat[type].c_malloc++; - mstat[type].t_malloc++; - - memory = zmalloc (type, size); - mtype_log ("zmalloc", memory, file, line, type); - - return memory; -} - -void * -mtype_zcalloc (const char *file, int line, int type, size_t size) -{ - void *memory; - - mstat[type].c_calloc++; - mstat[type].t_calloc++; - - memory = zzcalloc (type, size); - mtype_log ("xcalloc", memory, file, line, type); - - return memory; -} - -void * -mtype_zrealloc (const char *file, int line, int type, void *ptr, size_t size) -{ - void *memory; - - /* Realloc need before allocated pointer. */ - mstat[type].t_realloc++; - - memory = zrealloc (type, ptr, size); - - mtype_log ("xrealloc", memory, file, line, type); - - return memory; -} - -/* Important function. */ -void -mtype_zfree (const char *file, int line, int type, void *ptr) -{ - mstat[type].t_free++; - - mtype_log ("xfree", ptr, file, line, type); - - zfree (type, ptr); -} - -char * -mtype_zstrdup (const char *file, int line, int type, const char *str) -{ - char *memory; - - mstat[type].c_strdup++; - - memory = zstrdup (type, str); - - mtype_log ("xstrdup", memory, file, line, type); - - return memory; -} -#else -static struct -{ - char *name; - long alloc; -} mstat [MTYPE_MAX]; -#endif /* MEMORY_LOG */ - -/* Increment allocation counter. */ -static void -alloc_inc (int type) -{ - mstat[type].alloc++; -} - -/* Decrement allocation counter. */ -static void -alloc_dec (int type) -{ - mstat[type].alloc--; -} +#include "memory_vty.h" /* Looking up memory status from vty interface. */ #include "vector.h" #include "vty.h" #include "command.h" -static void -log_memstats(int pri) -{ - struct mlist *ml; - - for (ml = mlists; ml->list; ml++) - { - struct memory_list *m; - - zlog (NULL, pri, "Memory utilization in module %s:", ml->name); - for (m = ml->list; m->index >= 0; m++) - if (m->index && mstat[m->index].alloc) - zlog (NULL, pri, " %-30s: %10ld", m->format, mstat[m->index].alloc); - } -} - void log_memstats_stderr (const char *prefix) { +#if 0 struct mlist *ml; struct memory_list *m; int i; @@ -325,8 +75,10 @@ log_memstats_stderr (const char *prefix) fprintf (stderr, "%s: memstats: No remaining tracked memory utilization.\n", prefix); +#endif } +#if 0 static void show_separator(struct vty *vty) { @@ -355,6 +107,7 @@ show_memory_vty (struct vty *vty, struct memory_list *list) } return needsep; } +#endif #ifdef HAVE_MALLINFO static int @@ -421,19 +174,22 @@ DEFUN (show_memory, "Show running system information\n" "Memory statistics\n") { - struct mlist *ml; int needsep = 0; #ifdef HAVE_MALLINFO needsep = show_memory_mallinfo (vty); #endif /* HAVE_MALLINFO */ - + + (void) needsep; +#if 0 + struct mlist *ml; for (ml = mlists; ml->list; ml++) { if (needsep) show_separator (vty); needsep = show_memory_vty (vty, ml->list); } +#endif qmem_walk(qmem_walker, vty); return CMD_SUCCESS; @@ -498,9 +254,3 @@ mtype_memstr (char *buf, size_t len, unsigned long bytes) return buf; } - -unsigned long -mtype_stats_alloc (int type) -{ - return mstat[type].alloc; -} diff --git a/lib/memory_vty.h b/lib/memory_vty.h index d691b9b2b8..7aab01ee5b 100644 --- a/lib/memory_vty.h +++ b/lib/memory_vty.h @@ -21,73 +21,11 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _ZEBRA_MEMORY_VTY_H #define _ZEBRA_MEMORY_VTY_H -/* For pretty printing of memory allocate information. */ -struct memory_list -{ - int index; - const char *format; -}; +#include "memory.h" -struct mlist { - struct memory_list *list; - const char *name; -}; - -#include "lib/memtypes.h" - -extern struct mlist mlists[]; - -/* #define MEMORY_LOG */ -#ifdef MEMORY_LOG -#define XMALLOC(mtype, size) \ - mtype_zmalloc (__FILE__, __LINE__, (mtype), (size)) -#define XCALLOC(mtype, size) \ - mtype_zcalloc (__FILE__, __LINE__, (mtype), (size)) -#define XREALLOC(mtype, ptr, size) \ - mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size)) -#define XFREE(mtype, ptr) \ - do { \ - mtype_zfree (__FILE__, __LINE__, (mtype), (ptr)); \ - ptr = NULL; } \ - while (0) -#define XSTRDUP(mtype, str) \ - mtype_zstrdup (__FILE__, __LINE__, (mtype), (str)) -#else -#define XMALLOC(mtype, size) zmalloc ((mtype), (size)) -#define XCALLOC(mtype, size) zcalloc ((mtype), (size)) -#define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size)) -#define XFREE(mtype, ptr) do { \ - zfree ((mtype), (ptr)); \ - ptr = NULL; } \ - while (0) -#define XSTRDUP(mtype, str) zstrdup ((mtype), (str)) -#endif /* MEMORY_LOG */ - -/* Prototypes of memory function. */ -extern void *zmalloc (int type, size_t size); -extern void *zcalloc (int type, size_t size); -extern void *zrealloc (int type, void *ptr, size_t size); -extern void zfree (int type, void *ptr); -extern char *zstrdup (int type, const char *str); - -extern void *mtype_zmalloc (const char *file, int line, int type, size_t size); - -extern void *mtype_zcalloc (const char *file, int line, int type, size_t size); - -extern void *mtype_zrealloc (const char *file, int line, int type, void *ptr, - size_t size); - -extern void mtype_zfree (const char *file, int line, int type, - void *ptr); - -extern char *mtype_zstrdup (const char *file, int line, int type, - const char *str); extern void memory_init (void); extern void log_memstats_stderr (const char *); -/* return number of allocations outstanding for the type */ -extern unsigned long mtype_stats_alloc (int); - /* Human friendly string for given byte count */ #define MTYPE_MEMSTR_LEN 20 extern const char *mtype_memstr (char *, size_t, unsigned long); diff --git a/lib/memtypes.awk b/lib/memtypes.awk deleted file mode 100644 index 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_[] .....' -# -# Each MTYPE_ within the definition must the second token on the line, -# tokens being delineated by whitespace. It may only consist of the set of -# characters [[:upper:]_[:digit:]]. Eg: -# -# '\n { MTYPE_AWESOME_IPV8 , "Amazing new protocol, says genius" {}..boo' -# -# We try to ignore lines whose first token is /* or *, ie C comment lines. -# So the following should work fine: -# -# '/* This is the best memory_list ever! -# ' * It's got all my MTYPE's */ -# ' -# 'struct memory_list memory_list_my_amazing_mlist[] = = -# '{ -# ' { MTYPE_DONGLE, "Dongle widget" } -# ' { MTYPE_FROB, "Frobulator" }, -# '{ MTYPE_WIPPLE, "Wipple combombulator"} -# '}}} -# -# Even if it isn't quite a valid C declaration. -# - -BEGIN { - mlistregex = "memory_list_(.*)\\[\\]"; - mtyperegex = "^(MTYPE_[[:upper:]_[:digit:]]+).*"; - header = "/* Auto-generated from memtypes.c by " ARGV[0] ". */\n"; - header = header "/* Do not edit! */\n"; - header = header "\n#ifndef _QUAGGA_MEMTYPES_H\n"; - header = header "#define _QUAGGA_MEMTYPES_H\n"; - footer = "\n#endif /* _QUAGGA_MEMTYPES_H */\n\n"; - mlistformat = "extern struct memory_list memory_list_%s[];"; - printf ("%s\n", header); -} - -# catch lines beginning with 'struct memory list ' and try snag the -# memory_list name. Has to be 3rd field. -($0 ~ /^struct memory_list /) && (NF >= 3) { - mlists[lcount++] = gensub(mlistregex, "\\1", "g",$3); -} - -# snag the MTYPE, it must self-standing and the second field, -# though we do manage to tolerate the , C seperator being appended -($1 !~ /^\/?\*/) && ($2 ~ /^MTYPE_/) { - mtype[tcount++] = gensub(mtyperegex, "\\1", "g", $2); -} - -END { - printf("enum\n{\n MTYPE_TMP = 1,\n"); - for (i = 0; i < tcount; i++) { - if (mtype[i] != "" && mtype[i] != "MTYPE_TMP") - printf (" %s,\n", mtype[i]); - } - printf (" MTYPE_MAX,\n};\n\n"); - for (i = 0; i < lcount; i++) { - if (mlists[i] != "") - printf (mlistformat "\n", mlists[i]); - } - printf (footer); -} diff --git a/lib/memtypes.c b/lib/memtypes.c index 510312f336..4fa64a8cb0 100644 --- a/lib/memtypes.c +++ b/lib/memtypes.c @@ -10,308 +10,283 @@ #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 }, -}; +DEFINE_MGROUP(LIB, "libzebra") +DEFINE_MTYPE(LIB, TMP, "Temporary memory") +DEFINE_MTYPE(LIB, STRVEC, "String vector") +DEFINE_MTYPE(LIB, VECTOR, "Vector") +DEFINE_MTYPE(LIB, VECTOR_INDEX, "Vector index") +DEFINE_MTYPE(LIB, LINK_LIST, "Link List") +DEFINE_MTYPE(LIB, LINK_NODE, "Link Node") +DEFINE_MTYPE(LIB, THREAD, "Thread") +DEFINE_MTYPE(LIB, THREAD_MASTER, "Thread master") +DEFINE_MTYPE(LIB, THREAD_STATS, "Thread stats") +DEFINE_MTYPE(LIB, VTY, "VTY") +DEFINE_MTYPE(LIB, VTY_OUT_BUF, "VTY output buffer") +DEFINE_MTYPE(LIB, VTY_HIST, "VTY history") +DEFINE_MTYPE(LIB, IF, "Interface") +DEFINE_MTYPE(LIB, CONNECTED, "Connected") +DEFINE_MTYPE(LIB, NBR_CONNECTED, "Neighbor Connected") +DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label") +DEFINE_MTYPE(LIB, BUFFER, "Buffer") +DEFINE_MTYPE(LIB, BUFFER_DATA, "Buffer data") +DEFINE_MTYPE(LIB, STREAM, "Stream") +DEFINE_MTYPE(LIB, STREAM_DATA, "Stream data") +DEFINE_MTYPE(LIB, STREAM_FIFO, "Stream FIFO") +DEFINE_MTYPE(LIB, PREFIX, "Prefix") +DEFINE_MTYPE(LIB, PREFIX_IPV4, "Prefix IPv4") +DEFINE_MTYPE(LIB, PREFIX_IPV6, "Prefix IPv6") +DEFINE_MTYPE(LIB, HASH, "Hash") +DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket") +DEFINE_MTYPE(LIB, HASH_INDEX, "Hash Index") +DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table") +DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node") +DEFINE_MTYPE(LIB, DISTRIBUTE, "Distribute list") +DEFINE_MTYPE(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname") +DEFINE_MTYPE(LIB, DISTRIBUTE_NAME, "Dist-list name") +DEFINE_MTYPE(LIB, ACCESS_LIST, "Access List") +DEFINE_MTYPE(LIB, ACCESS_LIST_STR, "Access List Str") +DEFINE_MTYPE(LIB, ACCESS_FILTER, "Access Filter") +DEFINE_MTYPE(LIB, PREFIX_LIST, "Prefix List") +DEFINE_MTYPE(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") +DEFINE_MTYPE(LIB, PREFIX_LIST_STR, "Prefix List Str") +DEFINE_MTYPE(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table") +DEFINE_MTYPE(LIB, ROUTE_MAP, "Route map") +DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name") +DEFINE_MTYPE(LIB, ROUTE_MAP_INDEX, "Route map index") +DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule") +DEFINE_MTYPE(LIB, ROUTE_MAP_RULE_STR, "Route map rule str") +DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled") +DEFINE_MTYPE(LIB, ROUTE_MAP_DEP, "Route map dependency") +DEFINE_MTYPE(LIB, CMD_TOKENS, "Command desc") +DEFINE_MTYPE(LIB, KEY, "Key") +DEFINE_MTYPE(LIB, KEYCHAIN, "Key chain") +DEFINE_MTYPE(LIB, IF_RMAP, "Interface route map") +DEFINE_MTYPE(LIB, IF_RMAP_NAME, "I.f. route map name") +DEFINE_MTYPE(LIB, SOCKUNION, "Socket union") +DEFINE_MTYPE(LIB, PRIVS, "Privilege information") +DEFINE_MTYPE(LIB, ZLOG, "Logging") +DEFINE_MTYPE(LIB, ZCLIENT, "Zclient") +DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue") +DEFINE_MTYPE(LIB, WORK_QUEUE_ITEM, "Work queue item") +DEFINE_MTYPE(LIB, WORK_QUEUE_NAME, "Work queue name string") +DEFINE_MTYPE(LIB, PQUEUE, "Priority queue") +DEFINE_MTYPE(LIB, PQUEUE_DATA, "Priority queue data") +DEFINE_MTYPE(LIB, HOST, "host configuration") +DEFINE_MTYPE(LIB, BFD_INFO, "BFD info") +DEFINE_MTYPE(LIB, VRF, "VRF") +DEFINE_MTYPE(LIB, VRF_NAME, "VRF name") +DEFINE_MTYPE(LIB, VRF_BITMAP, "VRF bit-map") +DEFINE_MTYPE(LIB, IF_LINK_PARAMS, "Informational Link Parameters") +DEFINE_MTYPE(LIB, NS, "Logical-Router") +DEFINE_MTYPE(LIB, NS_NAME, "Logical-Router Name") +DEFINE_MTYPE(LIB, NS_BITMAP, "Logical-Router bit-map") -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 } -}; +DEFINE_MGROUP(ZEBRA, "zebra") +DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") +DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") +DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF") +DEFINE_MTYPE(ZEBRA, NEXTHOP, "Nexthop") +DEFINE_MTYPE(ZEBRA, RIB, "RIB") +DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue") +DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route") +DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination") +DEFINE_MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info") +DEFINE_MTYPE(ZEBRA, RNH, "Nexthop tracking object") +DEFINE_MTYPE(ZEBRA, NETLINK_NAME, "Netlink name") -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 }, -}; +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") -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 }, -}; +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") -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 }, -}; +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") -struct memory_list memory_list_vtysh[] = -{ - { MTYPE_VTYSH_CONFIG, "Vtysh configuration", }, - { MTYPE_VTYSH_CONFIG_LINE, "Vtysh configuration line" }, - { -1, NULL }, -}; +DEFINE_MTYPE(BGPD, COMMUNITY, "community") +DEFINE_MTYPE(BGPD, COMMUNITY_VAL, "community val") +DEFINE_MTYPE(BGPD, COMMUNITY_STR, "community str") -struct mlist mlists[] __attribute__ ((unused)) = { - { memory_list_lib, "LIB" }, - { memory_list_zebra, "ZEBRA" }, - { memory_list_rip, "RIP" }, - { memory_list_ripng, "RIPNG" }, - { memory_list_ospf, "OSPF" }, - { memory_list_ospf6, "OSPF6" }, - { memory_list_isis, "ISIS" }, - { memory_list_bgp, "BGP" }, - { memory_list_pim, "PIM" }, - { NULL, NULL}, -}; +DEFINE_MTYPE(BGPD, ECOMMUNITY, "extcommunity") +DEFINE_MTYPE(BGPD, ECOMMUNITY_VAL, "extcommunity val") +DEFINE_MTYPE(BGPD, ECOMMUNITY_STR, "extcommunity str") + +DEFINE_MTYPE(BGPD, COMMUNITY_LIST, "community-list") +DEFINE_MTYPE(BGPD, COMMUNITY_LIST_NAME, "community-list name") +DEFINE_MTYPE(BGPD, COMMUNITY_LIST_ENTRY, "community-list entry") +DEFINE_MTYPE(BGPD, COMMUNITY_LIST_CONFIG, "community-list config") +DEFINE_MTYPE(BGPD, COMMUNITY_LIST_HANDLER, "community-list handler") + +DEFINE_MTYPE(BGPD, CLUSTER, "Cluster list") +DEFINE_MTYPE(BGPD, CLUSTER_VAL, "Cluster list val") + +DEFINE_MTYPE(BGPD, BGP_PROCESS_QUEUE, "BGP Process queue") +DEFINE_MTYPE(BGPD, BGP_CLEAR_NODE_QUEUE, "BGP node clear queue") + +DEFINE_MTYPE(BGPD, TRANSIT, "BGP transit attr") +DEFINE_MTYPE(BGPD, TRANSIT_VAL, "BGP transit val") + +DEFINE_MTYPE(BGPD, BGP_DEBUG_FILTER, "BGP debug filter") +DEFINE_MTYPE(BGPD, BGP_DEBUG_STR, "BGP debug filter string") + +DEFINE_MTYPE(BGPD, BGP_DISTANCE, "BGP distance") +DEFINE_MTYPE(BGPD, BGP_NEXTHOP_CACHE, "BGP nexthop") +DEFINE_MTYPE(BGPD, BGP_CONFED_LIST, "BGP confed list") +DEFINE_MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface") +DEFINE_MTYPE(BGPD, PEER_CONF_IF, "BGP peer config interface") +DEFINE_MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info") +DEFINE_MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array") +DEFINE_MTYPE(BGPD, BGP_REGEXP, "BGP regexp") +DEFINE_MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate") +DEFINE_MTYPE(BGPD, BGP_ADDR, "BGP own address") + +DEFINE_MTYPE(BGPD, BGP_REDIST, "BGP redistribution") +DEFINE_MTYPE(BGPD, BGP_FILTER_NAME, "BGP Filter Information") +DEFINE_MTYPE(BGPD, BGP_DUMP_STR, "BGP Dump String Information") +DEFINE_MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV") + + + +DEFINE_MGROUP(RIPD, "ripd") +DEFINE_MTYPE(RIPD, RIP, "RIP structure") +DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info") +DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface") +DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer") +DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list") +DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance") + + + +DEFINE_MGROUP(RIPNGD, "ripngd") +DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure") +DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info") +DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate") +DEFINE_MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer") +DEFINE_MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst") +DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data") + + + +DEFINE_MGROUP(OSPFD, "ospfd") +DEFINE_MTYPE(OSPFD, OSPF_TOP, "OSPF top") +DEFINE_MTYPE(OSPFD, OSPF_AREA, "OSPF area") +DEFINE_MTYPE(OSPFD, OSPF_AREA_RANGE, "OSPF area range") +DEFINE_MTYPE(OSPFD, OSPF_NETWORK, "OSPF network") +DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR_STATIC, "OSPF static nbr") +DEFINE_MTYPE(OSPFD, OSPF_IF, "OSPF interface") +DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR, "OSPF neighbor") +DEFINE_MTYPE(OSPFD, OSPF_ROUTE, "OSPF route") +DEFINE_MTYPE(OSPFD, OSPF_TMP, "OSPF tmp mem") +DEFINE_MTYPE(OSPFD, OSPF_LSA, "OSPF LSA") +DEFINE_MTYPE(OSPFD, OSPF_LSA_DATA, "OSPF LSA data") +DEFINE_MTYPE(OSPFD, OSPF_LSDB, "OSPF LSDB") +DEFINE_MTYPE(OSPFD, OSPF_PACKET, "OSPF packet") +DEFINE_MTYPE(OSPFD, OSPF_FIFO, "OSPF FIFO queue") +DEFINE_MTYPE(OSPFD, OSPF_VERTEX, "OSPF vertex") +DEFINE_MTYPE(OSPFD, OSPF_VERTEX_PARENT, "OSPF vertex parent") +DEFINE_MTYPE(OSPFD, OSPF_NEXTHOP, "OSPF nexthop") +DEFINE_MTYPE(OSPFD, OSPF_PATH, "OSPF path") +DEFINE_MTYPE(OSPFD, OSPF_VL_DATA, "OSPF VL data") +DEFINE_MTYPE(OSPFD, OSPF_CRYPT_KEY, "OSPF crypt key") +DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_INFO, "OSPF ext. info") +DEFINE_MTYPE(OSPFD, OSPF_DISTANCE, "OSPF distance") +DEFINE_MTYPE(OSPFD, OSPF_IF_INFO, "OSPF if info") +DEFINE_MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params") +DEFINE_MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message") +DEFINE_MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS parameters") +DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCE parameters") + + + +DEFINE_MGROUP(OSPF6D, "ospf6d") +DEFINE_MTYPE(OSPF6D, OSPF6_TOP, "OSPF6 top") +DEFINE_MTYPE(OSPF6D, OSPF6_AREA, "OSPF6 area") +DEFINE_MTYPE(OSPF6D, OSPF6_IF, "OSPF6 interface") +DEFINE_MTYPE(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor") +DEFINE_MTYPE(OSPF6D, OSPF6_ROUTE, "OSPF6 route") +DEFINE_MTYPE(OSPF6D, OSPF6_PREFIX, "OSPF6 prefix") +DEFINE_MTYPE(OSPF6D, OSPF6_MESSAGE, "OSPF6 message") +DEFINE_MTYPE(OSPF6D, OSPF6_LSA, "OSPF6 LSA") +DEFINE_MTYPE(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary") +DEFINE_MTYPE(OSPF6D, OSPF6_LSDB, "OSPF6 LSA database") +DEFINE_MTYPE(OSPF6D, OSPF6_VERTEX, "OSPF6 vertex") +DEFINE_MTYPE(OSPF6D, OSPF6_SPFTREE, "OSPF6 SPF tree") +DEFINE_MTYPE(OSPF6D, OSPF6_NEXTHOP, "OSPF6 nexthop") +DEFINE_MTYPE(OSPF6D, OSPF6_EXTERNAL_INFO,"OSPF6 ext. info") +DEFINE_MTYPE(OSPF6D, OSPF6_OTHER, "OSPF6 other") + + + +DEFINE_MGROUP(ISISD, "isisd") +DEFINE_MTYPE(ISISD, ISIS, "ISIS") +DEFINE_MTYPE(ISISD, ISIS_TMP, "ISIS TMP") +DEFINE_MTYPE(ISISD, ISIS_CIRCUIT, "ISIS circuit") +DEFINE_MTYPE(ISISD, ISIS_LSP, "ISIS LSP") +DEFINE_MTYPE(ISISD, ISIS_ADJACENCY, "ISIS adjacency") +DEFINE_MTYPE(ISISD, ISIS_AREA, "ISIS area") +DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address") +DEFINE_MTYPE(ISISD, ISIS_TLV, "ISIS TLV") +DEFINE_MTYPE(ISISD, ISIS_DYNHN, "ISIS dyn hostname") +DEFINE_MTYPE(ISISD, ISIS_SPFTREE, "ISIS SPFtree") +DEFINE_MTYPE(ISISD, ISIS_VERTEX, "ISIS vertex") +DEFINE_MTYPE(ISISD, ISIS_ROUTE_INFO, "ISIS route info") +DEFINE_MTYPE(ISISD, ISIS_NEXTHOP, "ISIS nexthop") +DEFINE_MTYPE(ISISD, ISIS_NEXTHOP6, "ISIS nexthop6") +DEFINE_MTYPE(ISISD, ISIS_DICT, "ISIS dictionary") +DEFINE_MTYPE(ISISD, ISIS_DICT_NODE, "ISIS dictionary node") +DEFINE_MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters") + + + +DEFINE_MGROUP(PIMD, "pimd") +DEFINE_MTYPE(PIMD, PIM_CHANNEL_OIL, "PIM SSM (S,G) channel OIL") +DEFINE_MTYPE(PIMD, PIM_INTERFACE, "PIM interface") +DEFINE_MTYPE(PIMD, PIM_IGMP_JOIN, "PIM interface IGMP static join") +DEFINE_MTYPE(PIMD, PIM_IGMP_SOCKET, "PIM interface IGMP socket") +DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP, "PIM interface IGMP group") +DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source") +DEFINE_MTYPE(PIMD, PIM_NEIGHBOR, "PIM interface neighbor") +DEFINE_MTYPE(PIMD, PIM_IFCHANNEL, "PIM interface (S,G) state") +DEFINE_MTYPE(PIMD, PIM_UPSTREAM, "PIM upstream (S,G) state") +DEFINE_MTYPE(PIMD, PIM_SSMPINGD, "PIM sspimgd socket") +DEFINE_MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route") +DEFINE_MTYPE(PIMD, PIM_BR, "PIM Bridge Router info") + + + +DEFINE_MGROUP(MVTYSH, "vtysh") +DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG, "Vtysh configuration") +DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line") diff --git a/lib/memtypes.pl b/lib/memtypes.pl new file mode 100755 index 0000000000..0955161b18 --- /dev/null +++ b/lib/memtypes.pl @@ -0,0 +1,6 @@ +#!/usr/bin/perl +while () { + $_ =~ s/DEFINE_MTYPE\([^,]+,\s*([^,]+)\s*,.*\)/DECLARE_MTYPE\($1\)/; + $_ =~ s/DEFINE_MGROUP\(([^,]+),.*\)/DECLARE_MGROUP\($1\)/; + print $_; +} 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/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/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_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 #include "linklist.h" @@ -57,6 +52,10 @@ #include "ospfd/ospf_ase.h" #include "ospfd/ospf_zebra.h" +DEFINE_MTYPE_STATIC(OSPFD, OSPF_OPAQUE_FUNCTAB, "OSPF opaque function table") +DEFINE_MTYPE_STATIC(OSPFD, OPAQUE_INFO_PER_TYPE, "OSPF opaque per-type info") +DEFINE_MTYPE_STATIC(OSPFD, OPAQUE_INFO_PER_ID, "OSPF opaque per-ID info") + /*------------------------------------------------------------------------* * Followings are initialize/terminate functions for Opaque-LSAs handling. *------------------------------------------------------------------------*/ diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index c118e46c55..e6e296f8af 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -63,6 +63,8 @@ #include "ospfd/ospf_te.h" #include "ospfd/ospf_vty.h" +DEFINE_MTYPE_STATIC(OSPFD, OSPF_MPLS_TE_LINKPARAMS, "OSPF MPLS-TE link parameters") + /* * Global variable to manage Opaque-LSA/MPLS-TE on this node. * Note that all parameter values are stored in network byte order. 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 #include "memory.h" +#include "vrf.h" +#include "memory_vty.h" #include "filter.h" #include "vty.h" #include "sigevent.h" diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 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/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/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/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 #include +#include #include struct thread_master *master; 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/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/main.c b/zebra/main.c index d8892f582a..25de5aea22 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -27,6 +27,7 @@ #include "thread.h" #include "filter.h" #include "memory.h" +#include "memory_vty.h" #include "prefix.h" #include "log.h" #include "plist.h" diff --git a/zebra/test_main.c b/zebra/test_main.c index 95c56bb046..7d0baf2599 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -25,6 +25,7 @@ #include "thread.h" #include "filter.h" #include "memory.h" +#include "memory_vty.h" #include "prefix.h" #include "log.h" #include "privs.h" From 4a1ab8e4050a141d3d7a80b5f8bb27dfd045dae8 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 29 May 2015 05:48:31 +0200 Subject: [PATCH 21/29] *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN Acked-by: Donald Sharp [CF: rebased for cmaster-next] Signed-off-by: David Lamparter Signed-off-by: Christian Franke --- bgpd/Makefile.am | 2 + bgpd/bgp_community.c | 1 + bgpd/bgp_fsm.c | 13 +- bgpd/bgp_memory.c | 110 +++++++++++++ bgpd/bgp_memory.h | 108 ++++++++++++ bgpd/bgp_nexthop.c | 11 +- bgpd/bgp_open.c | 9 +- bgpd/bgp_vty.c | 2 +- bgpd/bgpd.c | 13 +- bgpd/bgpd.h | 1 + isisd/Makefile.am | 2 + isisd/dict.c | 1 + isisd/isis_memory.c | 48 ++++++ isisd/isis_memory.h | 49 ++++++ isisd/isis_redist.c | 13 +- isisd/isisd.h | 1 + lib/.gitignore | 1 - lib/Makefile.am | 10 +- lib/bfd.c | 2 + lib/buffer.c | 3 +- lib/command.c | 4 + lib/command.h | 6 + lib/distribute.c | 4 + lib/filter.c | 4 + lib/hash.c | 4 + lib/hash.h | 5 + lib/if.c | 6 + lib/if.h | 4 + lib/if_rmap.c | 3 + lib/keychain.c | 3 + lib/linklist.c | 3 + lib/log.c | 2 + lib/memory.c | 3 + lib/memory.h | 5 +- lib/memtypes.c | 292 --------------------------------- lib/memtypes.pl | 6 - lib/nexthop.c | 2 + lib/ns.c | 3 + lib/plist.c | 9 +- lib/pqueue.c | 3 + lib/prefix.c | 2 + lib/privs.c | 3 + lib/routemap.c | 8 + lib/routemap.h | 4 + lib/sockunion.c | 2 + lib/stream.c | 4 + lib/table.c | 3 + lib/table.h | 3 + lib/thread.c | 4 + lib/vector.c | 3 + lib/vector.h | 3 + lib/vrf.c | 3 + lib/vty.c | 4 + lib/workqueue.c | 4 + lib/workqueue.h | 3 + lib/zclient.c | 2 + ospf6d/Makefile.am | 2 + ospf6d/ospf6_interface.c | 10 +- ospf6d/ospf6_memory.c | 44 +++++ ospf6d/ospf6_memory.h | 45 +++++ ospf6d/ospf6d.h | 2 + ospfd/Makefile.am | 4 +- ospfd/ospf_memory.c | 56 +++++++ ospfd/ospf_memory.h | 57 +++++++ ospfd/ospf_te.c | 2 - ospfd/ospfd.h | 2 + pimd/Makefile.am | 2 + pimd/pim_memory.c | 41 +++++ pimd/pim_memory.h | 42 +++++ pimd/pimd.h | 1 + ripd/Makefile.am | 2 + ripd/rip_memory.c | 35 ++++ ripd/rip_memory.h | 36 ++++ ripd/ripd.h | 2 + ripngd/Makefile.am | 2 + ripngd/ripng_memory.c | 35 ++++ ripngd/ripng_memory.h | 36 ++++ ripngd/ripngd.h | 2 + tests/heavy-wq.c | 14 +- tests/test-memory.c | 49 +++--- vtysh/vtysh.c | 14 +- vtysh/vtysh.h | 3 + vtysh/vtysh_config.c | 4 + zebra/Makefile.am | 5 +- zebra/connected.c | 1 + zebra/if_ioctl.c | 1 + zebra/if_ioctl_solaris.c | 1 + zebra/if_sysctl.c | 1 + zebra/interface.c | 1 + zebra/irdp_interface.c | 1 + zebra/irdp_main.c | 1 + zebra/irdp_packet.c | 1 + zebra/kernel_socket.c | 1 + zebra/main.c | 1 + zebra/redistribute.c | 1 + zebra/router-id.c | 1 + zebra/rt_netlink.c | 1 + zebra/rtadv.c | 1 + zebra/rtread_sysctl.c | 1 + zebra/test_main.c | 1 + zebra/zebra_memory.c | 37 +++++ zebra/zebra_memory.h | 40 +++++ zebra/zebra_ns.c | 4 + zebra/zebra_ptm_redistribute.c | 1 + zebra/zebra_rib.c | 11 +- zebra/zebra_rnh.c | 1 + zebra/zebra_routemap.c | 1 + zebra/zebra_static.c | 1 + zebra/zebra_vrf.c | 2 + zebra/zebra_vty.c | 2 + zebra/zserv.c | 1 + 111 files changed, 1100 insertions(+), 392 deletions(-) create mode 100644 bgpd/bgp_memory.c create mode 100644 bgpd/bgp_memory.h create mode 100644 isisd/isis_memory.c create mode 100644 isisd/isis_memory.h delete mode 100644 lib/memtypes.c delete mode 100755 lib/memtypes.pl create mode 100644 ospf6d/ospf6_memory.c create mode 100644 ospf6d/ospf6_memory.h create mode 100644 ospfd/ospf_memory.c create mode 100644 ospfd/ospf_memory.h create mode 100644 pimd/pim_memory.c create mode 100644 pimd/pim_memory.h create mode 100644 ripd/rip_memory.c create mode 100644 ripd/rip_memory.h create mode 100644 ripngd/ripng_memory.c create mode 100644 ripngd/ripng_memory.h create mode 100644 zebra/zebra_memory.c create mode 100644 zebra/zebra_memory.h 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_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..f63c9aa713 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; } 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_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_vty.c b/bgpd/bgp_vty.c index 56db697502..96dcf9044a 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10247,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)), 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/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_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 cc77785ced..5311b5c69c 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -24,6 +24,7 @@ #include "if.h" #include "linklist.h" #include "memory.h" +#include "isis_memory.h" #include "prefix.h" #include "routemap.h" #include "stream.h" @@ -94,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; } @@ -104,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 = { @@ -142,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)); @@ -242,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; @@ -280,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; 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 a25bae5aae..fe75137bca 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -14,6 +14,5 @@ gitversion.h.tmp .arch-ids *~ *.loT -memtypes.h route_types.h refix diff --git a/lib/Makefile.am b/lib/Makefile.am index 7a21511510..dbb80076c5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,10 +13,10 @@ libzebra_la_SOURCES = \ sockunion.c prefix.c thread.c if.c buffer.c table.c hash.c \ filter.c routemap.c distribute.c stream.c str.c log.c plist.c \ zclient.c sockopt.c smux.c agentx.c snmp.c md5.c if_rmap.c keychain.c privs.c \ - sigevent.c pqueue.c jhash.c memtypes.c workqueue.c nexthop.c json.c \ + sigevent.c pqueue.c jhash.c workqueue.c nexthop.c json.c \ ptm_lib.c csv.c bfd.c vrf.c systemd.c ns.c memory.c memory_vty.c -BUILT_SOURCES = memtypes.h route_types.h gitversion.h +BUILT_SOURCES = route_types.h gitversion.h libzebra_la_DEPENDENCIES = @LIB_REGEX@ @@ -28,7 +28,7 @@ pkginclude_HEADERS = \ memory.h network.h prefix.h routemap.h distribute.h sockunion.h \ str.h stream.h table.h thread.h vector.h version.h vty.h zebra.h \ plist.h zclient.h sockopt.h smux.h md5.h if_rmap.h keychain.h \ - privs.h sigevent.h pqueue.h jhash.h zassert.h memtypes.h \ + privs.h sigevent.h pqueue.h jhash.h zassert.h \ workqueue.h route_types.h libospf.h nexthop.h json.h \ ptm_lib.h csv.h bfd.h vrf.h ns.h systemd.h bitfield.h \ fifo.h memory_vty.h @@ -39,13 +39,9 @@ noinst_HEADERS = \ EXTRA_DIST = \ regex.c regex-gnu.h \ queue.h \ - memtypes.pl \ route_types.pl route_types.txt \ gitversion.pl -memtypes.h: $(srcdir)/memtypes.c $(srcdir)/memtypes.pl - @PERL@ $(srcdir)/memtypes.pl < $(srcdir)/memtypes.c > $@ - route_types.h: $(srcdir)/route_types.txt $(srcdir)/route_types.pl @PERL@ $(srcdir)/route_types.pl < $(srcdir)/route_types.txt > $@ 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 - +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 e67007ae2f..cfdb91a5b9 100644 --- a/lib/command.c +++ b/lib/command.c @@ -34,6 +34,10 @@ Boston, MA 02111-1307, USA. */ #include "workqueue.h" #include "vrf.h" +DEFINE_MTYPE( LIB, HOST, "Host config") +DEFINE_MTYPE( LIB, STRVEC, "String vector") +DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc") + /* Command vector which includes some level of command lists. Normally each daemon maintains each own cmdvec. */ vector cmdvec = NULL; diff --git a/lib/command.h b/lib/command.h index 0415834b09..9ee4f2db3d 100644 --- a/lib/command.h +++ b/lib/command.h @@ -26,6 +26,12 @@ #include "vector.h" #include "vty.h" #include "lib/route_types.h" +#include "memory.h" + +DECLARE_MTYPE(HOST) + +/* for test-commands.c */ +DECLARE_MTYPE(STRVEC) /* Host configuration variable */ struct host diff --git a/lib/distribute.c b/lib/distribute.c index 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/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/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/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 1ecc5b6df6..b9edb12fbd 100644 --- a/lib/log.c +++ b/lib/log.c @@ -35,6 +35,8 @@ #include #endif +DEFINE_MTYPE_STATIC(LIB, ZLOG, "Logging") + static int logfile_fd = -1; /* Used in signal handler. */ struct zlog *zlog_default = NULL; diff --git a/lib/memory.c b/lib/memory.c index 60008d4b5b..562b0f589a 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -29,6 +29,9 @@ static struct memgroup *mg_first = NULL; struct memgroup **mg_insert = &mg_first; +DEFINE_MGROUP(LIB, "libzebra") +DEFINE_MTYPE(LIB, TMP, "Temporary memory") + static inline void mt_count_alloc (struct memtype *mt, size_t size) { diff --git a/lib/memory.h b/lib/memory.h index e8243f1733..2680253d98 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -138,6 +138,9 @@ struct memgroup DEFINE_MTYPE_ATTR(group, name, static, desc) \ static struct memtype * const MTYPE_ ## name = &_mt_##name; +DECLARE_MGROUP(LIB) +DECLARE_MTYPE(TMP) + extern void *qmalloc (struct memtype *mt, size_t size) __attribute__ ((malloc, _ALLOC_SIZE(2), nonnull (1) _RET_NONNULL)); @@ -172,6 +175,4 @@ extern int qmem_walk (qmem_walk_fn *func, void *arg); extern void memory_oom (size_t size, const char *name); -#include "memtypes.h" - #endif /* _QUAGGA_MEMORY_H */ diff --git a/lib/memtypes.c b/lib/memtypes.c deleted file mode 100644 index 4fa64a8cb0..0000000000 --- a/lib/memtypes.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Memory type definitions. This file is parsed by memtypes.awk to extract - * MTYPE_ and memory_list_.. information in order to autogenerate - * memtypes.h. - * - * The script is sensitive to the format (though not whitespace), see - * the top of memtypes.awk for more details. - */ - -#include "zebra.h" -#include "memory.h" - -DEFINE_MGROUP(LIB, "libzebra") -DEFINE_MTYPE(LIB, TMP, "Temporary memory") -DEFINE_MTYPE(LIB, STRVEC, "String vector") -DEFINE_MTYPE(LIB, VECTOR, "Vector") -DEFINE_MTYPE(LIB, VECTOR_INDEX, "Vector index") -DEFINE_MTYPE(LIB, LINK_LIST, "Link List") -DEFINE_MTYPE(LIB, LINK_NODE, "Link Node") -DEFINE_MTYPE(LIB, THREAD, "Thread") -DEFINE_MTYPE(LIB, THREAD_MASTER, "Thread master") -DEFINE_MTYPE(LIB, THREAD_STATS, "Thread stats") -DEFINE_MTYPE(LIB, VTY, "VTY") -DEFINE_MTYPE(LIB, VTY_OUT_BUF, "VTY output buffer") -DEFINE_MTYPE(LIB, VTY_HIST, "VTY history") -DEFINE_MTYPE(LIB, IF, "Interface") -DEFINE_MTYPE(LIB, CONNECTED, "Connected") -DEFINE_MTYPE(LIB, NBR_CONNECTED, "Neighbor Connected") -DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label") -DEFINE_MTYPE(LIB, BUFFER, "Buffer") -DEFINE_MTYPE(LIB, BUFFER_DATA, "Buffer data") -DEFINE_MTYPE(LIB, STREAM, "Stream") -DEFINE_MTYPE(LIB, STREAM_DATA, "Stream data") -DEFINE_MTYPE(LIB, STREAM_FIFO, "Stream FIFO") -DEFINE_MTYPE(LIB, PREFIX, "Prefix") -DEFINE_MTYPE(LIB, PREFIX_IPV4, "Prefix IPv4") -DEFINE_MTYPE(LIB, PREFIX_IPV6, "Prefix IPv6") -DEFINE_MTYPE(LIB, HASH, "Hash") -DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket") -DEFINE_MTYPE(LIB, HASH_INDEX, "Hash Index") -DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table") -DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node") -DEFINE_MTYPE(LIB, DISTRIBUTE, "Distribute list") -DEFINE_MTYPE(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname") -DEFINE_MTYPE(LIB, DISTRIBUTE_NAME, "Dist-list name") -DEFINE_MTYPE(LIB, ACCESS_LIST, "Access List") -DEFINE_MTYPE(LIB, ACCESS_LIST_STR, "Access List Str") -DEFINE_MTYPE(LIB, ACCESS_FILTER, "Access Filter") -DEFINE_MTYPE(LIB, PREFIX_LIST, "Prefix List") -DEFINE_MTYPE(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") -DEFINE_MTYPE(LIB, PREFIX_LIST_STR, "Prefix List Str") -DEFINE_MTYPE(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table") -DEFINE_MTYPE(LIB, ROUTE_MAP, "Route map") -DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name") -DEFINE_MTYPE(LIB, ROUTE_MAP_INDEX, "Route map index") -DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule") -DEFINE_MTYPE(LIB, ROUTE_MAP_RULE_STR, "Route map rule str") -DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled") -DEFINE_MTYPE(LIB, ROUTE_MAP_DEP, "Route map dependency") -DEFINE_MTYPE(LIB, CMD_TOKENS, "Command desc") -DEFINE_MTYPE(LIB, KEY, "Key") -DEFINE_MTYPE(LIB, KEYCHAIN, "Key chain") -DEFINE_MTYPE(LIB, IF_RMAP, "Interface route map") -DEFINE_MTYPE(LIB, IF_RMAP_NAME, "I.f. route map name") -DEFINE_MTYPE(LIB, SOCKUNION, "Socket union") -DEFINE_MTYPE(LIB, PRIVS, "Privilege information") -DEFINE_MTYPE(LIB, ZLOG, "Logging") -DEFINE_MTYPE(LIB, ZCLIENT, "Zclient") -DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue") -DEFINE_MTYPE(LIB, WORK_QUEUE_ITEM, "Work queue item") -DEFINE_MTYPE(LIB, WORK_QUEUE_NAME, "Work queue name string") -DEFINE_MTYPE(LIB, PQUEUE, "Priority queue") -DEFINE_MTYPE(LIB, PQUEUE_DATA, "Priority queue data") -DEFINE_MTYPE(LIB, HOST, "host configuration") -DEFINE_MTYPE(LIB, BFD_INFO, "BFD info") -DEFINE_MTYPE(LIB, VRF, "VRF") -DEFINE_MTYPE(LIB, VRF_NAME, "VRF name") -DEFINE_MTYPE(LIB, VRF_BITMAP, "VRF bit-map") -DEFINE_MTYPE(LIB, IF_LINK_PARAMS, "Informational Link Parameters") -DEFINE_MTYPE(LIB, NS, "Logical-Router") -DEFINE_MTYPE(LIB, NS_NAME, "Logical-Router Name") -DEFINE_MTYPE(LIB, NS_BITMAP, "Logical-Router bit-map") - - - -DEFINE_MGROUP(ZEBRA, "zebra") -DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix") -DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space") -DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF") -DEFINE_MTYPE(ZEBRA, NEXTHOP, "Nexthop") -DEFINE_MTYPE(ZEBRA, RIB, "RIB") -DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue") -DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route") -DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination") -DEFINE_MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info") -DEFINE_MTYPE(ZEBRA, RNH, "Nexthop tracking object") -DEFINE_MTYPE(ZEBRA, NETLINK_NAME, "Netlink name") - - - -DEFINE_MGROUP(BGPD, "bgpd") -DEFINE_MTYPE(BGPD, BGP, "BGP instance") -DEFINE_MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details") -DEFINE_MTYPE(BGPD, BGP_PEER, "BGP peer") -DEFINE_MTYPE(BGPD, BGP_PEER_HOST, "BGP peer hostname") -DEFINE_MTYPE(BGPD, BGP_PEER_IFNAME, "BGP peer ifname") -DEFINE_MTYPE(BGPD, PEER_GROUP, "Peer group") -DEFINE_MTYPE(BGPD, PEER_GROUP_HOST, "BGP Peer group hostname") -DEFINE_MTYPE(BGPD, PEER_DESC, "Peer description") -DEFINE_MTYPE(BGPD, PEER_PASSWORD, "Peer password string") -DEFINE_MTYPE(BGPD, BGP_PEER_AF, "BGP peer af") -DEFINE_MTYPE(BGPD, BGP_UPDGRP, "BGP update group") -DEFINE_MTYPE(BGPD, BGP_UPD_SUBGRP, "BGP update subgroup") -DEFINE_MTYPE(BGPD, BGP_PACKET, "BGP packet") -DEFINE_MTYPE(BGPD, ATTR, "BGP attribute") -DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes") -DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath") -DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg") -DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data") -DEFINE_MTYPE(BGPD, AS_STR, "BGP aspath str") - -DEFINE_MTYPE(BGPD, BGP_TABLE, "BGP table") -DEFINE_MTYPE(BGPD, BGP_NODE, "BGP node") -DEFINE_MTYPE(BGPD, BGP_ROUTE, "BGP route") -DEFINE_MTYPE(BGPD, BGP_ROUTE_EXTRA, "BGP ancillary route info") -DEFINE_MTYPE(BGPD, BGP_CONN, "BGP connected") -DEFINE_MTYPE(BGPD, BGP_STATIC, "BGP static") -DEFINE_MTYPE(BGPD, BGP_ADVERTISE_ATTR, "BGP adv attr") -DEFINE_MTYPE(BGPD, BGP_ADVERTISE, "BGP adv") -DEFINE_MTYPE(BGPD, BGP_SYNCHRONISE, "BGP synchronise") -DEFINE_MTYPE(BGPD, BGP_ADJ_IN, "BGP adj in") -DEFINE_MTYPE(BGPD, BGP_ADJ_OUT, "BGP adj out") -DEFINE_MTYPE(BGPD, BGP_MPATH_INFO, "BGP multipath info") - -DEFINE_MTYPE(BGPD, AS_LIST, "BGP AS list") -DEFINE_MTYPE(BGPD, AS_FILTER, "BGP AS filter") -DEFINE_MTYPE(BGPD, AS_FILTER_STR, "BGP AS filter str") - -DEFINE_MTYPE(BGPD, COMMUNITY, "community") -DEFINE_MTYPE(BGPD, COMMUNITY_VAL, "community val") -DEFINE_MTYPE(BGPD, COMMUNITY_STR, "community str") - -DEFINE_MTYPE(BGPD, ECOMMUNITY, "extcommunity") -DEFINE_MTYPE(BGPD, ECOMMUNITY_VAL, "extcommunity val") -DEFINE_MTYPE(BGPD, ECOMMUNITY_STR, "extcommunity str") - -DEFINE_MTYPE(BGPD, COMMUNITY_LIST, "community-list") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_NAME, "community-list name") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_ENTRY, "community-list entry") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_CONFIG, "community-list config") -DEFINE_MTYPE(BGPD, COMMUNITY_LIST_HANDLER, "community-list handler") - -DEFINE_MTYPE(BGPD, CLUSTER, "Cluster list") -DEFINE_MTYPE(BGPD, CLUSTER_VAL, "Cluster list val") - -DEFINE_MTYPE(BGPD, BGP_PROCESS_QUEUE, "BGP Process queue") -DEFINE_MTYPE(BGPD, BGP_CLEAR_NODE_QUEUE, "BGP node clear queue") - -DEFINE_MTYPE(BGPD, TRANSIT, "BGP transit attr") -DEFINE_MTYPE(BGPD, TRANSIT_VAL, "BGP transit val") - -DEFINE_MTYPE(BGPD, BGP_DEBUG_FILTER, "BGP debug filter") -DEFINE_MTYPE(BGPD, BGP_DEBUG_STR, "BGP debug filter string") - -DEFINE_MTYPE(BGPD, BGP_DISTANCE, "BGP distance") -DEFINE_MTYPE(BGPD, BGP_NEXTHOP_CACHE, "BGP nexthop") -DEFINE_MTYPE(BGPD, BGP_CONFED_LIST, "BGP confed list") -DEFINE_MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface") -DEFINE_MTYPE(BGPD, PEER_CONF_IF, "BGP peer config interface") -DEFINE_MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info") -DEFINE_MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array") -DEFINE_MTYPE(BGPD, BGP_REGEXP, "BGP regexp") -DEFINE_MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate") -DEFINE_MTYPE(BGPD, BGP_ADDR, "BGP own address") - -DEFINE_MTYPE(BGPD, BGP_REDIST, "BGP redistribution") -DEFINE_MTYPE(BGPD, BGP_FILTER_NAME, "BGP Filter Information") -DEFINE_MTYPE(BGPD, BGP_DUMP_STR, "BGP Dump String Information") -DEFINE_MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV") - - - -DEFINE_MGROUP(RIPD, "ripd") -DEFINE_MTYPE(RIPD, RIP, "RIP structure") -DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info") -DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface") -DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer") -DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list") -DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance") - - - -DEFINE_MGROUP(RIPNGD, "ripngd") -DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure") -DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info") -DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate") -DEFINE_MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer") -DEFINE_MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst") -DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data") - - - -DEFINE_MGROUP(OSPFD, "ospfd") -DEFINE_MTYPE(OSPFD, OSPF_TOP, "OSPF top") -DEFINE_MTYPE(OSPFD, OSPF_AREA, "OSPF area") -DEFINE_MTYPE(OSPFD, OSPF_AREA_RANGE, "OSPF area range") -DEFINE_MTYPE(OSPFD, OSPF_NETWORK, "OSPF network") -DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR_STATIC, "OSPF static nbr") -DEFINE_MTYPE(OSPFD, OSPF_IF, "OSPF interface") -DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR, "OSPF neighbor") -DEFINE_MTYPE(OSPFD, OSPF_ROUTE, "OSPF route") -DEFINE_MTYPE(OSPFD, OSPF_TMP, "OSPF tmp mem") -DEFINE_MTYPE(OSPFD, OSPF_LSA, "OSPF LSA") -DEFINE_MTYPE(OSPFD, OSPF_LSA_DATA, "OSPF LSA data") -DEFINE_MTYPE(OSPFD, OSPF_LSDB, "OSPF LSDB") -DEFINE_MTYPE(OSPFD, OSPF_PACKET, "OSPF packet") -DEFINE_MTYPE(OSPFD, OSPF_FIFO, "OSPF FIFO queue") -DEFINE_MTYPE(OSPFD, OSPF_VERTEX, "OSPF vertex") -DEFINE_MTYPE(OSPFD, OSPF_VERTEX_PARENT, "OSPF vertex parent") -DEFINE_MTYPE(OSPFD, OSPF_NEXTHOP, "OSPF nexthop") -DEFINE_MTYPE(OSPFD, OSPF_PATH, "OSPF path") -DEFINE_MTYPE(OSPFD, OSPF_VL_DATA, "OSPF VL data") -DEFINE_MTYPE(OSPFD, OSPF_CRYPT_KEY, "OSPF crypt key") -DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_INFO, "OSPF ext. info") -DEFINE_MTYPE(OSPFD, OSPF_DISTANCE, "OSPF distance") -DEFINE_MTYPE(OSPFD, OSPF_IF_INFO, "OSPF if info") -DEFINE_MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params") -DEFINE_MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message") -DEFINE_MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS parameters") -DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCE parameters") - - - -DEFINE_MGROUP(OSPF6D, "ospf6d") -DEFINE_MTYPE(OSPF6D, OSPF6_TOP, "OSPF6 top") -DEFINE_MTYPE(OSPF6D, OSPF6_AREA, "OSPF6 area") -DEFINE_MTYPE(OSPF6D, OSPF6_IF, "OSPF6 interface") -DEFINE_MTYPE(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor") -DEFINE_MTYPE(OSPF6D, OSPF6_ROUTE, "OSPF6 route") -DEFINE_MTYPE(OSPF6D, OSPF6_PREFIX, "OSPF6 prefix") -DEFINE_MTYPE(OSPF6D, OSPF6_MESSAGE, "OSPF6 message") -DEFINE_MTYPE(OSPF6D, OSPF6_LSA, "OSPF6 LSA") -DEFINE_MTYPE(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary") -DEFINE_MTYPE(OSPF6D, OSPF6_LSDB, "OSPF6 LSA database") -DEFINE_MTYPE(OSPF6D, OSPF6_VERTEX, "OSPF6 vertex") -DEFINE_MTYPE(OSPF6D, OSPF6_SPFTREE, "OSPF6 SPF tree") -DEFINE_MTYPE(OSPF6D, OSPF6_NEXTHOP, "OSPF6 nexthop") -DEFINE_MTYPE(OSPF6D, OSPF6_EXTERNAL_INFO,"OSPF6 ext. info") -DEFINE_MTYPE(OSPF6D, OSPF6_OTHER, "OSPF6 other") - - - -DEFINE_MGROUP(ISISD, "isisd") -DEFINE_MTYPE(ISISD, ISIS, "ISIS") -DEFINE_MTYPE(ISISD, ISIS_TMP, "ISIS TMP") -DEFINE_MTYPE(ISISD, ISIS_CIRCUIT, "ISIS circuit") -DEFINE_MTYPE(ISISD, ISIS_LSP, "ISIS LSP") -DEFINE_MTYPE(ISISD, ISIS_ADJACENCY, "ISIS adjacency") -DEFINE_MTYPE(ISISD, ISIS_AREA, "ISIS area") -DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address") -DEFINE_MTYPE(ISISD, ISIS_TLV, "ISIS TLV") -DEFINE_MTYPE(ISISD, ISIS_DYNHN, "ISIS dyn hostname") -DEFINE_MTYPE(ISISD, ISIS_SPFTREE, "ISIS SPFtree") -DEFINE_MTYPE(ISISD, ISIS_VERTEX, "ISIS vertex") -DEFINE_MTYPE(ISISD, ISIS_ROUTE_INFO, "ISIS route info") -DEFINE_MTYPE(ISISD, ISIS_NEXTHOP, "ISIS nexthop") -DEFINE_MTYPE(ISISD, ISIS_NEXTHOP6, "ISIS nexthop6") -DEFINE_MTYPE(ISISD, ISIS_DICT, "ISIS dictionary") -DEFINE_MTYPE(ISISD, ISIS_DICT_NODE, "ISIS dictionary node") -DEFINE_MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS_TE parameters") - - - -DEFINE_MGROUP(PIMD, "pimd") -DEFINE_MTYPE(PIMD, PIM_CHANNEL_OIL, "PIM SSM (S,G) channel OIL") -DEFINE_MTYPE(PIMD, PIM_INTERFACE, "PIM interface") -DEFINE_MTYPE(PIMD, PIM_IGMP_JOIN, "PIM interface IGMP static join") -DEFINE_MTYPE(PIMD, PIM_IGMP_SOCKET, "PIM interface IGMP socket") -DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP, "PIM interface IGMP group") -DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source") -DEFINE_MTYPE(PIMD, PIM_NEIGHBOR, "PIM interface neighbor") -DEFINE_MTYPE(PIMD, PIM_IFCHANNEL, "PIM interface (S,G) state") -DEFINE_MTYPE(PIMD, PIM_UPSTREAM, "PIM upstream (S,G) state") -DEFINE_MTYPE(PIMD, PIM_SSMPINGD, "PIM sspimgd socket") -DEFINE_MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route") -DEFINE_MTYPE(PIMD, PIM_BR, "PIM Bridge Router info") - - - -DEFINE_MGROUP(MVTYSH, "vtysh") -DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG, "Vtysh configuration") -DEFINE_MTYPE(MVTYSH, VTYSH_CONFIG_LINE, "Vtysh configuration line") diff --git a/lib/memtypes.pl b/lib/memtypes.pl deleted file mode 100755 index 0955161b18..0000000000 --- a/lib/memtypes.pl +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/perl -while () { - $_ =~ s/DEFINE_MTYPE\([^,]+,\s*([^,]+)\s*,.*\)/DECLARE_MTYPE\($1\)/; - $_ =~ s/DEFINE_MGROUP\(([^,]+),.*\)/DECLARE_MGROUP\($1\)/; - print $_; -} diff --git a/lib/nexthop.c b/lib/nexthop.c index 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 573e9f725d..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 #include 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 831ae8e556..48b64a95c4 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -40,6 +40,10 @@ #include #include +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 772749403c..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 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/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_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/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_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_te.c b/ospfd/ospf_te.c index e6e296f8af..c118e46c55 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -63,8 +63,6 @@ #include "ospfd/ospf_te.h" #include "ospfd/ospf_vty.h" -DEFINE_MTYPE_STATIC(OSPFD, OSPF_MPLS_TE_LINKPARAMS, "OSPF MPLS-TE link parameters") - /* * Global variable to manage Opaque-LSA/MPLS-TE on this node. * Note that all parameter values are stored in network byte order. 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_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 +#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_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_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 #include +#include "ripng_memory.h" + /* RIPng version and port number. */ #define RIPNG_V1 1 #define RIPNG_PORT_DEFAULT 521 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/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 #include +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/vtysh/vtysh.c b/vtysh/vtysh.c index d01a1bcebb..10bdef8cc8 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -44,6 +44,8 @@ #include "ns.h" #include "vrf.h" +DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy") + /* Struct VTY. */ struct vty *vty; @@ -561,7 +563,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)) { @@ -641,25 +643,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); @@ -691,7 +693,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/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 af1aa08a6d..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" 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 25de5aea22..e67568140a 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -27,6 +27,7 @@ #include "thread.h" #include "filter.h" #include "memory.h" +#include "zebra_memory.h" #include "memory_vty.h" #include "prefix.h" #include "log.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/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 #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 #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 7d0baf2599..bbaf450282 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -25,6 +25,7 @@ #include "thread.h" #include "filter.h" #include "memory.h" +#include "zebra_memory.h" #include "memory_vty.h" #include "prefix.h" #include "log.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 45df9ac7dc..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. */ 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 #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 bf1d0a49c6..a7ee63d87f 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -22,6 +22,7 @@ #include #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" diff --git a/zebra/zserv.c b/zebra/zserv.c index b1bf5ed328..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" From 7a13c923afdec8765f8c33e93ae5eee7dfc4dc11 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 11 Feb 2016 17:12:44 +0100 Subject: [PATCH 22/29] lib: clean/restore memory debugging functions This adapts the dump-at-exit handler and removes the old leftover code. (Note the text in log_memtype_stderr was actually incorrect as the only caller in bgpd cleans up configuration before calling it, i.e. any remaining allocations are missing-cleanup bugs.) Signed-off-by: David Lamparter Acked-by: Vincent JARDIN Acked-by: Donald Sharp --- lib/memory.c | 35 +++++++++++++++++++ lib/memory.h | 1 + lib/memory_vty.c | 89 +----------------------------------------------- lib/memory_vty.h | 1 - 4 files changed, 37 insertions(+), 89 deletions(-) diff --git a/lib/memory.c b/lib/memory.c index 562b0f589a..38e424da7d 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -112,3 +112,38 @@ qmem_walk (qmem_walk_fn *func, void *arg) } return 0; } + +struct exit_dump_args +{ + const char *prefix; + int error; +}; + +static int +qmem_exit_walker (void *arg, struct memgroup *mg, struct memtype *mt) +{ + struct exit_dump_args *eda = arg; + + if (!mt) + { + fprintf (stderr, "%s: showing active allocations in memory group %s\n", + eda->prefix, mg->name); + } + else if (mt->n_alloc) + { + 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); + } + return 0; +} + +void +log_memstats_stderr (const char *prefix) +{ + 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 2680253d98..8f7d85a983 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -172,6 +172,7 @@ static inline size_t mtype_stats_alloc(struct memtype *mt) * 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 *); extern void memory_oom (size_t size, const char *name); diff --git a/lib/memory_vty.c b/lib/memory_vty.c index fa9f50a23a..e4cb295cf0 100644 --- a/lib/memory_vty.c +++ b/lib/memory_vty.c @@ -35,80 +35,6 @@ #include "vty.h" #include "command.h" -void -log_memstats_stderr (const char *prefix) -{ -#if 0 - 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); -#endif -} - -#if 0 -static void -show_separator(struct vty *vty) -{ - vty_out (vty, "-----------------------------\r\n"); -} - -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; -} -#endif - #ifdef HAVE_MALLINFO static int show_memory_mallinfo (struct vty *vty) @@ -174,23 +100,10 @@ DEFUN (show_memory, "Show running system information\n" "Memory statistics\n") { - int needsep = 0; - #ifdef HAVE_MALLINFO - needsep = show_memory_mallinfo (vty); + show_memory_mallinfo (vty); #endif /* HAVE_MALLINFO */ - (void) needsep; -#if 0 - struct mlist *ml; - for (ml = mlists; ml->list; ml++) - { - if (needsep) - show_separator (vty); - needsep = show_memory_vty (vty, ml->list); - } -#endif - qmem_walk(qmem_walker, vty); return CMD_SUCCESS; } diff --git a/lib/memory_vty.h b/lib/memory_vty.h index 7aab01ee5b..565a75aa98 100644 --- a/lib/memory_vty.h +++ b/lib/memory_vty.h @@ -24,7 +24,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "memory.h" extern void memory_init (void); -extern void log_memstats_stderr (const char *); /* Human friendly string for given byte count */ #define MTYPE_MEMSTR_LEN 20 From 802e2cdd3ad770f3e1f360437dcf910dc3e81c04 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 29 May 2015 05:16:41 +0200 Subject: [PATCH 23/29] build: goodbye, gawk Signed-off-by: David Lamparter Acked-by: Vincent JARDIN Acked-by: Donald Sharp --- INSTALL.quagga.txt | 1 - configure.ac | 6 ------ 2 files changed, 7 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/configure.ac b/configure.ac index 9cfb5d37d3..978aaf2c75 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} From af2d0efcac11723f9be52a3dae22dec31d157e24 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sun, 20 Mar 2016 10:09:18 +0100 Subject: [PATCH 24/29] lib: deregister memtypes on exit/unload This is useful for DSO modules in order to get support for unloading them dynamically. It also runs on exit, which doesn't matter much. At some future point, the code could be extended to check that allocation counts are 0 on unloading a module. Signed-off-by: David Lamparter --- lib/memory.h | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/memory.h b/lib/memory.h index 8f7d85a983..d287f229f7 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -30,7 +30,7 @@ #define SIZE_VAR ~0UL struct memtype { - struct memtype *next; + struct memtype *next, **ref; const char *name; size_t n_alloc; size_t size; @@ -38,7 +38,7 @@ struct memtype struct memgroup { - struct memgroup *next; + struct memgroup *next, **ref; struct memtype *types, **insert; const char *name; }; @@ -54,6 +54,7 @@ struct memgroup # 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 @@ -61,6 +62,7 @@ struct memgroup #ifdef __sun /* Solaris doesn't do constructor priorities due to linker restrictions */ # undef _CONSTRUCTOR +# undef _DESTRUCTOR #endif #ifndef _RET_NONNULL @@ -69,6 +71,9 @@ struct memgroup #ifndef _CONSTRUCTOR # define _CONSTRUCTOR(x) constructor #endif +#ifndef _DESTRUCTOR +# define _DESTRUCTOR(x) destructor +#endif #ifndef _ALLOC_SIZE # define _ALLOC_SIZE(x) #endif @@ -104,14 +109,21 @@ struct memgroup struct memgroup _mg_##mname \ __attribute__ ((section (".data.mgroups"))) = { \ .name = desc, \ - .types = NULL, .next = NULL, .insert = NULL, \ + .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; } + 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) \ @@ -122,15 +134,22 @@ struct memgroup attr struct memtype _mt_##mname \ __attribute__ ((section (".data.mtypes"))) = { \ .name = desc, \ - .next = NULL, .n_alloc = 0, .size = 0, \ + .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; } + _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) From 896af92e5b7f65de317b281acf469ccb9d713bb1 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 16 Aug 2016 17:48:44 +0200 Subject: [PATCH 25/29] vtysh: work around gcc bug #69981 The memtypes changes break gcc -O0 build (none of the other optimisation levels are affected, *any* of -Og, -Os, -O1, etc. make this go away). Unfortunately, the option supposed to control this doesn't actually work (-fno-keep-static-const; that not working is the actual gcc bug). The workaround is to avoid DECLARE_MTYPE statements when their paired DEFINE_MTYPE isn't linked in. Thankfully, that's only a problem in a single place in vtysh where bgp_memory.h gets chain-included. (vtysh.c -> bgp_vty.h -> bgpd.h -> bgp_memory.h) So, this just breaks the chain at bgp_vty.h. No other compiler (clang & icc tested) has exhibited this problem. Signed-off-by: David Lamparter --- bgpd/bgp_vty.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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>" From 4d41dd8ba27b7ea62b428ebb470c577261586aea Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 20 Sep 2016 07:57:41 -0400 Subject: [PATCH 26/29] bgpd: Revert --enable-bgp-standalone Reverts the --enable-bgp-standalone and makes it so that you need to use --enable-cumulus to get the cumulus behavior. Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 2 +- bgpd/bgp_network.c | 4 ++-- bgpd/bgp_packet.c | 4 ++-- configure.ac | 6 ------ 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index f63c9aa713..f775bd048f 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1330,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_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_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/configure.ac b/configure.ac index 978aaf2c75..937d7b8d0f 100755 --- a/configure.ac +++ b/configure.ac @@ -311,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])) @@ -364,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 From 52e17e99dfdf7e7e6ef83759a805fdb9a6d1a496 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 20 Sep 2016 03:11:02 -0400 Subject: [PATCH 27/29] ospfd: Do not print warning on new interface The new TE functions will always print out a warning that TE has not been configured on an interface. This should be a debug not a warn. Signed-off-by: Donald Sharp --- ospfd/ospf_te.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index c118e46c55..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; } From 51f8c3f2ea9f0ddb8f7d99960182ab1f0344859a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 21 Sep 2016 08:48:04 -0400 Subject: [PATCH 28/29] lib: Add #define str for JavaScript help string Signed-off-by: Donald Sharp --- lib/json.h | 2 ++ 1 file changed, 2 insertions(+) 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 */ From e3e29b328d161c6d129e479a9564ce216688da81 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Wed, 21 Sep 2016 09:51:30 -0400 Subject: [PATCH 29/29] bgpd: Additional Show Commands These commands were ported forward from these commits: f9b6c39 bgpd: Add back old forms of 'show ' for compatibility bf1ae6c bgpd: drop machineparse / random "show" improvements 651b402 bgpd: encap show commands 35c3686 bgpd: VPNv6 show commands 135ca15 bgpd: cleanup vty bgp_node_afi/safi utils This is the first drop of those commits. The files have changed too much and the diffs to extensive to try to do it in one piece. Break it up into smaller code chunks. Original Code: Signed-off-by: Lou Berger Forward Port: Signed-off-by: Donald Sharp --- bgpd/bgp_mplsvpn.c | 108 +++++++++++++++++++++++++++++++---- bgpd/bgp_route.c | 139 +++++++++++++++++++++++++++++++++++++++------ bgpd/bgp_vty.c | 33 +++++++++++ 3 files changed, 252 insertions(+), 28 deletions(-) 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_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 /, 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 /\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 /\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 96dcf9044a..012d1d25a2 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10740,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}", @@ -16011,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);