summaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-01-15 23:19:58 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2009-01-15 23:19:58 +0100
commit8dce3504fde7da933dc6e7ecfeb99b4b45125f32 (patch)
tree9d12a1e54caf8a6718eb2ad5187e4e13c3791d3e /src/cache.c
parent50339f96638eed35dac2b673b64cc6f1eb96406c (diff)
cache: add status field to store the object status
This patch adds the status field to the cache object. This avoids the (ab)use of the alarm to check if an entry is active or dead. This is the first step to possibly move the alarm to the cache_extra memory space of the ftfw (which is the only use by now). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cache.c b/src/cache.c
index 621a3f4..c46498b 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -196,6 +196,7 @@ struct cache_object *cache_object_new(struct cache *c, struct nf_conntrack *ct)
return NULL;
}
memcpy(obj->ct, ct, nfct_sizeof(ct));
+ obj->status = C_OBJ_NONE;
return obj;
}
@@ -225,6 +226,7 @@ static int __add(struct cache *c, struct cache_object *obj, int id)
c->extra->add(obj, ((char *) obj) + c->extra_offset);
c->stats.active++;
+ obj->status = C_OBJ_NEW;
return 0;
}
@@ -260,6 +262,7 @@ void cache_update(struct cache *c, struct cache_object *obj, int id,
c->extra->update(obj, ((char *) obj) + c->extra_offset);
c->stats.upd_ok++;
+ obj->status = C_OBJ_ALIVE;
}
static void __del(struct cache *c, struct cache_object *obj)
@@ -285,7 +288,7 @@ void cache_del(struct cache *c, struct cache_object *obj)
* kill an entry was previously deleted via
* __cache_del_timer.
*/
- if (!alarm_pending(&obj->alarm)) {
+ if (obj->status != C_OBJ_DEAD) {
c->stats.del_ok++;
c->stats.active--;
}
@@ -301,7 +304,7 @@ cache_update_force(struct cache *c, struct nf_conntrack *ct)
obj = cache_find(c, ct, &id);
if (obj) {
- if (!alarm_pending(&obj->alarm)) {
+ if (obj->status != C_OBJ_DEAD) {
cache_update(c, obj, id, ct);
return obj;
} else {
@@ -333,7 +336,8 @@ int cache_del_timer(struct cache *c, struct cache_object *obj, int timeout)
cache_object_free(obj);
return 1;
}
- if (!alarm_pending(&obj->alarm)) {
+ if (obj->status != C_OBJ_DEAD) {
+ obj->status = C_OBJ_DEAD;
add_alarm(&obj->alarm, timeout, 0);
/*
* increase stats even if this entry was not really