summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2016-02-25 14:55:00 -0800
committerBen Hutchings <ben@decadent.org.uk>2016-08-22 22:38:15 +0100
commitf2610da0605227b7fc4d6ffd499fa3c7ef16644e (patch)
treee611571ae96cd0be1ba77508831853f3ec4b76c3 /include/net
parent4fecee0b8e513a4b3a05a3c07f5f1f487e1f361b (diff)
downloadlinux-stable-f2610da0605227b7fc4d6ffd499fa3c7ef16644e.tar.gz
linux-stable-f2610da0605227b7fc4d6ffd499fa3c7ef16644e.tar.bz2
linux-stable-f2610da0605227b7fc4d6ffd499fa3c7ef16644e.zip
net_sched: introduce qdisc_replace() helper
commit 86a7996cc8a078793670d82ed97d5a99bb4e8496 upstream. Remove nearly duplicated code and prepare for the following patch. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sch_generic.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 624f9857c83e..15fa8edb9228 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -608,6 +608,23 @@ static inline void qdisc_reset_queue(struct Qdisc *sch)
sch->qstats.backlog = 0;
}
+static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
+ struct Qdisc **pold)
+{
+ struct Qdisc *old;
+
+ sch_tree_lock(sch);
+ old = *pold;
+ *pold = new;
+ if (old != NULL) {
+ qdisc_tree_decrease_qlen(old, old->q.qlen);
+ qdisc_reset(old);
+ }
+ sch_tree_unlock(sch);
+
+ return old;
+}
+
static inline unsigned int __qdisc_queue_drop(struct Qdisc *sch,
struct sk_buff_head *list)
{