diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-03-12 12:53:26 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-03-12 12:53:26 +0100 |
commit | 0b2265da0d0dadfae5f0442700d6903ce3fe0bee (patch) | |
tree | 28f13a2b90b6ad75939ef86076fd50221c1920a6 /qa/ct_events_reliable.c | |
parent | 94e75add9867fb6f0e05e73b23f723f139da829e (diff) |
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 <pablo@netfilter.org>
Diffstat (limited to 'qa/ct_events_reliable.c')
-rw-r--r-- | qa/ct_events_reliable.c | 24 |
1 files changed, 18 insertions, 6 deletions
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 <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <errno.h> #include <libnetfilter_conntrack/libnetfilter_conntrack.h> +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"); |