From 1b17dbefe981da7791c98bc6320701c8f20886a0 Mon Sep 17 00:00:00 2001 From: "/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org" Date: Thu, 26 Jan 2006 09:12:19 +0000 Subject: fix some hahstable related bugs: 1) correctly name flow.end.usec 2) initialize 'idle' list_head 3) don't allocate hash table in case hash_use=0 4) fix invalid pointer arithmetic --- input/flow/ulogd_inpflow_NFCT.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/input/flow/ulogd_inpflow_NFCT.c b/input/flow/ulogd_inpflow_NFCT.c index 02526a3..c97c7bc 100644 --- a/input/flow/ulogd_inpflow_NFCT.c +++ b/input/flow/ulogd_inpflow_NFCT.c @@ -238,7 +238,7 @@ static struct ulogd_key nfct_okeys[] = { { .type = ULOGD_RET_UINT32, .flags = ULOGD_RETF_NONE, - .name = "flow.end.sec", + .name = "flow.end.usec", .ipfix = { .vendor = IPFIX_VENDOR_IETF, .field_id = IPFIX_flowEndSeconds, @@ -260,6 +260,7 @@ static struct ct_htable *htable_alloc(int htable_size, int prealloc) htable->buckets = (void *)htable + sizeof(*htable); htable->num_buckets = htable_size; htable->prealloc = prealloc; + INIT_LLIST_HEAD(&htable->idle); for (i = 0; i < htable->num_buckets; i++) INIT_LLIST_HEAD(&htable->buckets[i]); @@ -447,7 +448,8 @@ static int event_handler(void *arg, unsigned int flags, int type, { struct nfct_conntrack *ct = arg; struct ulogd_pluginstance *upi = data; - struct nfct_pluginstance *cpi = (struct nfct_pluginstance *) data; + struct nfct_pluginstance *cpi = + (struct nfct_pluginstance *) upi->private; if (type == NFCT_MSG_NEW) { if (usehash_ce(upi->config_kset).u.value != 0) @@ -546,12 +548,14 @@ static int constructor_nfct(struct ulogd_pluginstance *upi) else prealloc = 0; - cpi->ct_active = htable_alloc(buckets_ce(upi->config_kset).u.value, - prealloc); - if (!cpi->ct_active) { - ulogd_log(ULOGD_FATAL, "error allocating hash\n"); - nfct_close(cpi->cth); - return -1; + if (usehash_ce(upi->config_kset).u.value != 0) { + cpi->ct_active = htable_alloc(buckets_ce(upi->config_kset).u.value, + prealloc); + if (!cpi->ct_active) { + ulogd_log(ULOGD_FATAL, "error allocating hash\n"); + nfct_close(cpi->cth); + return -1; + } } return 0; -- cgit v1.2.3