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 ++++++++++++++++++------ qa/ct_stress.c | 6 +++--- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'qa') 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"); 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) -- cgit v1.2.3