diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-25 17:51:23 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2009-01-25 17:51:23 +0100 |
commit | b9ee88a0fdb20ed847f05efce1b0abdc8afbabaf (patch) | |
tree | 63fe8a9bd97d55c404a7b5c7e5fd48150495ae2a /src | |
parent | 8d689ebb67c511f5c03acdfc2226156d5f87c319 (diff) | |
download | conntrack-tools-b9ee88a0fdb20ed847f05efce1b0abdc8afbabaf.tar.gz conntrack-tools-b9ee88a0fdb20ed847f05efce1b0abdc8afbabaf.zip |
src: don't clone when calling nl_*_conntrack functions
This patch removes the clone conntrack objects created before
calling nl_*_conntrack functions since they are not required
anymore (the previous patch guarantees that objects passed as
parameter are not modified).
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cache_iterators.c | 19 | ||||
-rw-r--r-- | src/cache_wt.c | 15 |
2 files changed, 9 insertions, 25 deletions
diff --git a/src/cache_iterators.c b/src/cache_iterators.c index 9b54ea1..be69d47 100644 --- a/src/cache_iterators.c +++ b/src/cache_iterators.c @@ -194,34 +194,27 @@ static int do_reset_timers(void *data1, struct hashtable_node *n) u_int32_t current_timeout; struct nfct_handle *h = data1; struct cache_object *obj = (struct cache_object *)n; - struct nf_conntrack *ct = obj->ct; - char __tmp[nfct_maxsize()]; - struct nf_conntrack *tmp = (struct nf_conntrack *) (void *)__tmp; - - memset(__tmp, 0, sizeof(__tmp)); - /* use the original tuple to check if it is there */ - nfct_copy(tmp, ct, NFCT_CP_ORIG); - - ret = nl_get_conntrack(h, tmp); + ret = nl_get_conntrack(h, obj->ct); switch (ret) { case -1: /* the kernel table is not in sync with internal cache */ dlog(LOG_ERR, "reset-timers: %s", strerror(errno)); - dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); break; case 1: /* use the object that contain the current timer */ - current_timeout = nfct_get_attr_u32(ct, ATTR_TIMEOUT); + current_timeout = nfct_get_attr_u32(obj->ct, ATTR_TIMEOUT); /* already about to die, do not touch it */ if (current_timeout < CONFIG(purge_timeout)) break; - if (nl_update_conntrack(h, tmp, CONFIG(purge_timeout)) == -1) { + ret = nl_update_conntrack(h, obj->ct, CONFIG(purge_timeout)); + if (ret == -1) { if (errno == ETIME || errno == ENOENT) break; dlog(LOG_ERR, "reset-timers-upd: %s", strerror(errno)); - dlog_ct(STATE(log), ct, NFCT_O_PLAIN); + dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); } break; } diff --git a/src/cache_wt.c b/src/cache_wt.c index 6f9ccc7..34fe82e 100644 --- a/src/cache_wt.c +++ b/src/cache_wt.c @@ -27,8 +27,6 @@ static void add_wt(struct cache_object *obj) { int ret; - char __ct[nfct_maxsize()]; - struct nf_conntrack *ct = (struct nf_conntrack *)(void*) __ct; ret = nl_get_conntrack(STATE(request), obj->ct); switch (ret) { @@ -37,15 +35,13 @@ static void add_wt(struct cache_object *obj) dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); break; case 0: - memcpy(ct, obj->ct, nfct_maxsize()); - if (nl_create_conntrack(STATE(dump), ct, 0) == -1) { + if (nl_create_conntrack(STATE(dump), obj->ct, 0) == -1) { dlog(LOG_ERR, "cache_wt create: %s", strerror(errno)); dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); } break; case 1: - memcpy(ct, obj->ct, nfct_maxsize()); - if (nl_update_conntrack(STATE(dump), ct, 0) == -1) { + if (nl_update_conntrack(STATE(dump), obj->ct, 0) == -1) { dlog(LOG_ERR, "cache_wt crt-upd: %s", strerror(errno)); dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); } @@ -55,12 +51,7 @@ static void add_wt(struct cache_object *obj) static void upd_wt(struct cache_object *obj) { - char __ct[nfct_maxsize()]; - struct nf_conntrack *ct = (struct nf_conntrack *)(void*) __ct; - - memcpy(ct, obj->ct, nfct_maxsize()); - - if (nl_update_conntrack(STATE(dump), ct, 0) == -1) { + if (nl_update_conntrack(STATE(dump), obj->ct, 0) == -1) { dlog(LOG_ERR, "cache_wt update:%s", strerror(errno)); dlog_ct(STATE(log), obj->ct, NFCT_O_PLAIN); } |