From 0b2265da0d0dadfae5f0442700d6903ce3fe0bee Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 12 Mar 2012 12:53:26 +0100 Subject: qa: several improvements for the ct_stress tools This patch improves several aspects of the QA tools to stress the conntrack system via ctnetlink and to check reliable event delivery. Signed-off-by: Pablo Neira Ayuso --- qa/ct_events_reliable.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'qa/ct_events_reliable.c') diff --git a/qa/ct_events_reliable.c b/qa/ct_events_reliable.c index e95623a..1c8e194 100644 --- a/qa/ct_events_reliable.c +++ b/qa/ct_events_reliable.c @@ -1,35 +1,47 @@ #include #include #include +#include #include #include +static int events = 0; +static int new, update, destroy; + static int event_cb(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data) { - static int i = 0; - static int new, destroy; - if (type == NFCT_T_NEW) new++; + if (type == NFCT_T_UPDATE) + update++; else if (type == NFCT_T_DESTROY) destroy++; - if ((++i % 10000) == 0) - printf("%d events received (%d new, %d destroy)\n", - i, new, destroy); + if ((++events % 10000) == 0) + printf("%d events received (%d new, %d update, %d destroy)\n", + events, new, update, destroy); return NFCT_CB_CONTINUE; } +static void sighandler(int foo) +{ + printf("%d events received (%d new, %d update, %d destroy)\n", + events, new, update, destroy); + exit(EXIT_SUCCESS); +} + int main(void) { int ret; struct nfct_handle *h; int on = 1; + signal(SIGINT, sighandler); + h = nfct_open(CONNTRACK, NFCT_ALL_CT_GROUPS); if (!h) { perror("nfct_open"); -- cgit v1.2.3