net/sched: Fix divide error in tabledist
Subsystems (4)
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
---net/sched/sch_netem.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
net/sched/sch_netem.c +0 -0
@@ -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
Stephen Hemminger
maintainerQuoted 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 parametersFixes ec8e0e3d7ade ("net/sched: Restrict conditions for addingduplicating netems to qdisc tree")
Reported-by Manas Ghandat <[email protected]>Signed-off-by Manas Ghandat <[email protected]>---
net/sched/sch_netem.c| 11 +++++------1 file changed, 5 insertions(+), 6 deletions(-)net/sched/sch_netem.c +5
-0@@ -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
-6q->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
Quoted 1 line · Stephen Hemminger
The whole
netem_in_treecheck 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.
Just a friendly reminder
Quoted 8 lines · Manas Ghandat
Quoted 1 line · Stephen Hemminger
The whole
netem_in_treecheck 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.
Stephen Hemminger
maintainerQuoted 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_treecheck 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.