Skip to contentSkip to conversation

net/sched: Fix divide error in tabledist

PATCH Manas Ghandat 2 participants 5 messages Dec 11, 2025 – Dec 21, 2025

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

Previously, a duplication check was added to ensure that a duplicating netem cannot exist in a tree with other netems. When check_netem_in_tree() fails after parameter updates, the qdisc structure is left in an inconsistent state with some new values applied but duplicate not updated. Move the tree validation check before modifying any qdisc parameters

Fixes ec8e0e3d7ade ("net/sched: Restrict conditions for adding duplicating netems to qdisc tree")

---
net/sched/sch_netem.c | 11 +++++------

1 file changed, 5 insertions(+), 6 deletions(-)
net/sched/sch_netem.c +0 -0
index 32a5f3304046..1a2b498ada83 100644
@@ -1055,6 +1055,11 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,

q->loss_model = CLG_RANDOM;
}
+ ret = check_netem_in_tree(sch, qopt->duplicate, extack);
+ if (ret)
+ goto unlock;
+ q->duplicate = qopt->duplicate;
+
if (delay_dist)
swap(q->delay_dist, delay_dist);
if (slot_dist)
@@ -1068,12 +1073,6 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, q->counter = 0;
q->loss = qopt->loss;
- ret = check_netem_in_tree(sch, qopt->duplicate, extack);
- if (ret)
- goto unlock;
-
- q->duplicate = qopt->duplicate;
-
/* for compatibility with earlier versions.
* if gap is set, need to assume 100% probability
*/

Signature · 1 line
2.43.0
#1 lore raw
Quoted 32 lines · On Thu, 11 Dec 2025 23:36:32 +0530 Manas Ghandat <[email protected]> wrote:

Previously, a duplication check was added to ensure that a duplicating netem cannot exist in a tree with other netems. When check_netem_in_tree() fails after parameter updates, the qdisc structure is left in an inconsistent state with some new values applied but duplicate not updated. Move the tree validation check before modifying any qdisc parameters

Fixes ec8e0e3d7ade ("net/sched: Restrict conditions for adding

duplicating netems to qdisc tree")

---
net/sched/sch_netem.c | 11 +++++------

1 file changed, 5 insertions(+), 6 deletions(-)
net/sched/sch_netem.c +5 -0
index 32a5f3304046..1a2b498ada83 100644
@@ -1055,6 +1055,11 @@ static int netem_change(struct Qdisc *sch, struct 
 nlattr *opt,
 q->loss_model = CLG_RANDOM;
 }
+ ret = check_netem_in_tree(sch, qopt->duplicate, extack);
+ if (ret)
+ goto unlock;
+ q->duplicate = qopt->duplicate;
+
 if (delay_dist)
 swap(q->delay_dist, delay_dist);
 if (slot_dist)
@@ -1068,12 +1073,6 @@ static int netem_change(struct Qdisc *sch, struct 
 nlattr *opt,
 q->counter = 0;

net/sched/sch_netem.c static int netem_change(struct Qdisc *sch, struct · line 1078

Quoted 10 lines
net/sched/sch_netem.c +0 -6
 q->loss = qopt->loss;
- ret = check_netem_in_tree(sch, qopt->duplicate, extack);
- if (ret)
- goto unlock;
-
- q->duplicate = qopt->duplicate;
-
 /* for compatibility with earlier versions.
 * if gap is set, need to assume 100% probability
 */

Agree the netem_in_tree error path is incorrect. The whole netem_in_tree check is problematic as well.

Your mail system is corrupting the patch. The whitespace is messed up. Is this the same as earlier patch

#2 lore raw
Quoted 1 line · Stephen Hemminger

The whole netem_in_tree check is problematic as well.

Can you mention the issues. Maybe I can include that in my patch as well.

Quoted 1 line

Your mail system is corrupting the patch.

I will resend the patch.

Quoted 1 line

Is this the same as earlier patch

I have just moved the check before the values in qdisc are changed. This would prevent the values being affected in case we bail out taking the error path.

#3 lore raw

Just a friendly reminder

Quoted 8 lines · Manas Ghandat
Quoted 1 line · Stephen Hemminger

The whole netem_in_tree check is problematic as well.

Can you mention the issues. Maybe I can include that in my patch as well.

Quoted 1 line

Your mail system is corrupting the patch.

I will resend the patch.

Quoted 1 line

Is this the same as earlier patch

I have just moved the check before the values in qdisc are changed. This would prevent the values being affected in case we bail out taking the error path.

#4 lore raw
Quoted 13 lines · On Wed, 17 Dec 2025 23:57:40 +0530 Manas Ghandat <[email protected]> wrote:

Just a friendly reminder

Quoted 10 lines · Manas Ghandat
Quoted 1 line · Stephen Hemminger

The whole netem_in_tree check is problematic as well.

Can you mention the issues. Maybe I can include that in my patch as well.

Quoted 1 line

Your mail system is corrupting the patch.

I will resend the patch.

Quoted 1 line

Is this the same as earlier patch

I have just moved the check before the values in qdisc are changed. This would prevent the values being affected in case we bail out taking the error path.

The check_netem_in_tree code caused a regression where some valid configurations using multiple queues are HTB stopped working. A better solution is needed and Cong et al are working on it.