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 | |
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>
-rw-r--r-- | qa/ct_events_reliable.c | 24 | ||||
-rw-r--r-- | qa/ct_stress.c | 6 |
2 files changed, 21 insertions, 9 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"); diff --git a/qa/ct_stress.c b/qa/ct_stress.c index 36aa1a0..328409c 100644 --- a/qa/ct_stress.c +++ b/qa/ct_stress.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { time_t t; - int ret, i, r; + int ret, i, j, r; struct nfct_handle *h; struct nf_conntrack *ct; @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) return -1; } - for (i = r;i < (r + atoi(argv[1]) * 2); i++) { + for (i = r, j = 0;i < (r + atoi(argv[1]) * 2); i++, j++) { nfct_set_attr_u8(ct, ATTR_L3PROTO, AF_INET); nfct_set_attr_u32(ct, ATTR_IPV4_SRC, inet_addr("1.1.1.1") + i); nfct_set_attr_u32(ct, ATTR_IPV4_DST, inet_addr("2.2.2.2") + i); @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) nfct_set_attr_u32(ct, ATTR_STATUS, IPS_ASSURED); if (i % 10000 == 0) - printf("added %d flow entries\n", i); + printf("added %d flow entries\n", j); ret = nfct_query(h, NFCT_Q_CREATE, ct); if (ret == -1) |