diff options
author | Eric Dumazet <edumazet@google.com> | 2014-03-10 10:09:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-10 21:45:11 -0400 |
commit | d32d9bb85c65f52bed99a0149b47e9f6578c44c5 (patch) | |
tree | 96dfb7a0eefaed30e0a63442337907166dbe9526 /net/core | |
parent | 5812521be0f79583a26e203ac5f23de679cbdd94 (diff) |
flowcache: restore a single flow_cache kmem_cache
It is not legal to create multiple kmem_cache having the same name.
flowcache can use a single kmem_cache, no need for a per netns
one.
Fixes: ca925cf1534e ("flowcache: Make flow cache name space aware")
Reported-by: Jakub Kicinski <moorray3@wp.pl>
Tested-by: Jakub Kicinski <moorray3@wp.pl>
Tested-by: Fan Du <fan.du@windriver.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/flow.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/core/flow.c b/net/core/flow.c index 344a184011fd..102f8ea2eb6e 100644 --- a/net/core/flow.c +++ b/net/core/flow.c | |||
@@ -45,6 +45,8 @@ struct flow_flush_info { | |||
45 | struct completion completion; | 45 | struct completion completion; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static struct kmem_cache *flow_cachep __read_mostly; | ||
49 | |||
48 | #define flow_cache_hash_size(cache) (1 << (cache)->hash_shift) | 50 | #define flow_cache_hash_size(cache) (1 << (cache)->hash_shift) |
49 | #define FLOW_HASH_RND_PERIOD (10 * 60 * HZ) | 51 | #define FLOW_HASH_RND_PERIOD (10 * 60 * HZ) |
50 | 52 | ||
@@ -75,7 +77,7 @@ static void flow_entry_kill(struct flow_cache_entry *fle, | |||
75 | { | 77 | { |
76 | if (fle->object) | 78 | if (fle->object) |
77 | fle->object->ops->delete(fle->object); | 79 | fle->object->ops->delete(fle->object); |
78 | kmem_cache_free(xfrm->flow_cachep, fle); | 80 | kmem_cache_free(flow_cachep, fle); |
79 | } | 81 | } |
80 | 82 | ||
81 | static void flow_cache_gc_task(struct work_struct *work) | 83 | static void flow_cache_gc_task(struct work_struct *work) |
@@ -230,7 +232,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir, | |||
230 | if (fcp->hash_count > fc->high_watermark) | 232 | if (fcp->hash_count > fc->high_watermark) |
231 | flow_cache_shrink(fc, fcp); | 233 | flow_cache_shrink(fc, fcp); |
232 | 234 | ||
233 | fle = kmem_cache_alloc(net->xfrm.flow_cachep, GFP_ATOMIC); | 235 | fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC); |
234 | if (fle) { | 236 | if (fle) { |
235 | fle->net = net; | 237 | fle->net = net; |
236 | fle->family = family; | 238 | fle->family = family; |
@@ -435,10 +437,10 @@ int flow_cache_init(struct net *net) | |||
435 | int i; | 437 | int i; |
436 | struct flow_cache *fc = &net->xfrm.flow_cache_global; | 438 | struct flow_cache *fc = &net->xfrm.flow_cache_global; |
437 | 439 | ||
438 | /* Initialize per-net flow cache global variables here */ | 440 | if (!flow_cachep) |
439 | net->xfrm.flow_cachep = kmem_cache_create("flow_cache", | 441 | flow_cachep = kmem_cache_create("flow_cache", |
440 | sizeof(struct flow_cache_entry), | 442 | sizeof(struct flow_cache_entry), |
441 | 0, SLAB_PANIC, NULL); | 443 | 0, SLAB_PANIC, NULL); |
442 | spin_lock_init(&net->xfrm.flow_cache_gc_lock); | 444 | spin_lock_init(&net->xfrm.flow_cache_gc_lock); |
443 | INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list); | 445 | INIT_LIST_HEAD(&net->xfrm.flow_cache_gc_list); |
444 | INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task); | 446 | INIT_WORK(&net->xfrm.flow_cache_gc_work, flow_cache_gc_task); |