Revert "net: xfrm: Localize sequence counter per network namespace"
This reverts commit 0224432a8f
as it
breaks the abi and we can't allow that at this point in time.
Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I21e6c33ac7011d8489e766fd9b5e32bd528dc456
This commit is contained in:
@@ -72,9 +72,7 @@ struct netns_xfrm {
|
|||||||
#if IS_ENABLED(CONFIG_IPV6)
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
struct dst_ops xfrm6_dst_ops;
|
struct dst_ops xfrm6_dst_ops;
|
||||||
#endif
|
#endif
|
||||||
spinlock_t xfrm_state_lock;
|
spinlock_t xfrm_state_lock;
|
||||||
seqcount_t xfrm_state_hash_generation;
|
|
||||||
|
|
||||||
spinlock_t xfrm_policy_lock;
|
spinlock_t xfrm_policy_lock;
|
||||||
struct mutex xfrm_cfg_mutex;
|
struct mutex xfrm_cfg_mutex;
|
||||||
};
|
};
|
||||||
|
@@ -44,6 +44,7 @@ static void xfrm_state_gc_task(struct work_struct *work);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024;
|
static unsigned int xfrm_state_hashmax __read_mostly = 1 * 1024 * 1024;
|
||||||
|
static __read_mostly seqcount_t xfrm_state_hash_generation = SEQCNT_ZERO(xfrm_state_hash_generation);
|
||||||
static struct kmem_cache *xfrm_state_cache __ro_after_init;
|
static struct kmem_cache *xfrm_state_cache __ro_after_init;
|
||||||
|
|
||||||
static DECLARE_WORK(xfrm_state_gc_work, xfrm_state_gc_task);
|
static DECLARE_WORK(xfrm_state_gc_work, xfrm_state_gc_task);
|
||||||
@@ -139,7 +140,7 @@ static void xfrm_hash_resize(struct work_struct *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_bh(&net->xfrm.xfrm_state_lock);
|
spin_lock_bh(&net->xfrm.xfrm_state_lock);
|
||||||
write_seqcount_begin(&net->xfrm.xfrm_state_hash_generation);
|
write_seqcount_begin(&xfrm_state_hash_generation);
|
||||||
|
|
||||||
nhashmask = (nsize / sizeof(struct hlist_head)) - 1U;
|
nhashmask = (nsize / sizeof(struct hlist_head)) - 1U;
|
||||||
odst = xfrm_state_deref_prot(net->xfrm.state_bydst, net);
|
odst = xfrm_state_deref_prot(net->xfrm.state_bydst, net);
|
||||||
@@ -155,7 +156,7 @@ static void xfrm_hash_resize(struct work_struct *work)
|
|||||||
rcu_assign_pointer(net->xfrm.state_byspi, nspi);
|
rcu_assign_pointer(net->xfrm.state_byspi, nspi);
|
||||||
net->xfrm.state_hmask = nhashmask;
|
net->xfrm.state_hmask = nhashmask;
|
||||||
|
|
||||||
write_seqcount_end(&net->xfrm.xfrm_state_hash_generation);
|
write_seqcount_end(&xfrm_state_hash_generation);
|
||||||
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
|
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
|
||||||
|
|
||||||
osize = (ohashmask + 1) * sizeof(struct hlist_head);
|
osize = (ohashmask + 1) * sizeof(struct hlist_head);
|
||||||
@@ -1060,7 +1061,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
|
|||||||
|
|
||||||
to_put = NULL;
|
to_put = NULL;
|
||||||
|
|
||||||
sequence = read_seqcount_begin(&net->xfrm.xfrm_state_hash_generation);
|
sequence = read_seqcount_begin(&xfrm_state_hash_generation);
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family);
|
h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family);
|
||||||
@@ -1173,7 +1174,7 @@ out:
|
|||||||
if (to_put)
|
if (to_put)
|
||||||
xfrm_state_put(to_put);
|
xfrm_state_put(to_put);
|
||||||
|
|
||||||
if (read_seqcount_retry(&net->xfrm.xfrm_state_hash_generation, sequence)) {
|
if (read_seqcount_retry(&xfrm_state_hash_generation, sequence)) {
|
||||||
*err = -EAGAIN;
|
*err = -EAGAIN;
|
||||||
if (x) {
|
if (x) {
|
||||||
xfrm_state_put(x);
|
xfrm_state_put(x);
|
||||||
@@ -2666,7 +2667,6 @@ int __net_init xfrm_state_init(struct net *net)
|
|||||||
net->xfrm.state_num = 0;
|
net->xfrm.state_num = 0;
|
||||||
INIT_WORK(&net->xfrm.state_hash_work, xfrm_hash_resize);
|
INIT_WORK(&net->xfrm.state_hash_work, xfrm_hash_resize);
|
||||||
spin_lock_init(&net->xfrm.xfrm_state_lock);
|
spin_lock_init(&net->xfrm.xfrm_state_lock);
|
||||||
seqcount_init(&net->xfrm.xfrm_state_hash_generation);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_byspi:
|
out_byspi:
|
||||||
|
Reference in New Issue
Block a user