Skip to contentSkip to conversation

TBF: stop qdisc infanticide

PATCH In review Stephen Hemminger 2 participants 5 messages May 13, 2010 – May 15, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 TBF: stop qdisc infanticide

Several netem users have complained that when using TBF for rate control that any change to TBF parameters destroys the child qdisc. A typical use is to have a test that sets up netem + TBF then changes bandwidth setting. But every time the parameters of TBF are changed it destroys the child qdisc, requiring reconfiguration. Other qdisc's like HTB don't do this.

net/sched/sch_tbf.c +5 -1
@@ -273,7 +273,11 @@ static int tbf_change(struct Qdisc* sch,
 	if (max_size < 0)
 		goto done;
 
-	if (qopt->limit > 0) {
+	if (q->qdisc) {
+		err = fifo_set_limit(q->qdisc, qopt->limit);
+		if (err)
+			goto done;
+	} else if (qopt->limit > 0) {
 		child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
 		if (IS_ERR(child)) {
 			err = PTR_ERR(child);
#1 lore raw
Quoted 13 lines · Stephen Hemminger

Several netem users have complained that when using TBF for rate control that any change to TBF parameters destroys the child qdisc. A typical use is to have a test that sets up netem + TBF then changes bandwidth setting. But every time the parameters of TBF are changed it destroys the child qdisc, requiring reconfiguration. Other qdisc's like HTB don't do this.

net/sched/sch_tbf.c static int tbf_change(struct Qdisc* sch, · line 279

Quoted 8 lines
net/sched/sch_tbf.c +4 -1
@@ -273,7 +273,11 @@ static int tbf_change(struct Qdisc* sch,
 	if (max_size < 0)
 		goto done;
 
-	if (qopt->limit > 0) {
+	if (q->qdisc) {
+		err = fifo_set_limit(q->qdisc, qopt->limit);
+		if (err)
+			goto done;

q->qdisc is never NULL since a noop_qdisc is assigned by default. Also this should check that the child is in fact one of the *fifos.

Quoted 5 lines
net/sched/sch_tbf.c +1 -0
+	} else if (qopt->limit > 0) {
 		child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
 		if (IS_ERR(child)) {
 			err = PTR_ERR(child);
#2 lore raw
Quoted 17 lines · On Thu, 13 May 2010 18:22:56 +0200 Patrick McHardy <[email protected]> wrote:
Quoted 16 lines · Stephen Hemminger

Several netem users have complained that when using TBF for rate control that any change to TBF parameters destroys the child qdisc. A typical use is to have a test that sets up netem + TBF then changes bandwidth setting. But every time the parameters of TBF are changed it destroys the child qdisc, requiring reconfiguration. Other qdisc's like HTB don't do this.

net/sched/sch_tbf.c +0 -0
@@ -273,7 +273,11 @@ static int tbf_change(struct Qdisc* sch,
 	if (max_size < 0)
 		goto done;
 
Quoted 8 lines

net/sched/sch_tbf.c static int tbf_change(struct Qdisc* sch, · line 279

Quoted 5 lines
net/sched/sch_tbf.c +4 -1
-	if (qopt->limit > 0) {
+	if (q->qdisc) {
+		err = fifo_set_limit(q->qdisc, qopt->limit);
+		if (err)
+			goto done;

q->qdisc is never NULL since a noop_qdisc is assigned by default. Also this should check that the child is in fact one of the *fifos.

But the child will be netem and fifo_set_limit ignores non-fifo.

#3 lore raw
Quoted 28 lines · Stephen Hemminger
Quoted 17 lines · On Thu, 13 May 2010 18:22:56 +0200 Patrick McHardy <[email protected]> wrote:
Quoted 16 lines · Stephen Hemminger

Several netem users have complained that when using TBF for rate control that any change to TBF parameters destroys the child qdisc. A typical use is to have a test that sets up netem + TBF then changes bandwidth setting. But every time the parameters of TBF are changed it destroys the child qdisc, requiring reconfiguration. Other qdisc's like HTB don't do this.

net/sched/sch_tbf.c +0 -0
@@ -273,7 +273,11 @@ static int tbf_change(struct Qdisc* sch,
 	if (max_size < 0)
 		goto done;
 
Quoted 7 lines

net/sched/sch_tbf.c static int tbf_change(struct Qdisc* sch, · line 279

Quoted 5 lines
net/sched/sch_tbf.c +4 -1
-	if (qopt->limit > 0) {
+	if (q->qdisc) {
+		err = fifo_set_limit(q->qdisc, qopt->limit);
+		if (err)
+			goto done;

q->qdisc is never NULL since a noop_qdisc is assigned by default. Also this should check that the child is in fact one of the *fifos.

Quoted 1 line

But the child will be netem and fifo_set_limit ignores non-fifo.

OK, but it does need to make sure the child is not a noop_qdisc, otherwise it won't create the default bfifo.

#4 lore raw

PATCH 1/1 tbf: stop wanton destruction of children (v2)

Several netem users use TBF for rate control. But every time the parameters of TBF are changed it destroys the child qdisc, requiring reconfigation. Better to just keep child qdisc and just notify it of changed limit.

net/sched/sch_tbf.c +5 -1
@@ -273,7 +273,11 @@ static int tbf_change(struct Qdisc* sch,
 	if (max_size < 0)
 		goto done;
 
-	if (qopt->limit > 0) {
+	if (q->qdisc != &noop_qdisc) {
+		err = fifo_set_limit(q->qdisc, qopt->limit);
+		if (err)
+			goto done;
+	} else if (qopt->limit > 0) {
 		child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
 		if (IS_ERR(child)) {
 			err = PTR_ERR(child);