[conntrack-tools] ftfw: remove bottleneck in ack/nack handling

Pablo Neira netfilter-cvslog-bounces at lists.netfilter.org
Sun Oct 26 21:24:34 CET 2008


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=e78d828aff1ba35dfdb2e4ccede22cb887977086
commit e78d828aff1ba35dfdb2e4ccede22cb887977086
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Sun Oct 26 21:13:39 2008 +0100
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Sun Oct 26 21:13:39 2008 +0100

    ftfw: remove bottleneck in ack/nack handling
    
    Since the resend list/queue contain elements in order, we can break
    looping once we find the first element that is after the ack/nack
    window. This patch fixes a bottleneck in the ack/nack handling
    reported by oprofile.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

commit c9fc2e7843e56eec84d92b5baa208afdb5b81d3c
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Sun Oct 26 20:48:55 2008 +0100
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Sun Oct 26 20:48:55 2008 +0100

    ftfw: add option `-v' to output debugging information (if any)
    
    This patch introduces the option `-v' to show useful debugging
    information, if any. As for now, only sync-ftfw.c make use of it to
    display the content and the length of the resent list/queue. This
    is useful to check for message leaks. Other working modes or
    synchronization approaches may use it to display debugging
    information in the future.
    
    This patch removes _SIGNAL_DEBUG in sync-ftfw.c that was used for
    for the same purpose. However, it could only be enabled at compilation
    time and it uses signalling instead of the standard UNIX socket
    interface that conntrackd provides.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
       via  e78d828aff1ba35dfdb2e4ccede22cb887977086 (commit)
       via  c9fc2e7843e56eec84d92b5baa208afdb5b81d3c (commit)
      from  367bd830bb88393a639f6f41c3f390f6dd3e120f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e78d828aff1ba35dfdb2e4ccede22cb887977086
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Sun Oct 26 21:13:39 2008 +0100

    ftfw: remove bottleneck in ack/nack handling
    
    Since the resend list/queue contain elements in order, we can break
    looping once we find the first element that is after the ack/nack
    window. This patch fixes a bottleneck in the ack/nack handling
    reported by oprofile.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

commit c9fc2e7843e56eec84d92b5baa208afdb5b81d3c
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Sun Oct 26 20:48:55 2008 +0100

    ftfw: add option `-v' to output debugging information (if any)
    
    This patch introduces the option `-v' to show useful debugging
    information, if any. As for now, only sync-ftfw.c make use of it to
    display the content and the length of the resent list/queue. This
    is useful to check for message leaks. Other working modes or
    synchronization approaches may use it to display debugging
    information in the future.
    
    This patch removes _SIGNAL_DEBUG in sync-ftfw.c that was used for
    for the same purpose. However, it could only be enabled at compilation
    time and it uses signalling instead of the standard UNIX socket
    interface that conntrackd provides.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

-----------------------------------------------------------------------

 include/conntrackd.h |    1 +
 src/main.c           |    7 ++-
 src/sync-ftfw.c      |  133 +++++++++++++++++++++++++++----------------------
 3 files changed, 80 insertions(+), 61 deletions(-)
This patch introduces the option `-v' to show useful debugging
information, if any. As for now, only sync-ftfw.c make use of it to
display the content and the length of the resent list/queue. This
is useful to check for message leaks. Other working modes or
synchronization approaches may use it to display debugging
information in the future.

This patch removes _SIGNAL_DEBUG in sync-ftfw.c that was used for
for the same purpose. However, it could only be enabled at compilation
time and it uses signalling instead of the standard UNIX socket
interface that conntrackd provides.

Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

diff --git a/include/conntrackd.h b/include/conntrackd.h
index c0bb4bb..448d594 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -25,6 +25,7 @@
 #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 DEFAULT_CONFIGFILE	"/etc/conntrackd/conntrackd.conf"
 #define DEFAULT_LOCKFILE	"/var/lock/conntrackd.lock"
diff --git a/src/main.c b/src/main.c
index b535c40..d6aa938 100644
--- a/src/main.c
+++ b/src/main.c
@@ -47,7 +47,8 @@ static const char usage_client_commands[] =
 	"  -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)"
-	"  -t, reset the kernel timeout (see PurgeTimeout clause)";
+	"  -t, reset the kernel timeout (see PurgeTimeout clause)"
+	"  -v, show internal debugging information (if any)";
 
 static const char usage_options[] =
 	"Options:\n"
@@ -180,6 +181,10 @@ int main(int argc, char *argv[])
 
 			}
 			break;
+		case 'v':
+			set_operation_mode(&type, REQUEST, argv);
+			action = DEBUG_INFO;
+			break;
 		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 b7eabdf..f900919 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -139,36 +139,6 @@ static void do_alive_alarm(struct alarm_block *a, void *data)
 	mcast_buffered_pending_netmsg(STATE_SYNC(mcast_client));
 }
 
-#undef _SIGNAL_DEBUG
-#ifdef _SIGNAL_DEBUG
-
-static int rs_dump(void *data1, const void *data2)
-{
-	struct nethdr_ack *net = data1;
-
-	printf("in RS queue -> seq:%u flags:%u\n", net->seq, net->flags);
-
-	return 0;
-}
-
-#include <signal.h>
-
-static void my_dump(int foo)
-{
-	struct cache_ftfw *cn, *tmp;
-
-	list_for_each_entry_safe(cn, tmp, &rs_list, rs_list) {
-		struct us_conntrack *u;
-		
-		u = cache_get_conntrack(STATE_SYNC(internal), cn);
-		printf("in RS list -> seq:%u\n", cn->seq);
-	}
-
-	queue_iterate(rs_queue, NULL, rs_dump);
-}
-
-#endif
-
 static int ftfw_init(void)
 {
 	tx_queue = queue_create(CONFIG(resend_queue_size));
@@ -189,10 +159,6 @@ static int ftfw_init(void)
 	/* set ack window size */
 	window = CONFIG(window_size);
 
-#ifdef _SIGNAL_DEBUG
-	signal(SIGUSR1, my_dump);
-#endif
-
 	return 0;
 }
 
@@ -219,6 +185,38 @@ static int do_cache_to_tx(void *data1, void *data2)
 	return 0;
 }
 
+static int debug_rs_queue_dump_step(void *data1, const void *data2)
+{
+	struct nethdr_ack *net = data1;
+	const int *fd = data2;
+	char buf[512];
+	int size;
+
+	size = sprintf(buf, "seq:%u flags:%u\n", net->seq, net->flags);
+	send(*fd, buf, size, 0);
+	return 0;
+}
+
+static void debug_rs_dump(int fd)
+{
+	struct cache_ftfw *cn, *tmp;
+	char buf[512];
+	int size;
+
+	size = sprintf(buf, "resent list (len=%u):\n", rs_list_len);
+	send(fd, buf, size, 0);
+	list_for_each_entry_safe(cn, tmp, &rs_list, rs_list) {
+		struct us_conntrack *u;
+		
+		u = cache_get_conntrack(STATE_SYNC(internal), cn);
+		size = sprintf(buf, "seq:%u\n", cn->seq);
+		send(fd, buf, size, 0);
+	}
+	size = sprintf(buf, "\nresent queue (len=%u):\n", queue_len(rs_queue));
+	send(fd, buf, size, 0);
+	queue_iterate(rs_queue, &fd, debug_rs_queue_dump_step);
+}
+
 static int ftfw_local(int fd, int type, void *data)
 {
 	int ret = 1;
@@ -232,6 +230,9 @@ 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);
+		break;
 	default:
 		ret = 0;
 		break;



More information about the netfilter-cvslog mailing list