Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86a7996c authored by WANG Cong's avatar WANG Cong Committed by David S. Miller
Browse files

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: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f12d33f4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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)
{
+1 −6
Original line number Diff line number Diff line
@@ -1624,13 +1624,8 @@ static int cbq_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
			new->reshape_fail = cbq_reshape_fail;
#endif
	}
	sch_tree_lock(sch);
	*old = cl->q;
	cl->q = new;
	qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
	qdisc_reset(*old);
	sch_tree_unlock(sch);

	*old = qdisc_replace(sch, new, &cl->q);
	return 0;
}

+1 −5
Original line number Diff line number Diff line
@@ -226,11 +226,7 @@ static int drr_graft_class(struct Qdisc *sch, unsigned long arg,
			new = &noop_qdisc;
	}

	sch_tree_lock(sch);
	drr_purge_queue(cl);
	*old = cl->qdisc;
	cl->qdisc = new;
	sch_tree_unlock(sch);
	*old = qdisc_replace(sch, new, &cl->qdisc);
	return 0;
}

+1 −7
Original line number Diff line number Diff line
@@ -73,13 +73,7 @@ static int dsmark_graft(struct Qdisc *sch, unsigned long arg,
			new = &noop_qdisc;
	}

	sch_tree_lock(sch);
	*old = p->q;
	p->q = new;
	qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
	qdisc_reset(*old);
	sch_tree_unlock(sch);

	*old = qdisc_replace(sch, new, &p->q);
	return 0;
}

+1 −5
Original line number Diff line number Diff line
@@ -1215,11 +1215,7 @@ hfsc_graft_class(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
			new = &noop_qdisc;
	}

	sch_tree_lock(sch);
	hfsc_purge_queue(sch, cl);
	*old = cl->qdisc;
	cl->qdisc = new;
	sch_tree_unlock(sch);
	*old = qdisc_replace(sch, new, &cl->qdisc);
	return 0;
}

Loading