aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-03-12 00:04:08 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-12 14:39:40 -0400
commitefd7ef1c1929d7a0329d4349252863c04d6f1729 (patch)
tree66a1d5ba57a27fda7665da756551c10ac0ebf656 /net
parent6c7005f6cb1bf63bb1f505ef69364fb2cc00628e (diff)
net: Kill hold_net release_net
hold_net and release_net were an idea that turned out to be useless. The code has been disabled since 2008. Kill the code it is long past due. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/fib_rules.c17
-rw-r--r--net/core/neighbour.c9
-rw-r--r--net/core/net_namespace.c11
-rw-r--r--net/core/sock.c1
-rw-r--r--net/ipv4/fib_semantics.c3
-rw-r--r--net/ipv4/inet_hashtables.c3
-rw-r--r--net/ipv4/inet_timewait_sock.c3
-rw-r--r--net/ipv6/addrlabel.c5
-rw-r--r--net/ipv6/ip6_flowlabel.c3
-rw-r--r--net/openvswitch/datapath.c4
11 files changed, 11 insertions, 50 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 962ee9d71964..39fe369b46ad 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6841,8 +6841,6 @@ void free_netdev(struct net_device *dev)
6841{ 6841{
6842 struct napi_struct *p, *n; 6842 struct napi_struct *p, *n;
6843 6843
6844 release_net(dev_net(dev));
6845
6846 netif_free_tx_queues(dev); 6844 netif_free_tx_queues(dev);
6847#ifdef CONFIG_SYSFS 6845#ifdef CONFIG_SYSFS
6848 kvfree(dev->_rx); 6846 kvfree(dev->_rx);
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index b55677fed1c8..68ea6950cad1 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -31,7 +31,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
31 r->pref = pref; 31 r->pref = pref;
32 r->table = table; 32 r->table = table;
33 r->flags = flags; 33 r->flags = flags;
34 r->fr_net = hold_net(ops->fro_net); 34 r->fr_net = ops->fro_net;
35 35
36 r->suppress_prefixlen = -1; 36 r->suppress_prefixlen = -1;
37 r->suppress_ifgroup = -1; 37 r->suppress_ifgroup = -1;
@@ -116,7 +116,6 @@ static int __fib_rules_register(struct fib_rules_ops *ops)
116 if (ops->family == o->family) 116 if (ops->family == o->family)
117 goto errout; 117 goto errout;
118 118
119 hold_net(net);
120 list_add_tail_rcu(&ops->list, &net->rules_ops); 119 list_add_tail_rcu(&ops->list, &net->rules_ops);
121 err = 0; 120 err = 0;
122errout: 121errout:
@@ -160,15 +159,6 @@ static void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
160 } 159 }
161} 160}
162 161
163static void fib_rules_put_rcu(struct rcu_head *head)
164{
165 struct fib_rules_ops *ops = container_of(head, struct fib_rules_ops, rcu);
166 struct net *net = ops->fro_net;
167
168 release_net(net);
169 kfree(ops);
170}
171
172void fib_rules_unregister(struct fib_rules_ops *ops) 162void fib_rules_unregister(struct fib_rules_ops *ops)
173{ 163{
174 struct net *net = ops->fro_net; 164 struct net *net = ops->fro_net;
@@ -178,7 +168,7 @@ void fib_rules_unregister(struct fib_rules_ops *ops)
178 fib_rules_cleanup_ops(ops); 168 fib_rules_cleanup_ops(ops);
179 spin_unlock(&net->rules_mod_lock); 169 spin_unlock(&net->rules_mod_lock);
180 170
181 call_rcu(&ops->rcu, fib_rules_put_rcu); 171 kfree_rcu(ops, rcu);
182} 172}
183EXPORT_SYMBOL_GPL(fib_rules_unregister); 173EXPORT_SYMBOL_GPL(fib_rules_unregister);
184 174
@@ -303,7 +293,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
303 err = -ENOMEM; 293 err = -ENOMEM;
304 goto errout; 294 goto errout;
305 } 295 }
306 rule->fr_net = hold_net(net); 296 rule->fr_net = net;
307 297
308 if (tb[FRA_PRIORITY]) 298 if (tb[FRA_PRIORITY])
309 rule->pref = nla_get_u32(tb[FRA_PRIORITY]); 299 rule->pref = nla_get_u32(tb[FRA_PRIORITY]);
@@ -423,7 +413,6 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
423 return 0; 413 return 0;
424 414
425errout_free: 415errout_free:
426 release_net(rule->fr_net);
427 kfree(rule); 416 kfree(rule);
428errout: 417errout:
429 rules_ops_put(ops); 418 rules_ops_put(ops);
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ad07990e943d..0e8b32efc031 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -591,7 +591,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
591 if (!n) 591 if (!n)
592 goto out; 592 goto out;
593 593
594 write_pnet(&n->net, hold_net(net)); 594 write_pnet(&n->net, net);
595 memcpy(n->key, pkey, key_len); 595 memcpy(n->key, pkey, key_len);
596 n->dev = dev; 596 n->dev = dev;
597 if (dev) 597 if (dev)
@@ -600,7 +600,6 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
600 if (tbl->pconstructor && tbl->pconstructor(n)) { 600 if (tbl->pconstructor && tbl->pconstructor(n)) {
601 if (dev) 601 if (dev)
602 dev_put(dev); 602 dev_put(dev);
603 release_net(net);
604 kfree(n); 603 kfree(n);
605 n = NULL; 604 n = NULL;
606 goto out; 605 goto out;
@@ -634,7 +633,6 @@ int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *pkey,
634 tbl->pdestructor(n); 633 tbl->pdestructor(n);
635 if (n->dev) 634 if (n->dev)
636 dev_put(n->dev); 635 dev_put(n->dev);
637 release_net(pneigh_net(n));
638 kfree(n); 636 kfree(n);
639 return 0; 637 return 0;
640 } 638 }
@@ -657,7 +655,6 @@ static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev)
657 tbl->pdestructor(n); 655 tbl->pdestructor(n);
658 if (n->dev) 656 if (n->dev)
659 dev_put(n->dev); 657 dev_put(n->dev);
660 release_net(pneigh_net(n));
661 kfree(n); 658 kfree(n);
662 continue; 659 continue;
663 } 660 }
@@ -1428,11 +1425,10 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1428 neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); 1425 neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME));
1429 dev_hold(dev); 1426 dev_hold(dev);
1430 p->dev = dev; 1427 p->dev = dev;
1431 write_pnet(&p->net, hold_net(net)); 1428 write_pnet(&p->net, net);
1432 p->sysctl_table = NULL; 1429 p->sysctl_table = NULL;
1433 1430
1434 if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) { 1431 if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
1435 release_net(net);
1436 dev_put(dev); 1432 dev_put(dev);
1437 kfree(p); 1433 kfree(p);
1438 return NULL; 1434 return NULL;
@@ -1472,7 +1468,6 @@ EXPORT_SYMBOL(neigh_parms_release);
1472 1468
1473static void neigh_parms_destroy(struct neigh_parms *parms) 1469static void neigh_parms_destroy(struct neigh_parms *parms)
1474{ 1470{
1475 release_net(neigh_parms_net(parms));
1476 kfree(parms); 1471 kfree(parms);
1477} 1472}
1478 1473
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index cb5290b8c428..e5e96b0f6717 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -236,10 +236,6 @@ static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
236 net->user_ns = user_ns; 236 net->user_ns = user_ns;
237 idr_init(&net->netns_ids); 237 idr_init(&net->netns_ids);
238 238
239#ifdef NETNS_REFCNT_DEBUG
240 atomic_set(&net->use_count, 0);
241#endif
242
243 list_for_each_entry(ops, &pernet_list, list) { 239 list_for_each_entry(ops, &pernet_list, list) {
244 error = ops_init(ops, net); 240 error = ops_init(ops, net);
245 if (error < 0) 241 if (error < 0)
@@ -294,13 +290,6 @@ out_free:
294 290
295static void net_free(struct net *net) 291static void net_free(struct net *net)
296{ 292{
297#ifdef NETNS_REFCNT_DEBUG
298 if (unlikely(atomic_read(&net->use_count) != 0)) {
299 pr_emerg("network namespace not free! Usage: %d\n",
300 atomic_read(&net->use_count));
301 return;
302 }
303#endif
304 kfree(rcu_access_pointer(net->gen)); 293 kfree(rcu_access_pointer(net->gen));
305 kmem_cache_free(net_cachep, net); 294 kmem_cache_free(net_cachep, net);
306} 295}
diff --git a/net/core/sock.c b/net/core/sock.c
index a9a9c2ff9260..c8842f279f7a 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1455,7 +1455,6 @@ void sk_release_kernel(struct sock *sk)
1455 1455
1456 sock_hold(sk); 1456 sock_hold(sk);
1457 sock_release(sk->sk_socket); 1457 sock_release(sk->sk_socket);
1458 release_net(sock_net(sk));
1459 sock_net_set(sk, get_net(&init_net)); 1458 sock_net_set(sk, get_net(&init_net));
1460 sock_put(sk); 1459 sock_put(sk);
1461} 1460}
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index c6d267442dac..66c1e4fbf884 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -213,7 +213,6 @@ static void free_fib_info_rcu(struct rcu_head *head)
213 rt_fibinfo_free(&nexthop_nh->nh_rth_input); 213 rt_fibinfo_free(&nexthop_nh->nh_rth_input);
214 } endfor_nexthops(fi); 214 } endfor_nexthops(fi);
215 215
216 release_net(fi->fib_net);
217 if (fi->fib_metrics != (u32 *) dst_default_metrics) 216 if (fi->fib_metrics != (u32 *) dst_default_metrics)
218 kfree(fi->fib_metrics); 217 kfree(fi->fib_metrics);
219 kfree(fi); 218 kfree(fi);
@@ -814,7 +813,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
814 } else 813 } else
815 fi->fib_metrics = (u32 *) dst_default_metrics; 814 fi->fib_metrics = (u32 *) dst_default_metrics;
816 815
817 fi->fib_net = hold_net(net); 816 fi->fib_net = net;
818 fi->fib_protocol = cfg->fc_protocol; 817 fi->fib_protocol = cfg->fc_protocol;
819 fi->fib_scope = cfg->fc_scope; 818 fi->fib_scope = cfg->fc_scope;
820 fi->fib_flags = cfg->fc_flags; 819 fi->fib_flags = cfg->fc_flags;
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 9111a4e22155..f6a12b97d12b 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -61,7 +61,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
61 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC); 61 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
62 62
63 if (tb != NULL) { 63 if (tb != NULL) {
64 write_pnet(&tb->ib_net, hold_net(net)); 64 write_pnet(&tb->ib_net, net);
65 tb->port = snum; 65 tb->port = snum;
66 tb->fastreuse = 0; 66 tb->fastreuse = 0;
67 tb->fastreuseport = 0; 67 tb->fastreuseport = 0;
@@ -79,7 +79,6 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket
79{ 79{
80 if (hlist_empty(&tb->owners)) { 80 if (hlist_empty(&tb->owners)) {
81 __hlist_del(&tb->node); 81 __hlist_del(&tb->node);
82 release_net(ib_net(tb));
83 kmem_cache_free(cachep, tb); 82 kmem_cache_free(cachep, tb);
84 } 83 }
85} 84}
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 2bd980526631..86ebf020925b 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -98,7 +98,6 @@ void inet_twsk_free(struct inet_timewait_sock *tw)
98#ifdef SOCK_REFCNT_DEBUG 98#ifdef SOCK_REFCNT_DEBUG
99 pr_debug("%s timewait_sock %p released\n", tw->tw_prot->name, tw); 99 pr_debug("%s timewait_sock %p released\n", tw->tw_prot->name, tw);
100#endif 100#endif
101 release_net(twsk_net(tw));
102 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); 101 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
103 module_put(owner); 102 module_put(owner);
104} 103}
@@ -196,7 +195,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
196 tw->tw_transparent = inet->transparent; 195 tw->tw_transparent = inet->transparent;
197 tw->tw_prot = sk->sk_prot_creator; 196 tw->tw_prot = sk->sk_prot_creator;
198 atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie)); 197 atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
199 twsk_net_set(tw, hold_net(sock_net(sk))); 198 twsk_net_set(tw, sock_net(sk));
200 /* 199 /*
201 * Because we use RCU lookups, we should not set tw_refcnt 200 * Because we use RCU lookups, we should not set tw_refcnt
202 * to a non null value before everything is setup for this 201 * to a non null value before everything is setup for this
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index e43e79d0a612..59c793040498 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -129,9 +129,6 @@ static const __net_initconst struct ip6addrlbl_init_table
129/* Object management */ 129/* Object management */
130static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p) 130static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p)
131{ 131{
132#ifdef CONFIG_NET_NS
133 release_net(p->lbl_net);
134#endif
135 kfree(p); 132 kfree(p);
136} 133}
137 134
@@ -241,7 +238,7 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(struct net *net,
241 newp->label = label; 238 newp->label = label;
242 INIT_HLIST_NODE(&newp->list); 239 INIT_HLIST_NODE(&newp->list);
243#ifdef CONFIG_NET_NS 240#ifdef CONFIG_NET_NS
244 newp->lbl_net = hold_net(net); 241 newp->lbl_net = net;
245#endif 242#endif
246 atomic_set(&newp->refcnt, 1); 243 atomic_set(&newp->refcnt, 1);
247 return newp; 244 return newp;
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index f45d6db50a45..457303886fd4 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -100,7 +100,6 @@ static void fl_free(struct ip6_flowlabel *fl)
100 if (fl) { 100 if (fl) {
101 if (fl->share == IPV6_FL_S_PROCESS) 101 if (fl->share == IPV6_FL_S_PROCESS)
102 put_pid(fl->owner.pid); 102 put_pid(fl->owner.pid);
103 release_net(fl->fl_net);
104 kfree(fl->opt); 103 kfree(fl->opt);
105 kfree_rcu(fl, rcu); 104 kfree_rcu(fl, rcu);
106 } 105 }
@@ -403,7 +402,7 @@ fl_create(struct net *net, struct sock *sk, struct in6_flowlabel_req *freq,
403 } 402 }
404 } 403 }
405 404
406 fl->fl_net = hold_net(net); 405 fl->fl_net = net;
407 fl->expires = jiffies; 406 fl->expires = jiffies;
408 err = fl6_renew(fl, freq->flr_linger, freq->flr_expires); 407 err = fl6_renew(fl, freq->flr_linger, freq->flr_expires);
409 if (err) 408 if (err)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 5bae7243c577..096c6276e6b9 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -203,7 +203,6 @@ static void destroy_dp_rcu(struct rcu_head *rcu)
203 203
204 ovs_flow_tbl_destroy(&dp->table); 204 ovs_flow_tbl_destroy(&dp->table);
205 free_percpu(dp->stats_percpu); 205 free_percpu(dp->stats_percpu);
206 release_net(ovs_dp_get_net(dp));
207 kfree(dp->ports); 206 kfree(dp->ports);
208 kfree(dp); 207 kfree(dp);
209} 208}
@@ -1501,7 +1500,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
1501 if (dp == NULL) 1500 if (dp == NULL)
1502 goto err_free_reply; 1501 goto err_free_reply;
1503 1502
1504 ovs_dp_set_net(dp, hold_net(sock_net(skb->sk))); 1503 ovs_dp_set_net(dp, sock_net(skb->sk));
1505 1504
1506 /* Allocate table. */ 1505 /* Allocate table. */
1507 err = ovs_flow_tbl_init(&dp->table); 1506 err = ovs_flow_tbl_init(&dp->table);
@@ -1575,7 +1574,6 @@ err_destroy_percpu:
1575err_destroy_table: 1574err_destroy_table:
1576 ovs_flow_tbl_destroy(&dp->table); 1575 ovs_flow_tbl_destroy(&dp->table);
1577err_free_dp: 1576err_free_dp:
1578 release_net(ovs_dp_get_net(dp));
1579 kfree(dp); 1577 kfree(dp);
1580err_free_reply: 1578err_free_reply:
1581 kfree_skb(reply); 1579 kfree_skb(reply);