net_sched: introduce qdisc_replace() helper
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>
This commit is contained in:

committed by
David S. Miller

parent
f12d33f4d8
commit
86a7996cc8
@@ -707,6 +707,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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user