Linux virtualization list
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: <chia-yu.chang@nokia-bell-labs.com>, <shenjian15@huawei.com>,
	<linux-rdma@vger.kernel.org>, <eperezma@redhat.com>,
	<jasowang@redhat.com>, <virtualization@lists.linux.dev>,
	<mst@redhat.com>, <xuanzhuo@linux.alibaba.com>,
	<pabeni@redhat.com>, <edumazet@google.com>,
	<linux-doc@vger.kernel.org>, <corbet@lwn.net>, <horms@kernel.org>,
	<dsahern@kernel.org>, <kuniyu@google.com>, <bpf@vger.kernel.org>,
	<netdev@vger.kernel.org>, <dave.taht@gmail.com>,
	<jhs@mojatatu.com>, <kuba@kernel.org>,
	<stephen@networkplumber.org>, <xiyou.wangcong@gmail.com>,
	<jiri@resnulli.us>, <davem@davemloft.net>,
	<andrew+netdev@lunn.ch>, <donald.hunter@gmail.com>,
	<ast@fiberby.net>, <liuhangbin@gmail.com>, <shuah@kernel.org>,
	<linux-kselftest@vger.kernel.org>, <ij@kernel.org>,
	<ncardwell@google.com>, <koen.de_schepper@nokia-bell-labs.com>,
	<g.white@cablelabs.com>, <ingemar.s.johansson@ericsson.com>,
	<mirja.kuehlewind@ericsson.com>, <cheshire@apple.com>,
	<rs.ietf@gmx.at>, <Jason_Livingood@comcast.com>,
	<vidhi_goel@apple.com>
Cc: <shaojijie@huawei.com>
Subject: Re: [PATCH v5 net-next 2/2] net: hns3: fix GSO_ECN flag setting in the RX path
Date: Tue, 18 Aug 2026 21:32:20 +0800	[thread overview]
Message-ID: <dd817755-eb4d-4ac2-b282-ac06f847270d@huawei.com> (raw)
In-Reply-To: <61721708-0d77-4f59-aa08-02562af282bb@huawei.com>


on 2026/8/11 21:31, Jijie Shao wrote:
>
> on 2026/8/5 5:35, chia-yu.chang@nokia-bell-labs.com wrote:
>> From: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
>>
>> Currently, the hns3 Rx path sets the SKB_GSO_TCP_ECN flag when a TCP
>> segment with the CWR flag set is received. This is incorrect because
>> the hns3 hardware GRO resets the IP ToS byte to 0 during packet
>> aggregation. Consequently, no valid ECN signals are carreid, meaning
>> that it cannot support RFC3168 ECN or Accurate ECN protocols. Setting
>> SKB_GSO_TCP_ECN or SKB_GSO_TCP_ACCECN under these conditions misleads
>> the upper network stack.
>>
>> Fix this by removing the incorrect SKB_GSO_TCP_ECN flag assignment
>> in hns3_gro_complete().
>
>
> Tested on hns3 HW (2x 100G, direct cable, openEuler 24.03, kernel 
> 7.2.0-rc6).
>
> tcpdump confirms HW GRO zeroes IP ToS: aggregated (>MTU) packets carry
> tos 0x0, while non-aggregated packets keep their ToS/ECN marks — so the
> zeroing is done by HW GRO, not the sender. Before patch, CWR packets had
> SKB_GSO_TCP_ECN set (0x5 = SKB_GSO_TCPV4 | SKB_GSO_TCP_ECN). After patch,
> all GRO events gso_type=0x1 (SKB_GSO_TCPV4 only), no 0x5 observed.
>
> Tested-by: Jijie Shao <shaojijie@huawei.com>


I need to correct my earlier test report where I stated:

   "tcpdump confirms HW GRO zeroes IP ToS: aggregated (>MTU) packets
    carry tos 0x0, while non-aggregated packets keep their ToS/ECN
    marks — so the zeroing is done by HW GRO, not the sender"

This conclusion was wrong. I am withdrawing that Tested-by tag.

Root cause of the error
========================

I mixed two test tools with different sender-side paths and incorrectly
compared their results:

1. The observation that "non-aggregated packets keep their ToS/ECN
    marks" came from a Python script (scapy). Scapy constructs L2/L3
    packets directly, bypassing the kernel TCP stack, so the ToS value
    on the wire is exactly what the script sets — this says nothing
    about whether a kernel-stack sender would clear ToS or not.

2. The observation that "aggregated packets carry tos 0x0" came from
    iperf3 with --tos. iperf3 goes through the kernel TCP stack, and I
    did not set net.ipv4.tcp_ecn=1, so the kernel cleared the ECN bits
    (low 2 bits of ToS) before the packets hit the wire. The tos=0x0 on
    aggregated packets was already tos=0x0 on the wire at the sender
    side — it was a TX-side kernel behavior, not HW GRO zeroing.

