summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conntrackd.83
-rw-r--r--include/conntrackd.h1
-rw-r--r--include/queue.h2
-rw-r--r--src/main.c6
-rw-r--r--src/queue.c24
-rw-r--r--src/sync-mode.c3
6 files changed, 37 insertions, 2 deletions
diff --git a/conntrackd.8 b/conntrackd.8
index 61a3e0e..f741bc9 100644
--- a/conntrackd.8
+++ b/conntrackd.8
@@ -44,12 +44,13 @@ option will not flush your internal and external cache).
.BI "-k "
Kill the daemon
.TP
-.BI "-s " "[|network|cache|runtime|link|rsqueue|process]"
+.BI "-s " "[|network|cache|runtime|link|rsqueue|process|queue]"
Dump statistics. If no parameter is passed, it displays the general statistics.
If "network" is passed as parameter it displays the networking statistics.
If "cache" is passed as parameter, it shows the extended cache statistics.
If "runtime" is passed as parameter, it shows the run-time statistics.
If "process" is passed as parameter, it shows existing child processes (if any).
+If "queue" is passed as parameter, it shows queue statistics.
.TP
.BI "-R "
Force a resync against the kernel connection tracking table
diff --git a/include/conntrackd.h b/include/conntrackd.h
index 40566bd..040c252 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -35,6 +35,7 @@
#define FLUSH_INT_CACHE 33 /* flush internal cache */
#define FLUSH_EXT_CACHE 34 /* flush external cache */
#define STATS_PROCESS 35 /* child process stats */
+#define STATS_QUEUE 36 /* queue stats */
#define DEFAULT_CONFIGFILE "/etc/conntrackd/conntrackd.conf"
#define DEFAULT_LOCKFILE "/var/lock/conntrackd.lock"
diff --git a/include/queue.h b/include/queue.h
index 89b00a8..d989402 100644
--- a/include/queue.h
+++ b/include/queue.h
@@ -32,6 +32,7 @@ struct evfd;
#define QUEUE_NAMELEN 16
struct queue {
+ struct list_head list;
unsigned int max_elems;
unsigned int num_elems;
uint32_t flags;
@@ -45,6 +46,7 @@ struct queue {
struct queue *queue_create(const char *name,
int max_objects, unsigned int flags);
void queue_destroy(struct queue *b);
+void queue_stats_show(int fd);
unsigned int queue_len(const struct queue *b);
int queue_add(struct queue *b, struct queue_node *n);
int queue_del(struct queue_node *n);
diff --git a/src/main.c b/src/main.c
index ca491f2..4ead2ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -44,7 +44,7 @@ static const char usage_client_commands[] =
" -i, display content of the internal cache\n"
" -e, display the content of the external cache\n"
" -k, kill conntrack daemon\n"
- " -s [|network|cache|runtime|link|rsqueue], dump statistics\n"
+ " -s [|network|cache|runtime|link|rsqueue|queue], dump statistics\n"
" -R, resync with kernel conntrack table\n"
" -n, request resync with other node (only FT-FW and NOTRACK modes)\n"
" -x, dump cache in XML format (requires -i or -e)\n"
@@ -218,6 +218,10 @@ int main(int argc, char *argv[])
strlen(argv[i+1])) == 0) {
action = STATS_PROCESS;
i++;
+ } else if (strncmp(argv[i+1], "queue",
+ strlen(argv[i+1])) == 0) {
+ action = STATS_QUEUE;
+ i++;
} else {
fprintf(stderr, "ERROR: unknown "
"parameter `%s' for "
diff --git a/src/queue.c b/src/queue.c
index e5dc307..6f5707f 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -20,8 +20,12 @@
#include "event.h"
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/socket.h>
+
+static LIST_HEAD(queue_list); /* list of existing queues */
struct queue *
queue_create(const char *name, int max_objects, unsigned int flags)
@@ -45,17 +49,37 @@ queue_create(const char *name, int max_objects, unsigned int flags)
}
strncpy(b->name, name, QUEUE_NAMELEN);
b->name[QUEUE_NAMELEN-1]='\0';
+ list_add(&b->list, &queue_list);
return b;
}
void queue_destroy(struct queue *b)
{
+ list_del(&b->list);
if (b->flags & QUEUE_F_EVFD)
destroy_evfd(b->evfd);
free(b);
}
+void queue_stats_show(int fd)
+{
+ struct queue *this;
+ int size = 0;
+ char buf[512];
+
+ list_for_each_entry(this, &queue_list, list) {
+ size += snprintf(buf+size, sizeof(buf),
+ "queue %s:\n"
+ "current elements:\t\t%12u\n"
+ "maximum elements:\t\t%12u\n\n",
+ this->name,
+ this->num_elems,
+ this->max_elems);
+ }
+ send(fd, buf, size, 0);
+}
+
void queue_node_init(struct queue_node *n, int type)
{
INIT_LIST_HEAD(&n->head);
diff --git a/src/sync-mode.c b/src/sync-mode.c
index 308c08b..4d6956e 100644
--- a/src/sync-mode.c
+++ b/src/sync-mode.c
@@ -494,6 +494,9 @@ static int local_handler_sync(int fd, int type, void *data)
multichannel_stats_extended(STATE_SYNC(channel),
STATE_SYNC(interface), fd);
break;
+ case STATS_QUEUE:
+ queue_stats_show(fd);
+ break;
default:
if (STATE_SYNC(sync)->local)
ret = STATE_SYNC(sync)->local(fd, type, data);