summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-01-04 14:31:41 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2012-01-10 01:54:45 +0100
commit79ab299bfb20b7fc1982ca90d77d8b908b824fea (patch)
treea7fe20e7685f967da400675c42fce9f6f634a30f
parent598e465087365db1fa36b67aa53d291e400ec5b1 (diff)
downloadconntrack-tools-79ab299bfb20b7fc1982ca90d77d8b908b824fea.tar.gz
conntrack-tools-79ab299bfb20b7fc1982ca90d77d8b908b824fea.zip
conntrackd: simplify cache_get_extra function
This patch simplifies cache_get_extra which now takes only one parameter that is the cache_object. With it, the extra area can be calculated. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/cache.h2
-rw-r--r--src/cache.c4
-rw-r--r--src/sync-alarm.c3
-rw-r--r--src/sync-ftfw.c6
-rw-r--r--src/sync-notrack.c6
5 files changed, 8 insertions, 13 deletions
diff --git a/include/cache.h b/include/cache.h
index 02bb386..65f7e3a 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -148,7 +148,7 @@ struct cache_object *cache_find(struct cache *c, void *ptr, int *pos);
void cache_stats(const struct cache *c, int fd);
void cache_stats_extended(const struct cache *c, int fd);
struct cache_object *cache_data_get_object(struct cache *c, void *data);
-void *cache_get_extra(struct cache *, void *);
+void *cache_get_extra(struct cache_object *);
void cache_iterate(struct cache *c, void *data, int (*iterate)(void *data1, void *data2));
void cache_iterate_limit(struct cache *c, void *data, uint32_t from, uint32_t steps, int (*iterate)(void *data1, void *data2));
diff --git a/src/cache.c b/src/cache.c
index efdab0e..f515ba0 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -308,9 +308,9 @@ struct cache_object *cache_data_get_object(struct cache *c, void *data)
return (struct cache_object *)((char*)data - c->extra_offset);
}
-void *cache_get_extra(struct cache *c, void *data)
+void *cache_get_extra(struct cache_object *obj)
{
- return (char*)data + c->extra_offset;
+ return (char*)obj + obj->cache->extra_offset;
}
void cache_stats(const struct cache *c, int fd)
diff --git a/src/sync-alarm.c b/src/sync-alarm.c
index 65154a1..03481fd 100644
--- a/src/sync-alarm.c
+++ b/src/sync-alarm.c
@@ -110,8 +110,7 @@ static int alarm_recv(const struct nethdr *net)
static void alarm_enqueue(struct cache_object *obj, int query)
{
- struct cache_alarm *ca =
- cache_get_extra(STATE(mode)->internal->ct.data, obj);
+ struct cache_alarm *ca = cache_get_extra(obj);
if (queue_add(STATE_SYNC(tx_queue), &ca->qnode) > 0)
cache_object_get(obj);
}
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index cff4d25..c7cc4aa 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -169,8 +169,7 @@ static void ftfw_kill(void)
static int do_cache_to_tx(void *data1, void *data2)
{
struct cache_object *obj = data2;
- struct cache_ftfw *cn =
- cache_get_extra(STATE(mode)->internal->ct.data, obj);
+ struct cache_ftfw *cn = cache_get_extra(obj);
if (queue_in(rs_queue, &cn->qnode)) {
queue_del(&cn->qnode);
@@ -551,8 +550,7 @@ static void ftfw_xmit(void)
static void ftfw_enqueue(struct cache_object *obj, int type)
{
- struct cache_ftfw *cn =
- cache_get_extra(STATE(mode)->internal->ct.data, obj);
+ struct cache_ftfw *cn = cache_get_extra(obj);
if (queue_in(rs_queue, &cn->qnode)) {
queue_del(&cn->qnode);
queue_add(STATE_SYNC(tx_queue), &cn->qnode);
diff --git a/src/sync-notrack.c b/src/sync-notrack.c
index 6c798ac..a8cc6bf 100644
--- a/src/sync-notrack.c
+++ b/src/sync-notrack.c
@@ -76,8 +76,7 @@ static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to)
static int do_cache_to_tx(void *data1, void *data2)
{
struct cache_object *obj = data2;
- struct cache_notrack *cn =
- cache_get_extra(STATE(mode)->internal->ct.data, obj);
+ struct cache_notrack *cn = cache_get_extra(obj);
if (queue_add(STATE_SYNC(tx_queue), &cn->qnode) > 0)
cache_object_get(obj);
return 0;
@@ -219,8 +218,7 @@ static void notrack_xmit(void)
static void notrack_enqueue(struct cache_object *obj, int query)
{
- struct cache_notrack *cn =
- cache_get_extra(STATE(mode)->internal->ct.data, obj);
+ struct cache_notrack *cn = cache_get_extra(obj);
if (queue_add(STATE_SYNC(tx_queue), &cn->qnode) > 0)
cache_object_get(obj);
}