From cedd1976acefbbf85d95a67a23c72ff011466d62 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 14 Feb 2009 21:26:26 +0100 Subject: src: use resync handler for polling instead of dump handler This patch moves the polling logic into the resync handler. The dump handler action depended on the daemon working mode (polling or event-driven) resulting in an inconsistent behaviour. Signed-off-by: Pablo Neira Ayuso --- src/sync-mode.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/sync-mode.c') diff --git a/src/sync-mode.c b/src/sync-mode.c index 63948f1..74eb36e 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -507,8 +507,6 @@ static void mcast_send_sync(struct cache_object *obj, int query) static void dump_sync(struct nf_conntrack *ct) { - struct cache_object *obj; - /* This is required by kernels < 2.6.20 */ nfct_attr_unset(ct, ATTR_ORIG_COUNTER_BYTES); nfct_attr_unset(ct, ATTR_ORIG_COUNTER_PACKETS); @@ -516,13 +514,8 @@ static void dump_sync(struct nf_conntrack *ct) nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); nfct_attr_unset(ct, ATTR_USE); - obj = cache_update_force(STATE_SYNC(internal), ct); - if ((CONFIG(flags) & CTD_POLL)) { - if (obj != NULL && obj->status == C_OBJ_NEW) { - debug_ct(ct, "poll"); - mcast_send_sync(obj, NET_T_STATE_NEW); - } - } + if (cache_update_force(STATE_SYNC(internal), ct)) + debug_ct(ct, "dump"); } static int purge_step(void *data1, void *data2) @@ -566,11 +559,20 @@ static int resync_sync(enum nf_conntrack_msg_type type, nfct_attr_unset(ct, ATTR_REPL_COUNTER_PACKETS); nfct_attr_unset(ct, ATTR_USE); - if ((obj = cache_update_force(STATE_SYNC(internal), ct))) { - debug_ct(obj->ct, "resync"); + obj = cache_update_force(STATE_SYNC(internal), ct); + if (obj == NULL) + return NFCT_CB_CONTINUE; + + switch (obj->status) { + case C_OBJ_NEW: + debug_ct(ct, "resync"); + mcast_send_sync(obj, NET_T_STATE_NEW); + break; + case C_OBJ_ALIVE: + debug_ct(ct, "resync"); mcast_send_sync(obj, NET_T_STATE_UPD); + break; } - return NFCT_CB_CONTINUE; } -- cgit v1.2.3