diff options
author | Florian Westphal <fw@strlen.de> | 2016-08-23 10:00:12 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2016-08-24 07:16:06 -0400 |
commit | 35db57bbc4b7ab810bba6e6d6954a0faf5a842cf (patch) | |
tree | 6d158c2c0f8da102efa29b3282d7b58526bf8fbf | |
parent | 4141b36ab16d7a66b4cf712f2d21eba61c5927e5 (diff) |
xfrm: state: remove per-netns gc task
After commit 5b8ef3415a21f173
("xfrm: Remove ancient sleeping when the SA is in acquire state")
gc does not need any per-netns data anymore.
As far as gc is concerned all state structs are the same, so we
can use a global work struct for it.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
-rw-r--r-- | include/net/netns/xfrm.h | 2 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 18 |
2 files changed, 9 insertions, 11 deletions
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 177ed444d7b2..27bb9633c69d 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
@@ -44,8 +44,6 @@ struct netns_xfrm { | |||
44 | unsigned int state_hmask; | 44 | unsigned int state_hmask; |
45 | unsigned int state_num; | 45 | unsigned int state_num; |
46 | struct work_struct state_hash_work; | 46 | struct work_struct state_hash_work; |
47 | struct hlist_head state_gc_list; | ||
48 | struct work_struct state_gc_work; | ||
49 | 47 | ||
50 | struct list_head policy_all; | 48 | struct list_head policy_all; |
51 | struct hlist_head *policy_byidx; | 49 | struct hlist_head *policy_byidx; |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 1a15b658a79e..ba8bf518ba14 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #define xfrm_state_deref_prot(table, net) \ | 31 | #define xfrm_state_deref_prot(table, net) \ |
32 | rcu_dereference_protected((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock)) | 32 | rcu_dereference_protected((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock)) |
33 | 33 | ||
34 | static void xfrm_state_gc_task(struct work_struct *work); | ||
35 | |||
34 | /* Each xfrm_state may be linked to two tables: | 36 | /* Each xfrm_state may be linked to two tables: |
35 | 37 | ||
36 | 1. Hash table by (spi,daddr,ah/esp) to find SA by SPI. (input,ctl) | 38 | 1. Hash table by (spi,daddr,ah/esp) to find SA by SPI. (input,ctl) |
@@ -41,6 +43,9 @@ | |||
41 | static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024; | 43 | static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024; |
42 | static __read_mostly seqcount_t xfrm_state_hash_generation = SEQCNT_ZERO(xfrm_state_hash_generation); | 44 | static __read_mostly seqcount_t xfrm_state_hash_generation = SEQCNT_ZERO(xfrm_state_hash_generation); |
43 | 45 | ||
46 | static DECLARE_WORK(xfrm_state_gc_work, xfrm_state_gc_task); | ||
47 | static HLIST_HEAD(xfrm_state_gc_list); | ||
48 | |||
44 | static inline bool xfrm_state_hold_rcu(struct xfrm_state __rcu *x) | 49 | static inline bool xfrm_state_hold_rcu(struct xfrm_state __rcu *x) |
45 | { | 50 | { |
46 | return atomic_inc_not_zero(&x->refcnt); | 51 | return atomic_inc_not_zero(&x->refcnt); |
@@ -368,13 +373,12 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) | |||
368 | 373 | ||
369 | static void xfrm_state_gc_task(struct work_struct *work) | 374 | static void xfrm_state_gc_task(struct work_struct *work) |
370 | { | 375 | { |
371 | struct net *net = container_of(work, struct net, xfrm.state_gc_work); | ||
372 | struct xfrm_state *x; | 376 | struct xfrm_state *x; |
373 | struct hlist_node *tmp; | 377 | struct hlist_node *tmp; |
374 | struct hlist_head gc_list; | 378 | struct hlist_head gc_list; |
375 | 379 | ||
376 | spin_lock_bh(&xfrm_state_gc_lock); | 380 | spin_lock_bh(&xfrm_state_gc_lock); |
377 | hlist_move_list(&net->xfrm.state_gc_list, &gc_list); | 381 | hlist_move_list(&xfrm_state_gc_list, &gc_list); |
378 | spin_unlock_bh(&xfrm_state_gc_lock); | 382 | spin_unlock_bh(&xfrm_state_gc_lock); |
379 | 383 | ||
380 | synchronize_rcu(); | 384 | synchronize_rcu(); |
@@ -515,14 +519,12 @@ EXPORT_SYMBOL(xfrm_state_alloc); | |||
515 | 519 | ||
516 | void __xfrm_state_destroy(struct xfrm_state *x) | 520 | void __xfrm_state_destroy(struct xfrm_state *x) |
517 | { | 521 | { |
518 | struct net *net = xs_net(x); | ||
519 | |||
520 | WARN_ON(x->km.state != XFRM_STATE_DEAD); | 522 | WARN_ON(x->km.state != XFRM_STATE_DEAD); |
521 | 523 | ||
522 | spin_lock_bh(&xfrm_state_gc_lock); | 524 | spin_lock_bh(&xfrm_state_gc_lock); |
523 | hlist_add_head(&x->gclist, &net->xfrm.state_gc_list); | 525 | hlist_add_head(&x->gclist, &xfrm_state_gc_list); |
524 | spin_unlock_bh(&xfrm_state_gc_lock); | 526 | spin_unlock_bh(&xfrm_state_gc_lock); |
525 | schedule_work(&net->xfrm.state_gc_work); | 527 | schedule_work(&xfrm_state_gc_work); |
526 | } | 528 | } |
527 | EXPORT_SYMBOL(__xfrm_state_destroy); | 529 | EXPORT_SYMBOL(__xfrm_state_destroy); |
528 | 530 | ||
@@ -2134,8 +2136,6 @@ int __net_init xfrm_state_init(struct net *net) | |||
2134 | 2136 | ||
2135 | net->xfrm.state_num = 0; | 2137 | net->xfrm.state_num = 0; |
2136 | INIT_WORK(&net->xfrm.state_hash_work, xfrm_hash_resize); | 2138 | INIT_WORK(&net->xfrm.state_hash_work, xfrm_hash_resize); |
2137 | INIT_HLIST_HEAD(&net->xfrm.state_gc_list); | ||
2138 | INIT_WORK(&net->xfrm.state_gc_work, xfrm_state_gc_task); | ||
2139 | spin_lock_init(&net->xfrm.xfrm_state_lock); | 2139 | spin_lock_init(&net->xfrm.xfrm_state_lock); |
2140 | return 0; | 2140 | return 0; |
2141 | 2141 | ||
@@ -2153,7 +2153,7 @@ void xfrm_state_fini(struct net *net) | |||
2153 | 2153 | ||
2154 | flush_work(&net->xfrm.state_hash_work); | 2154 | flush_work(&net->xfrm.state_hash_work); |
2155 | xfrm_state_flush(net, IPSEC_PROTO_ANY, false); | 2155 | xfrm_state_flush(net, IPSEC_PROTO_ANY, false); |
2156 | flush_work(&net->xfrm.state_gc_work); | 2156 | flush_work(&xfrm_state_gc_work); |
2157 | 2157 | ||
2158 | WARN_ON(!list_empty(&net->xfrm.state_all)); | 2158 | WARN_ON(!list_empty(&net->xfrm.state_all)); |
2159 | 2159 | ||