@@ -149,7 +149,8 @@ struct tc_action_net {
int tc_action_net_init(struct net *net, struct tc_action_net *tn,
const struct tc_action_ops *ops);
-void tc_action_net_exit(struct list_head *net_list, unsigned int id);
+void tc_action_net_exit_batch_rtnl(struct list_head *net_list,
+ unsigned int id);
int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
struct netlink_callback *cb, int type,
@@ -921,20 +921,19 @@ static void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
idr_destroy(&idrinfo->action_idr);
}
-void tc_action_net_exit(struct list_head *net_list, unsigned int id)
+void tc_action_net_exit_batch_rtnl(struct list_head *net_list, unsigned int id)
{
struct net *net;
- rtnl_lock();
+ ASSERT_RTNL();
list_for_each_entry(net, net_list, exit_list) {
struct tc_action_net *tn = net_generic(net, id);
tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
kfree(tn->idrinfo);
}
- rtnl_unlock();
}
-EXPORT_SYMBOL(tc_action_net_exit);
+EXPORT_SYMBOL(tc_action_net_exit_batch_rtnl);
static LIST_HEAD(act_base);
static DEFINE_RWLOCK(act_mod_lock);
@@ -410,14 +410,15 @@ static __net_init int bpf_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_bpf_ops);
}
-static void __net_exit bpf_exit_net(struct list_head *net_list)
+static void __net_exit bpf_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_bpf_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_bpf_ops.net_id);
}
static struct pernet_operations bpf_net_ops = {
.init = bpf_init_net,
- .exit_batch = bpf_exit_net,
+ .exit_batch_rtnl = bpf_exit_batch_rtnl,
.id = &act_bpf_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -251,14 +251,15 @@ static __net_init int connmark_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_connmark_ops);
}
-static void __net_exit connmark_exit_net(struct list_head *net_list)
+static void __net_exit connmark_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_connmark_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_connmark_ops.net_id);
}
static struct pernet_operations connmark_net_ops = {
.init = connmark_init_net,
- .exit_batch = connmark_exit_net,
+ .exit_batch_rtnl = connmark_exit_batch_rtnl,
.id = &act_connmark_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -718,14 +718,15 @@ static __net_init int csum_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_csum_ops);
}
-static void __net_exit csum_exit_net(struct list_head *net_list)
+static void __net_exit csum_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_csum_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_csum_ops.net_id);
}
static struct pernet_operations csum_net_ops = {
.init = csum_init_net,
- .exit_batch = csum_exit_net,
+ .exit_batch_rtnl = csum_exit_batch_rtnl,
.id = &act_csum_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -1609,14 +1609,15 @@ static __net_init int ct_init_net(struct net *net)
return tc_action_net_init(net, &tn->tn, &act_ct_ops);
}
-static void __net_exit ct_exit_net(struct list_head *net_list)
+static void __net_exit ct_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_ct_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_ct_ops.net_id);
}
static struct pernet_operations ct_net_ops = {
.init = ct_init_net,
- .exit_batch = ct_exit_net,
+ .exit_batch_rtnl = ct_exit_batch_rtnl,
.id = &act_ct_ops.net_id,
.size = sizeof(struct tc_ct_action_net),
};
@@ -372,14 +372,15 @@ static __net_init int ctinfo_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_ctinfo_ops);
}
-static void __net_exit ctinfo_exit_net(struct list_head *net_list)
+static void __net_exit ctinfo_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_ctinfo_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_ctinfo_ops.net_id);
}
static struct pernet_operations ctinfo_net_ops = {
.init = ctinfo_init_net,
- .exit_batch = ctinfo_exit_net,
+ .exit_batch_rtnl = ctinfo_exit_batch_rtnl,
.id = &act_ctinfo_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -305,14 +305,15 @@ static __net_init int gact_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_gact_ops);
}
-static void __net_exit gact_exit_net(struct list_head *net_list)
+static void __net_exit gact_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_gact_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_gact_ops.net_id);
}
static struct pernet_operations gact_net_ops = {
.init = gact_init_net,
- .exit_batch = gact_exit_net,
+ .exit_batch_rtnl = gact_exit_batch_rtnl,
.id = &act_gact_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -654,14 +654,15 @@ static __net_init int gate_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_gate_ops);
}
-static void __net_exit gate_exit_net(struct list_head *net_list)
+static void __net_exit gate_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_gate_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_gate_ops.net_id);
}
static struct pernet_operations gate_net_ops = {
.init = gate_init_net,
- .exit_batch = gate_exit_net,
+ .exit_batch_rtnl = gate_exit_batch_rtnl,
.id = &act_gate_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -898,14 +898,15 @@ static __net_init int ife_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_ife_ops);
}
-static void __net_exit ife_exit_net(struct list_head *net_list)
+static void __net_exit ife_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_ife_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_ife_ops.net_id);
}
static struct pernet_operations ife_net_ops = {
.init = ife_init_net,
- .exit_batch = ife_exit_net,
+ .exit_batch_rtnl = ife_exit_batch_rtnl,
.id = &act_ife_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -652,14 +652,15 @@ static __net_init int mirred_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_mirred_ops);
}
-static void __net_exit mirred_exit_net(struct list_head *net_list)
+static void __net_exit mirred_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *batch_rtnl)
{
- tc_action_net_exit(net_list, act_mirred_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_mirred_ops.net_id);
}
static struct pernet_operations mirred_net_ops = {
.init = mirred_init_net,
- .exit_batch = mirred_exit_net,
+ .exit_batch_rtnl = mirred_exit_batch_rtnl,
.id = &act_mirred_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -461,14 +461,15 @@ static __net_init int mpls_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_mpls_ops);
}
-static void __net_exit mpls_exit_net(struct list_head *net_list)
+static void __net_exit mpls_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_mpls_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_mpls_ops.net_id);
}
static struct pernet_operations mpls_net_ops = {
.init = mpls_init_net,
- .exit_batch = mpls_exit_net,
+ .exit_batch_rtnl = mpls_exit_batch_rtnl,
.id = &act_mpls_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -333,14 +333,15 @@ static __net_init int nat_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_nat_ops);
}
-static void __net_exit nat_exit_net(struct list_head *net_list)
+static void __net_exit nat_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_nat_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_nat_ops.net_id);
}
static struct pernet_operations nat_net_ops = {
.init = nat_init_net,
- .exit_batch = nat_exit_net,
+ .exit_batch_rtnl = nat_exit_batch_rtnl,
.id = &act_nat_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -629,14 +629,15 @@ static __net_init int pedit_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_pedit_ops);
}
-static void __net_exit pedit_exit_net(struct list_head *net_list)
+static void __net_exit pedit_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_pedit_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_pedit_ops.net_id);
}
static struct pernet_operations pedit_net_ops = {
.init = pedit_init_net,
- .exit_batch = pedit_exit_net,
+ .exit_batch_rtnl = pedit_exit_batch_rtnl,
.id = &act_pedit_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -511,14 +511,15 @@ static __net_init int police_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_police_ops);
}
-static void __net_exit police_exit_net(struct list_head *net_list)
+static void __net_exit police_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_police_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_police_ops.net_id);
}
static struct pernet_operations police_net_ops = {
.init = police_init_net,
- .exit_batch = police_exit_net,
+ .exit_batch_rtnl = police_exit_batch_rtnl,
.id = &act_police_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -325,14 +325,15 @@ static __net_init int sample_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_sample_ops);
}
-static void __net_exit sample_exit_net(struct list_head *net_list)
+static void __net_exit sample_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_sample_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_sample_ops.net_id);
}
static struct pernet_operations sample_net_ops = {
.init = sample_init_net,
- .exit_batch = sample_exit_net,
+ .exit_batch_rtnl = sample_exit_batch_rtnl,
.id = &act_sample_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -218,14 +218,15 @@ static __net_init int simp_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_simp_ops);
}
-static void __net_exit simp_exit_net(struct list_head *net_list)
+static void __net_exit simp_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_simp_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_simp_ops.net_id);
}
static struct pernet_operations simp_net_ops = {
.init = simp_init_net,
- .exit_batch = simp_exit_net,
+ .exit_batch_rtnl = simp_exit_batch_rtnl,
.id = &act_simp_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -435,14 +435,15 @@ static __net_init int skbedit_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_skbedit_ops);
}
-static void __net_exit skbedit_exit_net(struct list_head *net_list)
+static void __net_exit skbedit_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_skbedit_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_skbedit_ops.net_id);
}
static struct pernet_operations skbedit_net_ops = {
.init = skbedit_init_net,
- .exit_batch = skbedit_exit_net,
+ .exit_batch_rtnl = skbedit_exit_batch_rtnl,
.id = &act_skbedit_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -296,14 +296,15 @@ static __net_init int skbmod_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_skbmod_ops);
}
-static void __net_exit skbmod_exit_net(struct list_head *net_list)
+static void __net_exit skbmod_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_skbmod_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_skbmod_ops.net_id);
}
static struct pernet_operations skbmod_net_ops = {
.init = skbmod_init_net,
- .exit_batch = skbmod_exit_net,
+ .exit_batch_rtnl = skbmod_exit_batch_rtnl,
.id = &act_skbmod_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -851,14 +851,15 @@ static __net_init int tunnel_key_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_tunnel_key_ops);
}
-static void __net_exit tunnel_key_exit_net(struct list_head *net_list)
+static void __net_exit tunnel_key_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_tunnel_key_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_tunnel_key_ops.net_id);
}
static struct pernet_operations tunnel_key_net_ops = {
.init = tunnel_key_init_net,
- .exit_batch = tunnel_key_exit_net,
+ .exit_batch_rtnl = tunnel_key_exit_batch_rtnl,
.id = &act_tunnel_key_ops.net_id,
.size = sizeof(struct tc_action_net),
};
@@ -436,14 +436,15 @@ static __net_init int vlan_init_net(struct net *net)
return tc_action_net_init(net, tn, &act_vlan_ops);
}
-static void __net_exit vlan_exit_net(struct list_head *net_list)
+static void __net_exit vlan_exit_batch_rtnl(struct list_head *net_list,
+ struct list_head *dev_to_kill)
{
- tc_action_net_exit(net_list, act_vlan_ops.net_id);
+ tc_action_net_exit_batch_rtnl(net_list, act_vlan_ops.net_id);
}
static struct pernet_operations vlan_net_ops = {
.init = vlan_init_net,
- .exit_batch = vlan_exit_net,
+ .exit_batch_rtnl = vlan_exit_batch_rtnl,
.id = &act_vlan_ops.net_id,
.size = sizeof(struct tc_action_net),
};
tc_action_net_exit() is called for each act module, and grabs rtnl each time, making netns dismantles slow. exit_batch_rtnl() is called while RTNL is already held, saving one rtnl_lock()/rtnl_unlock() pair. Rename tc_action_net_exit() to tc_action_net_exit_batch_rtnl() and change all callers. Signed-off-by: Eric Dumazet <edumazet@google.com> --- include/net/act_api.h | 3 ++- net/sched/act_api.c | 7 +++---- net/sched/act_bpf.c | 7 ++++--- net/sched/act_connmark.c | 7 ++++--- net/sched/act_csum.c | 7 ++++--- net/sched/act_ct.c | 7 ++++--- net/sched/act_ctinfo.c | 7 ++++--- net/sched/act_gact.c | 7 ++++--- net/sched/act_gate.c | 7 ++++--- net/sched/act_ife.c | 7 ++++--- net/sched/act_mirred.c | 7 ++++--- net/sched/act_mpls.c | 7 ++++--- net/sched/act_nat.c | 7 ++++--- net/sched/act_pedit.c | 7 ++++--- net/sched/act_police.c | 7 ++++--- net/sched/act_sample.c | 7 ++++--- net/sched/act_simple.c | 7 ++++--- net/sched/act_skbedit.c | 7 ++++--- net/sched/act_skbmod.c | 7 ++++--- net/sched/act_tunnel_key.c | 7 ++++--- net/sched/act_vlan.c | 7 ++++--- 21 files changed, 81 insertions(+), 62 deletions(-)