summaryrefslogtreecommitdiffstats
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/cmds.c30
-rw-r--r--nest/cmds.h1
-rw-r--r--nest/config.Y5
-rw-r--r--nest/proto.c2
-rw-r--r--nest/rt-attr.c3
-rw-r--r--nest/rt-table.c3
6 files changed, 40 insertions, 4 deletions
diff --git a/nest/cmds.c b/nest/cmds.c
index 16fbba6..8ac3209 100644
--- a/nest/cmds.c
+++ b/nest/cmds.c
@@ -11,6 +11,7 @@
#include "conf/conf.h"
#include "nest/cmds.h"
#include "lib/string.h"
+#include "lib/resource.h"
void
cmd_show_status(void)
@@ -47,3 +48,32 @@ cmd_show_symbols(struct symbol *sym)
cli_msg(0, "");
}
}
+
+static void
+print_size(char *dsc, size_t val)
+{
+ char *px = " kMG";
+ int i = 0;
+ while ((val >= 10000) && (i < 3))
+ {
+ val = (val + 512) / 1024;
+ i++;
+ }
+
+ cli_msg(-1018, "%-17s %4u %cB", dsc, (unsigned) val, px[i]);
+}
+
+extern pool *rt_table_pool;
+extern pool *rta_pool;
+extern pool *proto_pool;
+
+void
+cmd_show_memory(void)
+{
+ cli_msg(-1018, "BIRD memory usage");
+ print_size("Routing tables:", rmemsize(rt_table_pool));
+ print_size("Route attributes:", rmemsize(rta_pool));
+ print_size("Protocols:", rmemsize(proto_pool));
+ print_size("Total:", rmemsize(&root_pool));
+ cli_msg(0, "");
+}
diff --git a/nest/cmds.h b/nest/cmds.h
index ae1c9e2..3b86a92 100644
--- a/nest/cmds.h
+++ b/nest/cmds.h
@@ -8,3 +8,4 @@
void cmd_show_status(void);
void cmd_show_symbols(struct symbol *sym);
+void cmd_show_memory(void);
diff --git a/nest/config.Y b/nest/config.Y
index 7bb0525..a8e6bf8 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -45,7 +45,7 @@ CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, TABLE, STATES, ROUTES, FILT
CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES)
CF_KEYWORDS(PRIMARY, STATS, COUNT, FOR, COMMANDS, PREEXPORT, GENERATE)
CF_KEYWORDS(LISTEN, BGP, V6ONLY, ADDRESS, PORT, PASSWORDS, DESCRIPTION)
-CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT)
+CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY)
CF_ENUM(T_ENUM_RTS, RTS_, DUMMY, STATIC, INHERIT, DEVICE, STATIC_DEVICE, REDIRECT,
RIP, OSPF, OSPF_IA, OSPF_EXT1, OSPF_EXT2, BGP, PIPE)
@@ -324,6 +324,9 @@ CF_CLI_HELP(SHOW, ..., [[Show status information]])
CF_CLI(SHOW STATUS,,, [[Show router status]])
{ cmd_show_status(); } ;
+CF_CLI(SHOW MEMORY,,, [[Show memory usage]])
+{ cmd_show_memory(); } ;
+
CF_CLI(SHOW PROTOCOLS, proto_patt2, [<protocol> | \"<pattern>\"], [[Show routing protocols]])
{ proto_apply_cmd($3, proto_cmd_show, 0, 0); } ;
diff --git a/nest/proto.c b/nest/proto.c
index 46147a4..c9e2f5c 100644
--- a/nest/proto.c
+++ b/nest/proto.c
@@ -20,7 +20,7 @@
#include "nest/cli.h"
#include "filter/filter.h"
-static pool *proto_pool;
+pool *proto_pool;
static list protocol_list;
static list proto_list;
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index b553475..abd49c7 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -54,8 +54,9 @@
#include "lib/resource.h"
#include "lib/string.h"
+pool *rta_pool;
+
static slab *rta_slab;
-static pool *rta_pool;
struct protocol *attr_class_to_protocol[EAP_MAX];
diff --git a/nest/rt-table.c b/nest/rt-table.c
index 8736574..8cca42a 100644
--- a/nest/rt-table.c
+++ b/nest/rt-table.c
@@ -43,10 +43,11 @@
#include "lib/string.h"
#include "lib/alloca.h"
+pool *rt_table_pool;
+
static slab *rte_slab;
static linpool *rte_update_pool;
-static pool *rt_table_pool;
static list routing_tables;
static void rt_format_via(rte *e, byte *via);