aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/netns/xfrm.h1
-rw-r--r--net/core/flow.c14
2 files changed, 8 insertions, 7 deletions
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h
index 51f0dce7b643..3492434baf88 100644
--- a/include/net/netns/xfrm.h
+++ b/include/net/netns/xfrm.h
@@ -64,7 +64,6 @@ struct netns_xfrm {
64 64
65 /* flow cache part */ 65 /* flow cache part */
66 struct flow_cache flow_cache_global; 66 struct flow_cache flow_cache_global;
67 struct kmem_cache *flow_cachep;
68 atomic_t flow_cache_genid; 67 atomic_t flow_cache_genid;
69 struct list_head flow_cache_gc_list; 68 struct list_head flow_cache_gc_list;
70 spinlock_t flow_cache_gc_lock; 69 spinlock_t flow_cache_gc_lock;
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
48static 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
81static void flow_cache_gc_task(struct work_struct *work) 83static 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);