summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2017-05-21 12:52:58 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2017-05-29 12:46:11 +0200
commit0d02d5646eb84403766a11a1d3b19e670a3d45d5 (patch)
tree65216eda295cf6a68a42830bb3b931b1a3aae506 /net
parent2843fb69980b84dfa939733c91dceae533aa89e9 (diff)
downloadlinux-0d02d5646eb84403766a11a1d3b19e670a3d45d5.tar.gz
linux-0d02d5646eb84403766a11a1d3b19e670a3d45d5.tar.bz2
linux-0d02d5646eb84403766a11a1d3b19e670a3d45d5.zip
netfilter: conntrack: restart iteration on resize
We could some conntracks when a resize occurs in parallel. Avoid this by sampling generation seqcnt and doing a restart if needed. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/nf_conntrack_core.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 7ecee79c78b8..c3bd9b086dcc 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1623,17 +1623,25 @@ found:
static void nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data),
void *data, u32 portid, int report)
{
+ unsigned int bucket = 0, sequence;
struct nf_conn *ct;
- unsigned int bucket = 0;
might_sleep();
- while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) {
- /* Time to push up daises... */
+ for (;;) {
+ sequence = read_seqcount_begin(&nf_conntrack_generation);
- nf_ct_delete(ct, portid, report);
- nf_ct_put(ct);
- cond_resched();
+ while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) {
+ /* Time to push up daises... */
+
+ nf_ct_delete(ct, portid, report);
+ nf_ct_put(ct);
+ cond_resched();
+ }
+
+ if (!read_seqcount_retry(&nf_conntrack_generation, sequence))
+ break;
+ bucket = 0;
}
}