staticd: kill static_memory.h, use MTYPE_STATIC

This one needed a move of zebra_stable_node_cleanup() from static_vrf.c
to static_routes.c.  But it seems to actually make sense there.

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2021-03-22 19:41:54 +01:00
parent 30043e4ce2
commit 8392606ec1
7 changed files with 68 additions and 122 deletions

View File

@ -1,28 +0,0 @@
/*
* static memory code.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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
*/
#include <zebra.h>
#include <memory.h>
#include "staticd/static_memory.h"
DEFINE_MGROUP(STATIC, "staticd");
DEFINE_MTYPE(STATIC, STATIC_NEXTHOP, "Static Nexthop");

View File

@ -1,30 +0,0 @@
/*
* static memory code.
* Copyright (C) 2018 Cumulus Networks, Inc.
* Donald Sharp
*
* This program 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 of the License, or (at your option)
* any later version.
*
* This program 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 __STATIC_MEMORY_H__
#include "memory.h"
DECLARE_MGROUP(STATIC);
DECLARE_MTYPE(STATIC_ROUTE);
DECLARE_MTYPE(STATIC_NEXTHOP);
DECLARE_MTYPE(STATIC_PATH);
#endif

View File

@ -31,12 +31,71 @@
#include "static_vrf.h"
#include "static_routes.h"
#include "static_memory.h"
#include "static_zebra.h"
#include "static_debug.h"
DEFINE_MTYPE(STATIC, STATIC_ROUTE, "Static Route Info");
DEFINE_MTYPE(STATIC, STATIC_PATH, "Static Path");
DEFINE_MGROUP(STATIC, "staticd");
DEFINE_MTYPE_STATIC(STATIC, STATIC_ROUTE, "Static Route Info");
DEFINE_MTYPE_STATIC(STATIC, STATIC_PATH, "Static Path");
DEFINE_MTYPE_STATIC(STATIC, STATIC_NEXTHOP, "Static Nexthop");
void zebra_stable_node_cleanup(struct route_table *table,
struct route_node *node)
{
struct static_nexthop *nh;
struct static_path *pn;
struct static_route_info *si;
struct route_table *src_table;
struct route_node *src_node;
struct static_path *src_pn;
struct static_route_info *src_si;
si = node->info;
if (si) {
frr_each_safe(static_path_list, &si->path_list, pn) {
frr_each_safe(static_nexthop_list, &pn->nexthop_list,
nh) {
static_nexthop_list_del(&pn->nexthop_list, nh);
XFREE(MTYPE_STATIC_NEXTHOP, nh);
}
static_path_list_del(&si->path_list, pn);
XFREE(MTYPE_STATIC_PATH, pn);
}
/* clean up for dst table */
src_table = srcdest_srcnode_table(node);
if (src_table) {
/* This means the route_node is part of the top
* hierarchy and refers to a destination prefix.
*/
for (src_node = route_top(src_table); src_node;
src_node = route_next(src_node)) {
src_si = src_node->info;
frr_each_safe(static_path_list,
&src_si->path_list, src_pn) {
frr_each_safe(static_nexthop_list,
&src_pn->nexthop_list,
nh) {
static_nexthop_list_del(
&src_pn->nexthop_list,
nh);
XFREE(MTYPE_STATIC_NEXTHOP, nh);
}
static_path_list_del(&src_si->path_list,
src_pn);
XFREE(MTYPE_STATIC_PATH, src_pn);
}
XFREE(MTYPE_STATIC_ROUTE, src_node->info);
}
}
XFREE(MTYPE_STATIC_ROUTE, node->info);
}
}
/* Install static path into rib. */
void static_install_path(struct route_node *rn, struct static_path *pn,

View File

@ -22,6 +22,9 @@
#include "lib/mpls.h"
#include "table.h"
#include "memory.h"
DECLARE_MGROUP(STATIC);
/* Static route label information */
struct static_nh_label {
@ -198,6 +201,9 @@ extern bool static_add_nexthop_validate(const char *nh_vrf_name,
extern struct stable_info *static_get_stable_info(struct route_node *rn);
extern void static_route_info_init(struct static_route_info *si);
extern void zebra_stable_node_cleanup(struct route_table *table,
struct route_node *node);
/*
* Max string return via API static_get_nh_str in size_t
*/

View File

@ -24,7 +24,6 @@
#include "table.h"
#include "srcdest_table.h"
#include "static_memory.h"
#include "static_vrf.h"
#include "static_routes.h"
#include "static_zebra.h"
@ -32,63 +31,6 @@
DEFINE_MTYPE_STATIC(STATIC, STATIC_RTABLE_INFO, "Static Route Table Info");
static void zebra_stable_node_cleanup(struct route_table *table,
struct route_node *node)
{
struct static_nexthop *nh;
struct static_path *pn;
struct static_route_info *si;
struct route_table *src_table;
struct route_node *src_node;
struct static_path *src_pn;
struct static_route_info *src_si;
si = node->info;
if (si) {
frr_each_safe(static_path_list, &si->path_list, pn) {
frr_each_safe(static_nexthop_list, &pn->nexthop_list,
nh) {
static_nexthop_list_del(&pn->nexthop_list, nh);
XFREE(MTYPE_STATIC_NEXTHOP, nh);
}
static_path_list_del(&si->path_list, pn);
XFREE(MTYPE_STATIC_PATH, pn);
}
/* clean up for dst table */
src_table = srcdest_srcnode_table(node);
if (src_table) {
/* This means the route_node is part of the top
* hierarchy and refers to a destination prefix.
*/
for (src_node = route_top(src_table); src_node;
src_node = route_next(src_node)) {
src_si = src_node->info;
frr_each_safe(static_path_list,
&src_si->path_list, src_pn) {
frr_each_safe(static_nexthop_list,
&src_pn->nexthop_list,
nh) {
static_nexthop_list_del(
&src_pn->nexthop_list,
nh);
XFREE(MTYPE_STATIC_NEXTHOP, nh);
}
static_path_list_del(&src_si->path_list,
src_pn);
XFREE(MTYPE_STATIC_PATH, src_pn);
}
XFREE(MTYPE_STATIC_ROUTE, src_node->info);
}
}
XFREE(MTYPE_STATIC_ROUTE, node->info);
}
}
static struct static_vrf *static_vrf_alloc(void)
{
struct route_table *table;

View File

@ -33,7 +33,6 @@
#include "northbound_cli.h"
#include "static_vrf.h"
#include "static_memory.h"
#include "static_vty.h"
#include "static_routes.h"
#include "static_debug.h"

View File

@ -13,7 +13,6 @@ endif
staticd_libstatic_a_SOURCES = \
staticd/static_debug.c \
staticd/static_memory.c \
staticd/static_nht.c \
staticd/static_routes.c \
staticd/static_zebra.c \
@ -25,7 +24,6 @@ staticd_libstatic_a_SOURCES = \
noinst_HEADERS += \
staticd/static_debug.h \
staticd/static_memory.h \
staticd/static_nht.h \
staticd/static_zebra.h \
staticd/static_routes.h \