summaryrefslogtreecommitdiff
path: root/include/net/inet_frag.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-05-24 09:03:39 -0700
committerDavid S. Miller <davem@davemloft.net>2019-05-26 14:08:05 -0700
commit4907abc605e328d61bee56e4e89db4f56ade2090 (patch)
tree764e708aaa78091e2a8ccb046cfbf8a59aa10c88 /include/net/inet_frag.h
parenta39aca678a0626941aa99c18c1c452ca758e7865 (diff)
net: dynamically allocate fqdir structures
Following patch will add rcu grace period before fqdir rhashtable destruction, so we need to dynamically allocate fqdir structures to not force expensive synchronize_rcu() calls in netns dismantle path. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/inet_frag.h')
-rw-r--r--include/net/inet_frag.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 37cde5c1498c..5f754c660cfa 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -105,14 +105,25 @@ struct inet_frags {
int inet_frags_init(struct inet_frags *);
void inet_frags_fini(struct inet_frags *);
-static inline int fqdir_init(struct fqdir *fqdir, struct inet_frags *f,
+static inline int fqdir_init(struct fqdir **fqdirp, struct inet_frags *f,
struct net *net)
{
+ struct fqdir *fqdir = kzalloc(sizeof(*fqdir), GFP_KERNEL);
+ int res;
+
+ if (!fqdir)
+ return -ENOMEM;
fqdir->f = f;
fqdir->net = net;
- atomic_long_set(&fqdir->mem, 0);
- return rhashtable_init(&fqdir->rhashtable, &fqdir->f->rhash_params);
+ res = rhashtable_init(&fqdir->rhashtable, &fqdir->f->rhash_params);
+ if (res < 0) {
+ kfree(fqdir);
+ return res;
+ }
+ *fqdirp = fqdir;
+ return 0;
}
+
void fqdir_exit(struct fqdir *fqdir);
void inet_frag_kill(struct inet_frag_queue *q);