netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manas <ghandatmanas@gmail.com>
To: stephen@networkplumber.org
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Manas <ghandatmanas@gmail.com>
Subject: [PATCH v2] net/sched: Fix divide error in tabledist
Date: Mon, 22 Dec 2025 11:43:06 +0530	[thread overview]
Message-ID: <20251222061306.28902-1-ghandatmanas@gmail.com> (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

v1 -> v2: Fix whitespace
---
 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


             reply	other threads:[~2025-12-22  6:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-22  6:13 Manas [this message]
2025-12-27 19:49 ` [PATCH v2] net/sched: Fix divide error in tabledist Cong Wang
2025-12-28 15:24   ` Manas Ghandat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251222061306.28902-1-ghandatmanas@gmail.com \
    --to=ghandatmanas@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).