I mistakenly used the scapy observation ("non-aggregated packets keep
ToS") as evidence that "the sender didn't clear ToS", then concluded
that iperf3's tos=0x0 must be caused by HW GRO. But these two
observations came from different sender paths and cannot be compared
this way. I only captured at the receiver side with no sender-side
wire capture to compare against, so I wrongly attributed the TX-side
clearing to HW GRO.

New test with tesgine (direct packet construction)
===================================================

To eliminate the kernel TCP stack interference, I retested using
tesgine, a packet generator that constructs TCP segments directly at
L2/L3 with full control over the IP ToS byte. This bypasses the kernel
TCP ECN state machine entirely, so the ToS value on the wire is exactly
what was configured.

Test setup:
   - hns3 NIC, HW GRO on, software GRO off (ethtool -K <dev> gro off)
   - tesgine sends 1460-byte TCP segments with controlled ToS values
   - Capture at receiver post-GRO

Four test cases were run, each verifying a different ToS boundary:

Test 1: Non-ECT <-> ECT(0)
   Sent:  4x tos=0x00 + 1x tos=0x02 + 4x tos=0x00 + 2x tos=0x02 + 1x tos=0x00
   Got:   4 aggregated (tos=0x00) | 1 single (tos=0x02)
        | 4 aggregated (tos=0x00) | 2 aggregated (tos=0x02)
        | 1 single (tos=0x00)
   => GRO segments at every ToS change, each group keeps its ToS.

Test 2: ECT(0) <-> CE
   Sent:  4x tos=0x02 + 1x tos=0x03 (CE) + 4x tos=0x02
   Got:   4 aggregated (tos=0x02) | 1 single (tos=0x03 CE)
        | 4 aggregated (tos=0x02)
   => CE packet is delivered independently, CE mark preserved.

Test 3: Non-ECT <-> CE
   Sent:  4x tos=0x00 + 1x tos=0x03 (CE)
   Got:   4 aggregated (tos=0x00) | 1 single (tos=0x03 CE)
   => Same behavior: CE is segmented out, ToS preserved.

Test 4: Pure DSCP change (ECN bits identical)
   Sent:  4x tos=0x10 (DSCP4) + 4x tos=0xB8 (DSCP46)
   Got:   4 aggregated (tos=0x10) | 4 aggregated (tos=0xB8)
   => Even pure DSCP change (no ECN bit change) triggers segmentation.

Conclusions from tesgine testing
================================

   1. HW GRO does NOT zero IP ToS. Each aggregate group retains the
      head packet's ToS value (verified with 0x00/0x02/0x03/0x10/0xB8).

   2. HW GRO segments flows by ToS boundaries. Any ToS change — whether
      DSCP (bits 0-5) or ECN (bits 6-7) — terminates the current
      aggregate group and starts a new one.

   3. ECN signals are preserved: CE packets (tos=0x03) are delivered
      independently with the CE mark intact, not merged into non-CE
      aggregates.

Impact on this patch
====================

The commit message states:

   "the hns3 hardware GRO resets the IP ToS byte to 0 during packet
    aggregation. Consequently, no valid ECN signals are carried"

This factual claim is incorrect per the tesgine test results above.
HW GRO preserves ToS and segments by ToS boundaries, so ECN signals
are not lost during aggregation.

The code change itself (removing the SKB_GSO_TCP_ECN assignment in
hns3_gro_complete) may still be correct, but the justification should
be based on the RX-path semantic argument from patch 1/2 (SKB_GSO_TCP_ECN
is a TX-path flag; using it in RX can corrupt the ACE signal in AccECN
forwarding scenarios), not on the ToS-zeroing claim. Or change to AccECN.

I will re-verify and provide a new Tested-by once the commit message is
updated. Sorry for the confusion caused by my earlier report.

Test captures and methodology details available on request.

Regards,
Jijie Shao



      parent reply	other threads:[~2026-08-18 13:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 21:35 [PATCH v5 net-next 0/2] ECN offload handling series chia-yu.chang
2026-08-04 21:35 ` [PATCH v5 net-next 1/2] net: update comments for SKB_GSO_TCP_ECN and SKB_GSO_TCP_ACCECN chia-yu.chang
2026-08-12  0:30   ` Jakub Kicinski
2026-08-12 10:33     ` Chia-Yu Chang (Nokia)
2026-08-12 22:54       ` Jakub Kicinski
2026-08-13 10:28         ` Chia-Yu Chang (Nokia)
2026-08-13 15:58           ` Willem de Bruijn
     [not found]             ` <47BE8A8A-F80C-4C30-BC95-C85FEBFFB606@ericsson.com>
2026-08-14 10:29               ` Chia-Yu Chang (Nokia)
2026-08-14 13:34                 ` Willem de Bruijn
2026-08-14 19:01                   ` Jakub Kicinski
2026-08-14 19:14                     ` Willem de Bruijn
2026-08-04 21:35 ` [PATCH v5 net-next 2/2] net: hns3: fix GSO_ECN flag setting in the RX path chia-yu.chang
2026-08-06 11:47   ` Jijie Shao
2026-08-11 13:31   ` Jijie Shao
2026-08-12 10:35     ` Chia-Yu Chang (Nokia)
2026-08-12 22:59       ` Jakub Kicinski
2026-08-19  2:51         ` Jijie Shao
2026-08-18 13:32     ` Jijie Shao [this message]

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=dd817755-eb4d-4ac2-b282-ac06f847270d@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=Jason_Livingood@comcast.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@fiberby.net \
    --cc=bpf@vger.kernel.org \
    --cc=cheshire@apple.com \
    --cc=chia-yu.chang@nokia-bell-labs.com \
    --cc=corbet@lwn.net \
    --cc=dave.taht@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=g.white@cablelabs.com \
    --cc=horms@kernel.org \
    --cc=ij@kernel.org \
    --cc=ingemar.s.johansson@ericsson.com \
    --cc=jasowang@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=koen.de_schepper@nokia-bell-labs.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=liuhangbin@gmail.com \
    --cc=mirja.kuehlewind@ericsson.com \
    --cc=mst@redhat.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rs.ietf@gmx.at \
    --cc=shenjian15@huawei.com \
    --cc=shuah@kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=vidhi_goel@apple.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xiyou.wangcong@gmail.com \
    --cc=xuanzhuo@linux.alibaba.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