From 5000afe7e1a3ae4a14995e051d3ee716d8a6c784 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 20 Oct 2008 14:17:13 +0200 Subject: notrack: fix double receival of resync requests This patch fixes double insertion in the tx_list if we receive two (or more) consecutive resync request in short time. Signed-off-by: Pablo Neira Ayuso --- src/sync-notrack.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/sync-notrack.c b/src/sync-notrack.c index 2b1bc13..c7ac9b5 100644 --- a/src/sync-notrack.c +++ b/src/sync-notrack.c @@ -36,8 +36,26 @@ struct cache_notrack { struct list_head tx_list; }; +static void cache_notrack_add(struct us_conntrack *u, void *data) +{ + struct cache_notrack *cn = data; + INIT_LIST_HEAD(&cn->tx_list); +} + +static void cache_notrack_del(struct us_conntrack *u, void *data) +{ + struct cache_notrack *cn = data; + + if (!list_empty(&cn->tx_list)) { + list_del(&cn->tx_list); + tx_list_len--; + } +} + static struct cache_extra cache_notrack_extra = { .size = sizeof(struct cache_notrack), + .add = cache_notrack_add, + .destroy = cache_notrack_del }; static void tx_queue_add_ctlmsg(uint32_t flags, uint32_t from, uint32_t to) @@ -73,6 +91,9 @@ static int do_cache_to_tx(void *data1, void *data2) struct us_conntrack *u = data2; struct cache_notrack *cn = cache_get_extra(STATE_SYNC(internal), u); + if (!list_empty(&cn->tx_list)) + return 0; + /* add to tx list */ list_add_tail(&cn->tx_list, &tx_list); tx_list_len++; -- cgit v1.2.3