summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2008-09-25 17:05:50 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2008-09-25 17:05:50 +0200
commit3863f882469117afd6a2ad7ce25711b619f43b27 (patch)
tree11e0242047872b1332cd491f8b8c6c1ca5e451ac
parent666ceb1e2cd71f844f5794a556c46b114764bca6 (diff)
downloadconntrack-tools-3863f882469117afd6a2ad7ce25711b619f43b27.tar.gz
conntrack-tools-3863f882469117afd6a2ad7ce25711b619f43b27.zip
ftfw: fix race that triggers a double insertion into tx_list
This patch fixes a race condition that can trigger a double insertion to the tx_list. This happens if we receive two resync request very close or resync just after a nack or vice-versa. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/sync-ftfw.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index 4c1b536..8dd5554 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -196,6 +196,10 @@ static int do_cache_to_tx(void *data1, void *data2)
struct us_conntrack *u = data2;
struct cache_ftfw *cn = cache_get_extra(STATE_SYNC(internal), u);
+ /* repeated request for resync? */
+ if (!list_empty(&cn->tx_list))
+ return 0;
+
/* add to tx list */
list_add_tail(&cn->tx_list, &tx_list);
tx_list_len++;
@@ -264,8 +268,11 @@ static void rs_list_to_tx(struct cache *c, unsigned int from, unsigned int to)
dp("resending nack'ed (oldseq=%u)\n", cn->seq);
list_del_init(&cn->rs_list);
rs_list_len--;
- list_add_tail(&cn->tx_list, &tx_list);
- tx_list_len++;
+ /* we received a request for resync before this nack? */
+ if (list_empty(&cn->tx_list)) {
+ list_add_tail(&cn->tx_list, &tx_list);
+ tx_list_len++;
+ }
write_evfd(STATE_SYNC(evfd));
}
}