diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2016-12-02 04:12:58 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-03 15:59:58 -0500 |
commit | 9bfc7b9969dbb800460e2577f1dea59336269ce4 (patch) | |
tree | 2fd83542f48b3aeb62c29035f08fa8019090e8df | |
parent | 1a9a059203299ed42b984e91b87086bafeea36c6 (diff) | |
download | linux-stable-9bfc7b9969dbb800460e2577f1dea59336269ce4.tar.gz linux-stable-9bfc7b9969dbb800460e2577f1dea59336269ce4.tar.bz2 linux-stable-9bfc7b9969dbb800460e2577f1dea59336269ce4.zip |
netns: add dummy struct inside "struct net_generic"
This is precursor to fixing "[id - 1]" bloat inside net_generic().
Name "s" is chosen to complement name "u" often used for dummy unions.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/netns/generic.h | 6 | ||||
-rw-r--r-- | net/core/net_namespace.c | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h index d315786bcfd7..65ccce69b040 100644 --- a/include/net/netns/generic.h +++ b/include/net/netns/generic.h @@ -25,8 +25,10 @@ */ struct net_generic { - unsigned int len; - struct rcu_head rcu; + struct { + unsigned int len; + struct rcu_head rcu; + } s; void *ptr[0]; }; diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 707b3c25cb80..55e28a8d0604 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -50,7 +50,7 @@ static struct net_generic *net_alloc_generic(void) ng = kzalloc(generic_size, GFP_KERNEL); if (ng) - ng->len = max_gen_ptrs; + ng->s.len = max_gen_ptrs; return ng; } @@ -64,7 +64,7 @@ static int net_assign_generic(struct net *net, unsigned int id, void *data) old_ng = rcu_dereference_protected(net->gen, lockdep_is_held(&net_mutex)); - if (old_ng->len >= id) { + if (old_ng->s.len >= id) { old_ng->ptr[id - 1] = data; return 0; } @@ -84,11 +84,11 @@ static int net_assign_generic(struct net *net, unsigned int id, void *data) * the old copy for kfree after a grace period. */ - memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*)); + memcpy(&ng->ptr, &old_ng->ptr, old_ng->s.len * sizeof(void*)); ng->ptr[id - 1] = data; rcu_assign_pointer(net->gen, ng); - kfree_rcu(old_ng, rcu); + kfree_rcu(old_ng, s.rcu); return 0; } |