netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net/sched: Fix divide error in tabledist
@ 2025-12-11 18:06 Manas Ghandat
  2025-12-12  8:18 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Manas Ghandat @ 2025-12-11 18:06 UTC (permalink / raw)
  To: stephen
  Cc: xiyou.wangcong, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev, linux-kernel

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")
Reported-by: Manas Ghandat <ghandatmanas@gmail.com>
Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
---
net/sched/sch_netem.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 32a5f3304046..1a2b498ada83 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -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
*/
-- 
2.43.0



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

* Re: net/sched: Fix divide error in tabledist
  2025-12-11 18:06 net/sched: Fix divide error in tabledist Manas Ghandat
@ 2025-12-12  8:18 ` Stephen Hemminger
  2025-12-12 15:17   ` Manas Ghandat
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-12  8:18 UTC (permalink / raw)
  To: Manas Ghandat
  Cc: xiyou.wangcong, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev

On Thu, 11 Dec 2025 23:36:32 +0530
Manas Ghandat <ghandatmanas@gmail.com> 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")
> Reported-by: Manas Ghandat <ghandatmanas@gmail.com>
> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
> ---
> net/sched/sch_netem.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
> diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> index 32a5f3304046..1a2b498ada83 100644
> --- a/net/sched/sch_netem.c
> +++ b/net/sched/sch_netem.c
> @@ -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
> */

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


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

* Re: net/sched: Fix divide error in tabledist
  2025-12-12  8:18 ` Stephen Hemminger
@ 2025-12-12 15:17   ` Manas Ghandat
  2025-12-17 18:27     ` Manas Ghandat
  0 siblings, 1 reply; 5+ messages in thread
From: Manas Ghandat @ 2025-12-12 15:17 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: xiyou.wangcong, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev


On 12/12/25 13:48, Stephen Hemminger wrote:
> 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.
> Your mail system is corrupting the patch.
I will resend the patch.
> 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.

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

* Re: net/sched: Fix divide error in tabledist
  2025-12-12 15:17   ` Manas Ghandat
@ 2025-12-17 18:27     ` Manas Ghandat
  2025-12-21 17:03       ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Manas Ghandat @ 2025-12-17 18:27 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: xiyou.wangcong, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev

Just a friendly reminder

On 12/12/25 20:47, Manas Ghandat wrote:
>
> On 12/12/25 13:48, Stephen Hemminger wrote:
>> 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.
>> Your mail system is corrupting the patch.
> I will resend the patch.
>> 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.

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

* Re: net/sched: Fix divide error in tabledist
  2025-12-17 18:27     ` Manas Ghandat
@ 2025-12-21 17:03       ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2025-12-21 17:03 UTC (permalink / raw)
  To: Manas Ghandat
  Cc: xiyou.wangcong, Jiri Pirko, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, netdev

On Wed, 17 Dec 2025 23:57:40 +0530
Manas Ghandat <ghandatmanas@gmail.com> wrote:

> Just a friendly reminder
> 
> On 12/12/25 20:47, Manas Ghandat wrote:
> >
> > On 12/12/25 13:48, Stephen Hemminger wrote:  
> >> 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.  
> >> Your mail system is corrupting the patch.  
> > I will resend the patch.  
> >> 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.

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

end of thread, other threads:[~2025-12-21 17:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 18:06 net/sched: Fix divide error in tabledist Manas Ghandat
2025-12-12  8:18 ` Stephen Hemminger
2025-12-12 15:17   ` Manas Ghandat
2025-12-17 18:27     ` Manas Ghandat
2025-12-21 17:03       ` Stephen Hemminger

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).