netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, will@willsroot.io,
	Savino Dicanosa <savy@syst3mfailure.io>
Subject: Re: [Patch v3 net 1/4] net_sched: Implement the right netem duplication behavior
Date: Tue, 15 Jul 2025 10:48:18 -0700	[thread overview]
Message-ID: <aHaUYnIZjHRItYu0@pop-os.localdomain> (raw)
In-Reply-To: <20250713151220.772882ab@hermes.local>

On Sun, Jul 13, 2025 at 03:12:20PM -0700, Stephen Hemminger wrote:
> On Sun, 13 Jul 2025 14:47:45 -0700
> Cong Wang <xiyou.wangcong@gmail.com> wrote:
> 
> > +	if (q->duplicate) {
> > +		bool dup = true;
> > +
> > +		if (netem_skb_cb(skb)->duplicate) {
> > +			netem_skb_cb(skb)->duplicate = 0;
> > +			dup = false;
> > +		}
> > +		if (dup && q->duplicate >= get_crandom(&q->dup_cor, &q->prng))
> > +			++count;
> > +	}
> 
> Doesn't look ideal.
> 
> Why do yo need the temporary variable here?

It is all because we need to clear the duplicate bit.

> And you risk having bug where first duplicate sets the flag then second clears it
> and a third layer would do duplicate and reset it.

I am not sure I follow you here. After this patch, we only enqueue the
duplicate skb to the same qdisc and this skb's duplicate bit gets
immediately cleared here. They have no chance to traverse to other qdisc
before clearing this bit. This is actually why it is safe to use
netem_skb_cb() now (instead of skb ext or tc_skb_cb). Or am I missing anything?

If you have a specific setup you suspect this may break, please share it
with me and I am happy to test and integrate into TDC.

Thanks for your review!

  reply	other threads:[~2025-07-15 17:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-13 21:47 [Patch v3 net 0/4] netem: Fix skb duplication logic and prevent infinite loops Cong Wang
2025-07-13 21:47 ` [Patch v3 net 1/4] net_sched: Implement the right netem duplication behavior Cong Wang
2025-07-13 22:01   ` Cong Wang
2025-07-13 22:12   ` Stephen Hemminger
2025-07-15 17:48     ` Cong Wang [this message]
2025-07-14  2:30   ` William Liu
2025-07-15 18:03     ` Cong Wang
2025-07-15 18:41       ` William Liu
2025-07-13 21:47 ` [Patch v3 net 2/4] selftests/tc-testing: Add a nested netem duplicate test Cong Wang
2025-07-13 21:47 ` [Patch v3 net 3/4] selftests/tc-testing: Add a test case for piro with netem duplicate Cong Wang
2025-07-13 21:47 ` [Patch v3 net 4/4] selftests/tc-testing: Add a test case for mq " Cong Wang

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=aHaUYnIZjHRItYu0@pop-os.localdomain \
    --to=xiyou.wangcong@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=savy@syst3mfailure.io \
    --cc=stephen@networkplumber.org \
    --cc=will@willsroot.io \
    /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).