aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_api.c
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-08-27 05:25:17 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-27 05:25:17 -0400
commitf6f9b93f1624206c802ac9162c9302edaf59bfd9 (patch)
tree643bd211bf909118311138e588a78834fad7a40d /net/sched/sch_api.c
parentf7a54c13c7b072d9426bd5cec1cdb8306df5ef55 (diff)
pkt_sched: Fix gen_estimator locks
While passing a qdisc root lock to gen_new_estimator() and gen_replace_estimator() dev could be deactivated or even before grafting proper root qdisc as qdisc_sleeping (e.g. qdisc_create), so using qdisc_root_lock() is not enough. This patch adds qdisc_root_sleeping_lock() for this, plus additional checks, where necessary. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_api.c')
-rw-r--r--net/sched/sch_api.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index ad9cda1b8c0a..506b709510b6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -830,9 +830,16 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
830 sch->stab = stab; 830 sch->stab = stab;
831 } 831 }
832 if (tca[TCA_RATE]) { 832 if (tca[TCA_RATE]) {
833 spinlock_t *root_lock;
834
835 if ((sch->parent != TC_H_ROOT) &&
836 !(sch->flags & TCQ_F_INGRESS))
837 root_lock = qdisc_root_sleeping_lock(sch);
838 else
839 root_lock = qdisc_lock(sch);
840
833 err = gen_new_estimator(&sch->bstats, &sch->rate_est, 841 err = gen_new_estimator(&sch->bstats, &sch->rate_est,
834 qdisc_root_lock(sch), 842 root_lock, tca[TCA_RATE]);
835 tca[TCA_RATE]);
836 if (err) { 843 if (err) {
837 /* 844 /*
838 * Any broken qdiscs that would require 845 * Any broken qdiscs that would require
@@ -884,7 +891,8 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca)
884 891
885 if (tca[TCA_RATE]) 892 if (tca[TCA_RATE])
886 gen_replace_estimator(&sch->bstats, &sch->rate_est, 893 gen_replace_estimator(&sch->bstats, &sch->rate_est,
887 qdisc_root_lock(sch), tca[TCA_RATE]); 894 qdisc_root_sleeping_lock(sch),
895 tca[TCA_RATE]);
888 return 0; 896 return 0;
889} 897}
890 898