zebra: kill zebra_memory.h, use MTYPE_STATIC

This one also needed a bit of shuffling around, but MTYPE_RE is the only
one left used across file boundaries now.

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2021-03-22 20:02:17 +01:00
parent 8392606ec1
commit 224ccf29d9
46 changed files with 40 additions and 139 deletions

View File

@ -29,7 +29,6 @@
#include "table.h"
#include "log.h"
#include "memory.h"
#include "zebra_memory.h"
#include "vty.h"
#include "zebra/debug.h"

View File

@ -29,7 +29,6 @@
#include "ioctl.h"
#include "connected.h"
#include "memory.h"
#include "zebra_memory.h"
#include "log.h"
#include "vrf.h"
#include "vty.h"

View File

@ -44,7 +44,6 @@
#include "connected.h"
#include "table.h"
#include "memory.h"
#include "zebra_memory.h"
#include "rib.h"
#include "thread.h"
#include "privs.h"

View File

@ -28,7 +28,6 @@
#include "prefix.h"
#include "connected.h"
#include "memory.h"
#include "zebra_memory.h"
#include "ioctl.h"
#include "log.h"
#include "interface.h"

View File

@ -28,7 +28,6 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
#include "zebra_memory.h"
#include "ioctl.h"
#include "connected.h"
#include "log.h"

View File

@ -34,7 +34,6 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
#include "zebra_memory.h"
#include "stream.h"
#include "ioctl.h"
#include "connected.h"

View File

@ -42,7 +42,6 @@
#include "prefix.h"
#include "command.h"
#include "memory.h"
#include "zebra_memory.h"
#include "stream.h"
#include "ioctl.h"
#include "connected.h"

View File

@ -54,7 +54,6 @@
#include "zclient.h"
#include "lib_errors.h"
#include "zebra_memory.h"
#include "zebra/interface.h"
#include "zebra/rtadv.h"
#include "zebra/rib.h"

View File

@ -29,7 +29,6 @@
#include "connected.h"
#include "table.h"
#include "memory.h"
#include "zebra_memory.h"
#include "rib.h"
#include "thread.h"
#include "privs.h"

View File

@ -32,7 +32,6 @@
#include "sockunion.h"
#include "connected.h"
#include "memory.h"
#include "zebra_memory.h"
#include "ioctl.h"
#include "log.h"
#include "table.h"

View File

@ -26,7 +26,6 @@
#include "thread.h"
#include "filter.h"
#include "memory.h"
#include "zebra_memory.h"
#include "prefix.h"
#include "log.h"
#include "plist.h"

View File

@ -41,7 +41,6 @@
#include "zebra/debug.h"
#include "zebra/router-id.h"
#include "zebra/zapi_msg.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_vxlan.h"
#include "zebra/zebra_errors.h"

View File

