netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [NET_SCHED 07/06]: Fix endless loops (part 5): netem/tbf/hfsc ->requeue failures
@ 2006-11-20 15:01 Patrick McHardy
  2006-11-20 18:08 ` Stephen Hemminger
  2006-11-30  1:37 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick McHardy @ 2006-11-20 15:01 UTC (permalink / raw)
  To: David S. Miller; +Cc: Stephen Hemminger, Linux Netdev List

[-- Attachment #1: Type: text/plain, Size: 57 bytes --]

I forgot to fix one (AFAICT purely theoretical) case ..


[-- Attachment #2: 07.diff --]
[-- Type: text/plain, Size: 2403 bytes --]

[NET_SCHED]: Fix endless loops (part 5): netem/tbf/hfsc ->requeue failures

When peeking at the next packet in a child qdisc by calling dequeue/requeue,
the upper qdisc qlen counter may get out of sync in case the requeue fails.
The qdisc and the child qdisc both have their counter decremented, but since
no packet is given to the upper qdisc it won't decrement its counter itself.

requeue should not fail, so this is mostly for "correctness".

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit 929cc41d7993cf356bcf1693c924e016df55a6a9
tree 8d0017e51e6285b4d584864e564e4d4512463b99
parent cc6f4de81d666f76192bee629473ff6fbd66286c
author Patrick McHardy <kaber@trash.net> Mon, 20 Nov 2006 15:59:14 +0100
committer Patrick McHardy <kaber@trash.net> Mon, 20 Nov 2006 15:59:14 +0100

 net/sched/sch_hfsc.c  |    1 +
 net/sched/sch_netem.c |    5 +----
 net/sched/sch_tbf.c   |    2 +-
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 2d43744..6eefa69 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -946,6 +946,7 @@ qdisc_peek_len(struct Qdisc *sch)
 	if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) {
 		if (net_ratelimit())
 			printk("qdisc_peek_len: failed to requeue\n");
+		qdisc_tree_decrease_qlen(sch, 1);
 		return 0;
 	}
 	return len;
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 672c354..79542af 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -287,13 +287,10 @@ static struct sk_buff *netem_dequeue(str
 			psched_tdiff_t delay = PSCHED_TDIFF(cb->time_to_send, now);
 
 			if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
+				qdisc_tree_decrease_qlen(q->qdisc, 1);
 				sch->qstats.drops++;
-
-				/* After this qlen is confused */
 				printk(KERN_ERR "netem: queue discpline %s could not requeue\n",
 				       q->qdisc->ops->id);
-
-				sch->q.qlen--;
 			}
 
 			mod_timer(&q->timer, jiffies + PSCHED_US2JIFFIE(delay));
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 23b7624..ed9b6d9 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -250,7 +250,7 @@ static struct sk_buff *tbf_dequeue(struc
 
 		if (q->qdisc->ops->requeue(skb, q->qdisc) != NET_XMIT_SUCCESS) {
 			/* When requeue fails skb is dropped */
-			sch->q.qlen--;
+			qdisc_tree_decrease_qlen(q->qdisc, 1);
 			sch->qstats.drops++;
 		}
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-30  1:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-20 15:01 [NET_SCHED 07/06]: Fix endless loops (part 5): netem/tbf/hfsc ->requeue failures Patrick McHardy
2006-11-20 18:08 ` Stephen Hemminger
2006-11-30  1:37 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).