Browse Source

net: sched: act_police: remove dependency on rtnl lock

Use tcf spinlock to protect police action private data from concurrent
modification during dump. (init already uses tcf spinlock when changing
police action state)

Pass tcf spinlock as estimator lock argument to gen_replace_estimator()
during action init.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Vlad Buslov 7 years ago
parent
commit
e329bc4273
1 changed files with 6 additions and 3 deletions
  1. 6 3
      net/sched/act_police.c

+ 6 - 3
net/sched/act_police.c

@@ -274,14 +274,15 @@ static int tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a,
 	struct tcf_police *police = to_police(a);
 	struct tcf_police *police = to_police(a);
 	struct tc_police opt = {
 	struct tc_police opt = {
 		.index = police->tcf_index,
 		.index = police->tcf_index,
-		.action = police->tcf_action,
-		.mtu = police->tcfp_mtu,
-		.burst = PSCHED_NS2TICKS(police->tcfp_burst),
 		.refcnt = refcount_read(&police->tcf_refcnt) - ref,
 		.refcnt = refcount_read(&police->tcf_refcnt) - ref,
 		.bindcnt = atomic_read(&police->tcf_bindcnt) - bind,
 		.bindcnt = atomic_read(&police->tcf_bindcnt) - bind,
 	};
 	};
 	struct tcf_t t;
 	struct tcf_t t;
 
 
+	spin_lock_bh(&police->tcf_lock);
+	opt.action = police->tcf_action;
+	opt.mtu = police->tcfp_mtu;
+	opt.burst = PSCHED_NS2TICKS(police->tcfp_burst);
 	if (police->rate_present)
 	if (police->rate_present)
 		psched_ratecfg_getrate(&opt.rate, &police->rate);
 		psched_ratecfg_getrate(&opt.rate, &police->rate);
 	if (police->peak_present)
 	if (police->peak_present)
@@ -301,10 +302,12 @@ static int tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a,
 	t.expires = jiffies_to_clock_t(police->tcf_tm.expires);
 	t.expires = jiffies_to_clock_t(police->tcf_tm.expires);
 	if (nla_put_64bit(skb, TCA_POLICE_TM, sizeof(t), &t, TCA_POLICE_PAD))
 	if (nla_put_64bit(skb, TCA_POLICE_TM, sizeof(t), &t, TCA_POLICE_PAD))
 		goto nla_put_failure;
 		goto nla_put_failure;
+	spin_unlock_bh(&police->tcf_lock);
 
 
 	return skb->len;
 	return skb->len;
 
 
 nla_put_failure:
 nla_put_failure:
+	spin_unlock_bh(&police->tcf_lock);
 	nlmsg_trim(skb, b);
 	nlmsg_trim(skb, b);
 	return -1;
 	return -1;
 }
 }