summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-06-19 11:37:48 -0400
committerDavid S. Miller <davem@davemloft.net>2019-06-19 11:37:48 -0400
commit6c9bef32c6e742e847fc28c9bf7721cbfa003fa6 (patch)
treef792af2a9bea74e3af00424f26f41087916abef9 /include
parent2a54003e7af1eaddc05848dac14f7bcd77301478 (diff)
parentd5dd88794a13c2f24cce31abad7a0a6c5e0ed2db (diff)
Merge branch 'inet-fix-defrag-units-dismantle-races'
Eric Dumazet says: ==================== inet: fix defrag units dismantle races This series add a new pre_exit() method to struct pernet_operations to solve a race in defrag units dismantle, without adding extra delays to netns dismantles. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/inet_frag.h8
-rw-r--r--include/net/ipv6_frag.h2
-rw-r--r--include/net/net_namespace.h5
3 files changed, 14 insertions, 1 deletions
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index e91b79ad4e4a..46574d996f1d 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -20,7 +20,7 @@ struct fqdir {
/* Keep atomic mem on separate cachelines in structs that include it */
atomic_long_t mem ____cacheline_aligned_in_smp;
- struct rcu_work destroy_rwork;
+ struct work_struct destroy_work;
};
/**
@@ -113,6 +113,12 @@ int inet_frags_init(struct inet_frags *);
void inet_frags_fini(struct inet_frags *);
int fqdir_init(struct fqdir **fqdirp, struct inet_frags *f, struct net *net);
+
+static void inline fqdir_pre_exit(struct fqdir *fqdir)
+{
+ fqdir->high_thresh = 0; /* prevent creation of new frags */
+ fqdir->dead = true;
+}
void fqdir_exit(struct fqdir *fqdir);
void inet_frag_kill(struct inet_frag_queue *q);
diff --git a/include/net/ipv6_frag.h b/include/net/ipv6_frag.h
index 1f77fb4dc79d..a21e8b1381a1 100644
--- a/include/net/ipv6_frag.h
+++ b/include/net/ipv6_frag.h
@@ -67,6 +67,8 @@ ip6frag_expire_frag_queue(struct net *net, struct frag_queue *fq)
struct sk_buff *head;
rcu_read_lock();
+ if (fq->q.fqdir->dead)
+ goto out_rcu_unlock;
spin_lock(&fq->q.lock);
if (fq->q.flags & INET_FRAG_COMPLETE)
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index abb4f92456e1..ad9243afac67 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -355,8 +355,13 @@ struct pernet_operations {
* synchronize_rcu() related to these pernet_operations,
* instead of separate synchronize_rcu() for every net.
* Please, avoid synchronize_rcu() at all, where it's possible.
+ *
+ * Note that a combination of pre_exit() and exit() can
+ * be used, since a synchronize_rcu() is guaranteed between
+ * the calls.
*/
int (*init)(struct net *net);
+ void (*pre_exit)(struct net *net);
void (*exit)(struct net *net);
void (*exit_batch)(struct list_head *net_exit_list);
unsigned int *id;