summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cache.c10
-rw-r--r--src/cache_iterators.c2
-rw-r--r--src/network.c13
3 files changed, 21 insertions, 4 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
diff --git a/src/cache_iterators.c b/src/cache_iterators.c
index 4773889..ab6a461 100644
--- a/src/cache_iterators.c
+++ b/src/cache_iterators.c
@@ -51,7 +51,7 @@ static int do_dump(void *data1, struct hashtable_node *n)
* specific and it breaks conntrackd modularity. Probably
* there's a nicer way to do this but until I come up with it...
*/
- if (CONFIG(flags) & CTD_SYNC_FTFW && alarm_pending(&obj->alarm))
+ if (CONFIG(flags) & CTD_SYNC_FTFW && obj->status == C_OBJ_DEAD)
return 0;
/* do not show cached timeout, this may confuse users */
diff --git a/src/network.c b/src/network.c
index 598195f..320cdea 100644
--- a/src/network.c
+++ b/src/network.c
@@ -177,3 +177,16 @@ int mcast_track_is_seq_set()
{
return local_seq_set;
}
+
+#include "cache.h"
+
+static int status2type[] = {
+ [C_OBJ_NEW] = NET_T_STATE_NEW,
+ [C_OBJ_ALIVE] = NET_T_STATE_UPD,
+ [C_OBJ_DEAD] = NET_T_STATE_DEL,
+};
+
+int object_status_to_network_type(int status)
+{
+ return status2type[status];
+}