@ -23,6 +23,7 @@
#define _ZEBRA_RIB_H
#include "zebra.h"
#include "memory.h"
#include "hook.h"
#include "typesafe.h"
#include "linklist.h"
@ -41,6 +42,10 @@
extern "C" {
#endif
DECLARE_MGROUP(ZEBRA);
DECLARE_MTYPE(RE);
enum rnh_type { RNH_NEXTHOP_TYPE, RNH_IMPORT_CHECK_TYPE };
PREDECL_LIST(rnh_list);

View File

@ -29,7 +29,6 @@
#include "stream.h"
#include "command.h"
#include "memory.h"
#include "zebra_memory.h"
#include "ioctl.h"
#include "connected.h"
#include "network.h"

View File

@ -41,7 +41,6 @@
#include "connected.h"
#include "table.h"
#include "memory.h"
#include "zebra_memory.h"
#include "rib.h"
#include "thread.h"
#include "privs.h"

View File

@ -23,7 +23,6 @@
#include <zebra.h>
#include "memory.h"
#include "zebra_memory.h"
#include "sockopt.h"
#include "thread.h"
#include "if.h"

View File

@ -24,7 +24,6 @@
#if !defined(GNU_LINUX)
#include "memory.h"
#include "zebra_memory.h"
#include "log.h"
#include "vrf.h"

View File

@ -88,7 +88,6 @@ zebra_zebra_SOURCES = \
zebra/zebra_evpn_neigh.c \
zebra/zebra_mlag.c \
zebra/zebra_mlag_vty.c \
zebra/zebra_memory.c \
zebra/zebra_mpls.c \
zebra/zebra_mpls_netlink.c \
zebra/zebra_mpls_openbsd.c \
@ -158,7 +157,6 @@ noinst_HEADERS += \
zebra/zebra_evpn_vxlan.h \
zebra/zebra_fpm_private.h \
zebra/zebra_l2.h \
zebra/zebra_memory.h \
zebra/zebra_mlag.h \
zebra/zebra_mlag_vty.h \
zebra/zebra_mpls.h \

View File

@ -38,7 +38,6 @@
#include "zebra/zebra_router.h"
#include "zebra/rib.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/router-id.h"
@ -62,6 +61,8 @@
#include "zebra/zebra_opaque.h"
#include "zebra/zebra_srte.h"
DEFINE_MTYPE_STATIC(ZEBRA, OPAQUE, "Opaque Data");
static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg);
/* Encoding helpers -------------------------------------------------------- */
@ -2076,6 +2077,11 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
}
}
void zapi_opaque_free(struct opaque *opaque)
{
XFREE(MTYPE_OPAQUE, opaque);
}
static void zread_route_del(ZAPI_HANDLER_ARGS)
{
struct stream *s;

View File

@ -111,6 +111,8 @@ extern int zsend_client_close_notify(struct zserv *client,
int zsend_nhg_notify(uint16_t type, uint16_t instance, uint32_t session_id,
uint32_t id, enum zapi_nhg_notify_owner note);
extern void zapi_opaque_free(struct opaque *opaque);
#ifdef __cplusplus
}
#endif

View File

@ -28,7 +28,6 @@
#include "lib/memory.h"
#include "lib/queue.h"
#include "lib/zebra.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_dplane.h"
#include "zebra/zebra_vxlan_private.h"

View File

@ -44,7 +44,6 @@
#include "zebra/rt_netlink.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_l2.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"

View File

@ -34,7 +34,6 @@
#include "zebra/zserv.h"
#include "zebra/debug.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_evpn.h"

View File

@ -41,7 +41,6 @@
#include "zebra/if_netlink.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_l2.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"

View File

@ -34,7 +34,6 @@
#include "zebra/debug.h"
#include "zebra/zebra_router.h"
#include "zebra/rt.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_evpn.h"

View File

@ -37,7 +37,6 @@
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_memory.h"
#include "fpm/fpm.h"
#include "zebra_fpm_private.h"

View File

@ -38,7 +38,6 @@
#include "zebra/zserv.h"
#include "zebra/debug.h"
#include "zebra/interface.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_vrf.h"
#include "zebra/rt_netlink.h"
#include "zebra/interface.h"

View File

@ -1,33 +0,0 @@
/* 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "zebra_memory.h"
DEFINE_MGROUP(ZEBRA, "zebra");
DEFINE_MTYPE(ZEBRA, RE, "Route Entry");
DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination");
DEFINE_MTYPE(ZEBRA, ZVLAN, "VLAN");
DEFINE_MTYPE(ZEBRA, ZVLAN_BITMAP, "VLAN bitmap");
DEFINE_MTYPE(ZEBRA, OPAQUE, "Opaque Data");

View File

@ -1,41 +0,0 @@
/* 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 this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QUAGGA_ZEBRA_MEMORY_H
#define _QUAGGA_ZEBRA_MEMORY_H
#include "memory.h"
#ifdef __cplusplus
extern "C" {
#endif
DECLARE_MGROUP(ZEBRA);
DECLARE_MTYPE(ZEBRA_NS);
DECLARE_MTYPE(RE);
DECLARE_MTYPE(RIB_DEST);
DECLARE_MTYPE(OPAQUE);
#ifdef __cplusplus
}
#endif
#endif /* _QUAGGA_ZEBRA_MEMORY_H */

View File

@ -29,7 +29,6 @@
#include "zebra/zebra_mlag.h"
#include "zebra/zebra_mlag_vty.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_memory.h"
#include "zebra/zapi_msg.h"
#include "zebra/debug.h"

View File

@ -44,7 +44,6 @@
#include "zebra/zebra_router.h"
#include "zebra/redistribute.h"
#include "zebra/debug.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_srte.h"

View File

@ -37,7 +37,6 @@
#include "lib_errors.h"
#include "zebra_router.h"
#include "zebra_memory.h"
#endif /* defined(HAVE_NETLINK) */
#include "zebra_netns_notify.h"

View File

@ -36,7 +36,6 @@
#include "zebra/zebra_nhg_private.h"
#include "zebra/zebra_rnh.h"
#include "zebra/zebra_routemap.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_srte.h"
#include "zebra/zserv.h"
#include "zebra/rt.h"

View File

@ -28,7 +28,6 @@
#include "zebra_ns.h"
#include "zebra_vrf.h"
#include "zebra_memory.h"
#include "rt.h"
#include "zebra_vxlan.h"
#include "debug.h"
@ -41,7 +40,7 @@
extern struct zebra_privs_t zserv_privs;
DEFINE_MTYPE(ZEBRA, ZEBRA_NS, "Zebra Name Space");
DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_NS, "Zebra Name Space");
static struct zebra_ns *dzns;

View File

@ -24,7 +24,6 @@
#include "lib/stream.h"
#include "zebra/debug.h"
#include "zebra/zserv.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_opaque.h"
/* Mem type */

View File

@ -30,7 +30,6 @@
#include "zebra/zebra_pbr.h"
#include "zebra/rt.h"
#include "zebra/zapi_msg.h"
#include "zebra/zebra_memory.h"
#include "zebra/zserv.h"
#include "zebra/debug.h"

View File

@ -1167,8 +1167,6 @@ void zebra_ptm_if_write(struct vty *vty, struct zebra_if *zebra_ifp)
#else /* HAVE_BFDD */
#include "zebra/zebra_memory.h"
/*
* Data structures.
*/

