From d05f05e21be0cca59ca67ac19ef2b73c467b8250 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 17 Jan 2009 20:33:30 +0100 Subject: src: add `-s queue' and change `-v' behaviour This patch moves the existing `-v' behaviour to `-s queue' where it really belongs. The `-v' option is now left to display the version which is the common use of it. # conntrackd -v Connection tracking userspace daemon v0.9.9. Licensed under GPLv2. (C) 2006-2009 Pablo Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- include/conntrackd.h | 3 ++- src/main.c | 22 +++++++++++++++++----- src/sync-ftfw.c | 8 ++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/conntrackd.h b/include/conntrackd.h index acf907c..eca6b76 100644 --- a/include/conntrackd.h +++ b/include/conntrackd.h @@ -25,11 +25,12 @@ #define DUMP_INT_XML 24 /* dump internal cache in XML */ #define DUMP_EXT_XML 25 /* dump external cache in XML */ #define RESET_TIMERS 26 /* reset kernel timers */ -#define DEBUG_INFO 27 /* show debug info (if any) */ +#define DEBUG_INFO 27 /* unused */ #define STATS_NETWORK 28 /* extended network stats */ #define STATS_CACHE 29 /* extended cache stats */ #define STATS_RUNTIME 30 /* extended runtime stats */ #define STATS_MULTICAST 31 /* multicast network stats */ +#define STATS_QUEUE 32 /* queue stats */ #define DEFAULT_CONFIGFILE "/etc/conntrackd/conntrackd.conf" #define DEFAULT_LOCKFILE "/var/lock/conntrackd.lock" diff --git a/src/main.c b/src/main.c index 061a73e..c3271fe 100644 --- a/src/main.c +++ b/src/main.c @@ -43,12 +43,12 @@ 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|multicast], dump statistics\n" + " -s [|network|cache|runtime|multicast|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" " -t, reset the kernel timeout (see PurgeTimeout clause)\n" - " -v, show internal debugging information (if any)\n"; + " -v, display conntrackd version\n"; static const char usage_options[] = "Options:\n" @@ -64,6 +64,15 @@ show_usage(char *progname) fprintf(stdout, "%s\n", usage_options); } +static void +show_version(void) +{ + fprintf(stdout, "Connection tracking userspace daemon v%s. ", VERSION); + fprintf(stdout, "Licensed under GPLv2.\n"); + fprintf(stdout, "(C) 2006-2009 Pablo Neira Ayuso "); + fprintf(stdout, "\n"); +} + static void set_operation_mode(int *current, int want, char *argv[]) { @@ -173,6 +182,10 @@ int main(int argc, char *argv[]) strlen(argv[i+1])) == 0) { action = STATS_MULTICAST; 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 " @@ -206,9 +219,8 @@ int main(int argc, char *argv[]) } break; case 'v': - set_operation_mode(&type, REQUEST, argv); - action = DEBUG_INFO; - break; + show_version(); + exit(EXIT_SUCCESS); default: show_usage(argv[0]); fprintf(stderr, "Unknown option: %s\n", argv[i]); diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c index 493c15f..fd6c350 100644 --- a/src/sync-ftfw.c +++ b/src/sync-ftfw.c @@ -204,12 +204,12 @@ static int rs_queue_dump(struct queue_node *n, const void *data2) return 0; } -static void debug_rs_dump(int fd) +static void ftfw_local_queue(int fd) { char buf[512]; int size; - size = sprintf(buf, "resent queue (len=%u):\n", queue_len(rs_queue)); + size = sprintf(buf, "resent queue (len=%u)\n", queue_len(rs_queue)); send(fd, buf, size, 0); queue_iterate(rs_queue, &fd, rs_queue_dump); } @@ -227,8 +227,8 @@ static int ftfw_local(int fd, int type, void *data) dlog(LOG_NOTICE, "sending bulk update"); cache_iterate(STATE_SYNC(internal), NULL, do_cache_to_tx); break; - case DEBUG_INFO: - debug_rs_dump(fd); + case STATS_QUEUE: + ftfw_local_queue(fd); break; default: ret = 0; -- cgit v1.2.3