summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--staticd/static_memory.c28
-rw-r--r--staticd/static_memory.h30
-rw-r--r--staticd/static_routes.c65
-rw-r--r--staticd/static_routes.h6
-rw-r--r--staticd/static_vrf.c58
-rw-r--r--staticd/static_vty.c1
-rw-r--r--staticd/subdir.am2
7 files changed, 68 insertions, 122 deletions
diff --git a/staticd/static_memory.c b/staticd/static_memory.c
deleted file mode 100644
index 9d8d7643e..000000000
--- a/staticd/static_memory.c
+++ /dev/null
@@ -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");
diff --git a/staticd/static_memory.h b/staticd/static_memory.h
deleted file mode 100644
index 5348129ab..000000000
--- a/staticd/static_memory.h
+++ /dev/null
@@ -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
diff --git a/staticd/static_routes.c b/staticd/static_routes.c
index 9f7e19660..739c08b09 100644
--- a/staticd/static_routes.c
+++ b/staticd/static_routes.c
@@ -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,
diff --git a/staticd/static_routes.h b/staticd/static_routes.h
index 0fbf0674d..f64a40329 100644
--- a/staticd/static_routes.h
+++ b/staticd/static_routes.h
@@ -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
*/
diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c
index 2133093bb..ba1367b87 100644
--- a/staticd/static_vrf.c
+++ b/staticd/static_vrf.c
@@ -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;
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index dd03f8377..33a2728cd 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -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"
diff --git a/staticd/subdir.am b/staticd/subdir.am
index 9c630e8f5..a0ae2569c 100644
--- a/staticd/subdir.am
+++ b/staticd/subdir.am
@@ -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 \