View File

@ -26,7 +26,6 @@
#include "zebra/zapi_msg.h"
#include "zebra/zebra_ptm.h"
#include "zebra/zebra_ptm_redistribute.h"
#include "zebra/zebra_memory.h"
static int zsend_interface_bfd_update(int cmd, struct zserv *client,
struct interface *ifp, struct prefix *dp,

View File

@ -49,7 +49,6 @@
#include "zebra/rt.h"
#include "zebra/zapi_msg.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_rnh.h"
#include "zebra/zebra_routemap.h"
@ -58,6 +57,10 @@
#include "zebra/zapi_msg.h"
#include "zebra/zebra_dplane.h"
DEFINE_MGROUP(ZEBRA, "zebra");
DEFINE_MTYPE(ZEBRA, RE, "Route Entry");
DEFINE_MTYPE_STATIC(ZEBRA, RIB_DEST, "RIB destination");
DEFINE_MTYPE_STATIC(ZEBRA, RIB_UPDATE_CTX, "Rib update context object");
/*
@ -800,6 +803,23 @@ int rib_gc_dest(struct route_node *rn)
return 1;
}
void zebra_rtable_node_cleanup(struct route_table *table,
struct route_node *node)
{
struct route_entry *re, *next;
RNODE_FOREACH_RE_SAFE (node, re, next) {
rib_unlink(node, re);
}
if (node->info) {
rib_dest_t *dest = node->info;
rnh_list_fini(&dest->nht);
XFREE(MTYPE_RIB_DEST, node->info);
}
}
static void rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn,
struct route_entry *new)
{
@ -2698,7 +2718,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
nexthops_free(re->fib_ng.nexthop);
XFREE(MTYPE_OPAQUE, re->opaque);
zapi_opaque_free(re->opaque);
XFREE(MTYPE_RE, re);
}

View File

@ -48,7 +48,6 @@
#include "zebra/zebra_routemap.h"
#include "zebra/zebra_srte.h"
#include "zebra/interface.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_errors.h"
DEFINE_MTYPE_STATIC(ZEBRA, RNH, "Nexthop tracking object");

View File

@ -21,7 +21,6 @@
#include <zebra.h>
#include "memory.h"
#include "zebra_memory.h"
#include "prefix.h"
#include "rib.h"
#include "vty.h"

View File

@ -25,7 +25,6 @@
#include "lib/frratomic.h"
#include "zebra_router.h"
#include "zebra_memory.h"
#include "zebra_pbr.h"
#include "zebra_vxlan.h"
#include "zebra_mlag.h"
@ -33,6 +32,7 @@
#include "debug.h"
DEFINE_MTYPE_STATIC(ZEBRA, RIB_TABLE_INFO, "RIB table info");
DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_RT_TABLE, "Zebra VRF table");
struct zebra_router zrouter = {
.multipath_num = MULTIPATH_NUM,
@ -121,7 +121,7 @@ struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
if (zrt)
return zrt->table;
zrt = XCALLOC(MTYPE_ZEBRA_NS, sizeof(*zrt));
zrt = XCALLOC(MTYPE_ZEBRA_RT_TABLE, sizeof(*zrt));
zrt->tableid = tableid;
zrt->afi = afi;
zrt->safi = safi;
@ -185,7 +185,7 @@ static void zebra_router_free_table(struct zebra_router_table *zrt)
RB_REMOVE(zebra_router_table_head, &zrouter.tables, zrt);
XFREE(MTYPE_RIB_TABLE_INFO, table_info);
XFREE(MTYPE_ZEBRA_NS, zrt);
XFREE(MTYPE_ZEBRA_RT_TABLE, zrt);
}
void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,

View File

@ -24,7 +24,6 @@
#include "lib/lib_errors.h"
#include "zebra/zebra_srte.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_rnh.h"
#include "zebra/zapi_msg.h"

View File

@ -36,7 +36,6 @@
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_rnh.h"
#include "zebra/router-id.h"
#include "zebra/zebra_memory.h"
#include "zebra/interface.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_vxlan.h"
@ -413,23 +412,6 @@ done:
return table;
}
void zebra_rtable_node_cleanup(struct route_table *table,
struct route_node *node)
{
struct route_entry *re, *next;
RNODE_FOREACH_RE_SAFE (node, re, next) {
rib_unlink(node, re);
}
if (node->info) {
rib_dest_t *dest = node->info;
rnh_list_fini(&dest->nht);
XFREE(MTYPE_RIB_DEST, node->info);
}
}
static void zebra_rnhtable_node_cleanup(struct route_table *table,
struct route_node *node)
{

View File

@ -21,7 +21,6 @@
#include <zebra.h>
#include "memory.h"
#include "zebra_memory.h"
#include "if.h"
#include "prefix.h"
#include "command.h"

View File

@ -46,7 +46,6 @@
#include "zebra/rt_netlink.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_l2.h"
#include "zebra/zebra_memory.h"
#include "zebra/zebra_ns.h"
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_vxlan.h"