Skip to contentSkip to conversation

netem: update backlog after drop

PATCH Applied Stephen Hemminger 3 participants 6 messages Oct 9, 2013 – Oct 11, 2013

Subsystems (4)
lore
Share & tools
lore

Stephen Hemminger

author maintainer
#0 lore raw

PATCH 1/1 netem: update backlog after drop

When packet is dropped from rb-tree netem the backlog statistic should also be updated.

---
Should be reviewed by Eric (he added the rb-tree stuff), and added to stable as well.

net/sched/sch_netem.c +1 -0
@@ -520,6 +520,7 @@ static unsigned int netem_drop(struct Qd
 			skb->next = NULL;
 			skb->prev = NULL;
 			len = qdisc_pkt_len(skb);
+			sch->qstats.backlog -= len;
 			kfree_skb(skb);
 		}
 	}
author maintainer
#1 lore raw

Re: [PATCH net] netem: free skb's in tree on reset

Netem can leak memory because packets get stored in red-black tree and it is not cleared on reset.

Reported by: Сергеев Сергей <[email protected]>

net/sched/sch_netem.c +16 -0
@@ -358,6 +358,21 @@ static psched_time_t packet_len_2_sched_
 	return PSCHED_NS2TICKS(ticks);
 }
 
+static void tfifo_reset(struct Qdisc *sch)
+{
+	struct netem_sched_data *q = qdisc_priv(sch);
+	struct rb_node *p;
+
+	while ((p = rb_first(&q->t_root)) {
+		struct sk_buff *skb = netem_rb_to_skb(p);
+
+		rb_erase(p, &q->t_root);
+		skb->next = NULL;
+		skb->prev = NULL;
+		kfree_skb(skb);
+	}
+}
+
 static void tfifo_enqueue(struct sk_buff *nskb, struct Qdisc *sch)
 {
 	struct netem_sched_data *q = qdisc_priv(sch);
@@ -610,6 +625,7 @@ static void netem_reset(struct Qdisc *sc
 	struct netem_sched_data *q = qdisc_priv(sch);
 
 	qdisc_reset_queue(sch);
+	tfifo_reset(sch);
 	if (q->qdisc)
 		qdisc_reset(q->qdisc);
 	qdisc_watchdog_cancel(&q->watchdog);
maintainer
#3 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Sun, 6 Oct 2013 15:15:33 -0700

Quoted 9 lines

When packet is dropped from rb-tree netem the backlog statistic should also be updated.

---
Should be reviewed by Eric (he added the rb-tree stuff), and added to stable as well.

Eric please review this patch, thanks.

Acked-by
#4 lore raw
Quoted 6 lines · David Miller

From: Stephen Hemminger <[email protected]>
Date: Sun, 6 Oct 2013 15:15:33 -0700

Quoted 3 lines

When packet is dropped from rb-tree netem the backlog statistic should also be updated.

Quoted 8 lines
Quoted 6 lines

---
Should be reviewed by Eric (he added the rb-tree stuff), and added to stable as well.

Eric please review this patch, thanks.

It somehow escaped from my radar ;)