Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: bigeasy@linutronix.de
Cc: netdev@vger.kernel.org, j-rameshbabu@ti.com,
	andrew+netdev@lunn.ch, c-vankar@ti.com, danishanwar@ti.com,
	d-qiu@ti.com, davem@davemloft.net, fmaurer@redhat.com,
	kuba@kernel.org, neelima@ti.com, pabeni@redhat.com,
	praneeth@ti.com, pratheesh@ti.com, richardcochran@gmail.com,
	horms@kernel.org, vigneshr@ti.com,
	willemdebruijn.kernel@gmail.com, daniel.machon@microchip.com,
	edumazet@kernel.org
Subject: Re: [PATCH net-next v9 5/8] hsr: Use the port and header information in hsr_forward_skb()
Date: Sun, 18 Oct 2026 15:51:43 +0000	[thread overview]
Message-ID: <179233870314.3135.16408273084496136138@kernel.org> (raw)
In-Reply-To: <20261014-hsr_ptp-v9-5-2d20a2a0f816@linutronix.de>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The per-port TX request (frame->req_tx_port) added by this
  patch does not take effect on slave devices with NETIF_F_HW_HSR_DUP.
- [Low] On PRP devices the has_foreign_header flag is only half honoured.
- [Low] Baseline decision: discard.

--

hsr: Use the port and header information in hsr_forward_skb()

This commit makes hsr_forward_skb() use the tx port and header
information passed down from the upper layer. A frame with a requested
port is sent only on that port.

A frame that already carries an HSR header is sent as a clone of the
original skb. It is not given a sequence number, its h_source is not
replaced and no source node lookup is done.

> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 14d793f00344f..a76bd02fe25f1 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c

[ ... ]

> @@ -570,6 +571,17 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
>  		if ((port->dev->features & NETIF_F_HW_HSR_DUP) && sent)
>  			continue;
>  
> +		/* PTP TX packets have an outgoing port specified */
> +		if (frame->req_tx_port != HSR_PT_NONE && frame->req_tx_port != port->type)
> +			continue;

[Severity: Medium]
Does the per-port request still work when the slave devices have
NETIF_F_HW_HSR_DUP set?

hsr_forward_do() passes the frame only to the requested slave netdev.
Nothing tells the lower driver not to duplicate it.

For DSA, dsa_xmit_port_mask() in net/dsa/tag.h adds every HSR ring port
to the egress mask:

    unlikely(dev->features & NETIF_F_HW_HSR_DUP)) {
    ...
        dsa_hsr_foreach_port(other_dp, dp->ds, hsr_dev)
            mask |= BIT(other_dp->index);

This covers ksz9477, xrs700x and the switches that use
dsa_port_simple_hsr_join().

For TI ICSSG, icssg_ndo_start_xmit() replaces the directed port:

    if (prueth->is_hsr_offload_mode &&
        (ndev->features & NETIF_F_HW_HSR_DUP))
        dst_tag_id = PRUETH_UNDIRECTED_PKT_DST_TAG;

So a PTP frame requested for SLAVE_A, such as a per-link peer delay
message, would also go out on SLAVE_B. That doesn't match "If the port
set, deliver it only on the requested port" in the commit message.

The later commit "hsr: Move struct hsr_ethhdr to a global header" says
offloading drivers need to inspect PTP packets and suppress offloading.
No driver is changed in the series, though.

Should the directed case be handled here, or in the drivers, before this
is enabled?

> +		/* PTP TX packets may already have a HSR header which needs to
> +		 * be preserved
> +		 */
> +		if (frame->has_foreign_header && frame->skb_std) {
> +			skb = skb_clone(frame->skb_std, GFP_ATOMIC);
> +			goto inject_into_stack;
> +		}

[Severity: Low]
Should the clone take over the socket ownership here?

__skb_clone() leaves sk as NULL on the clone. The slave driver takes the
TX hardware timestamp on the clone, so the timestamp can't be delivered
to the sending PTP socket. The original skb, which owns the socket, is
freed in hsr_forward_skb() without being sent.

The next commit in the series, "hsr: Assign a socket for cloned skbs",
fixes this by adding skb_set_owner_w() to this branch. So this only
affects this intermediate commit. TX timestamps through hsr were not
delivered before the series either.

> +
>  		/* Don't send frame over port where it has been sent before.

[ ... ]

> @@ -661,6 +674,13 @@ int hsr_fill_frame_info(__be16 proto, struct sk_buff *skb,
>  	struct hsr_port *port = frame->port_rcv;
>  	struct hsr_priv *hsr = port->hsr;
>  
> +	if (frame->has_foreign_header) {
> +		frame->skb_std = skb;
> +
> +		WARN_ON_ONCE(port->type != HSR_PT_MASTER);
> +		WARN_ON_ONCE(skb->mac_len < sizeof(struct hsr_ethhdr));
> +		return 0;
> +	}

[Severity: Low]
This early return is only added to hsr_fill_frame_info(), the hsr_ops
callback. What happens on a PRP device, where proto_ops->fill_frame_info
is prp_fill_frame_info()?

hsr_dev_xmit() accepts hsr_hdr for any prot_version. fill_frame_info()
then sets has_foreign_header and skips hsr_get_node(), and
prp_fill_frame_info() runs its normal logic.

If the frame has no valid RCT, handle_std_frame() still uses up a
sequence number:

    frame->sequence_nr = hsr->sequence_nr;
    WRITE_ONCE(hsr->sequence_nr, hsr->sequence_nr + 1);

The commit message says no sequence number is assigned when a header is
already present.

If the frame has a valid RCT, skb_prp is set and skb_std stays NULL. The
"has_foreign_header && frame->skb_std" bypass in hsr_forward_do() is then
skipped. The frame goes through prp_create_tagged_frame(), which calls
prp_set_lan_id() and rewrites the trailer the user supplied.

At the end of the series, that skb_prp clone also gets no socket owner,
so its TX timestamp is lost.

hsr_dev_xmit() also always adds HSR_HLEN when hsr_hdr is set:

    if (has_header)
        hdr_len = ETH_HLEN + HSR_HLEN;

PRP uses a trailer, not a front tag. On PRP this places network_header
and mac_len 6 bytes too far into the frame.

The later commit "hsr: Assign a socket for cloned skbs" says "This does
not consider PRP part of the stack". Would it be better to reject the
inline header on PRP devices, or to handle has_foreign_header in
prp_fill_frame_info() as well?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261014-hsr_ptp-v9-0-2d20a2a0f816%40linutronix.de

  parent reply	other threads:[~2026-10-18 15:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 14:43 [PATCH net-next v9 0/8] hsr: Add additional info to send/ receive skbs Sebastian Andrzej Siewior
2026-10-14 14:43 ` [PATCH net-next v9 1/8] hsr: Add header_ops::parse_protocol Sebastian Andrzej Siewior
2026-10-14 14:43 ` [PATCH net-next v9 2/8] hsr: Use skb_clone() while adding the HSR header Sebastian Andrzej Siewior
2026-10-16  9:09   ` Daniel Machon
2026-10-16  9:41     ` Sebastian Andrzej Siewior
2026-10-18 15:51   ` netdev-bot+sashiko
2026-10-14 14:43 ` [PATCH net-next v9 3/8] hsr: Add a magic header for sending PTP packets Sebastian Andrzej Siewior
2026-10-16  9:15   ` Daniel Machon
2026-10-16  9:48     ` Sebastian Andrzej Siewior
2026-10-18 15:51   ` netdev-bot+sashiko
2026-10-14 14:43 ` [PATCH net-next v9 4/8] hsr: Drop received " Sebastian Andrzej Siewior
2026-10-18 15:51   ` netdev-bot+sashiko
2026-10-14 14:43 ` [PATCH net-next v9 5/8] hsr: Use the port and header information in hsr_forward_skb() Sebastian Andrzej Siewior
2026-10-16  9:24   ` Daniel Machon
2026-10-16  9:56     ` Sebastian Andrzej Siewior
2026-10-18 15:51   ` netdev-bot+sashiko [this message]
2026-10-14 14:44 ` [PATCH net-next v9 6/8] hsr: Assign a socket for cloned skbs Sebastian Andrzej Siewior
2026-10-16  9:34   ` Daniel Machon
2026-10-16  9:56     ` Sebastian Andrzej Siewior
2026-10-14 14:44 ` [PATCH net-next v9 7/8] hsr: Move struct hsr_ethhdr to a global header Sebastian Andrzej Siewior
2026-10-16  9:38   ` Daniel Machon
2026-10-16 10:07     ` Sebastian Andrzej Siewior
2026-10-19  9:15       ` Daniel Machon
2026-10-14 14:44 ` [PATCH net-next v9 8/8] selftests: hsr: Add test for the inline PTP header on HSR Sebastian Andrzej Siewior
2026-10-18 15:51   ` netdev-bot+sashiko
2026-10-16  9:01 ` [PATCH net-next v9 0/8] hsr: Add additional info to send/ receive skbs Daniel Machon
2026-10-16  9:36   ` Sebastian Andrzej Siewior
2026-10-18 16:14 ` Sebastian Andrzej Siewior

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=179233870314.3135.16408273084496136138@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bigeasy@linutronix.de \
    --cc=c-vankar@ti.com \
    --cc=d-qiu@ti.com \
    --cc=daniel.machon@microchip.com \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fmaurer@redhat.com \
    --cc=horms@kernel.org \
    --cc=j-rameshbabu@ti.com \
    --cc=kuba@kernel.org \
    --cc=neelima@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=praneeth@ti.com \
    --cc=pratheesh@ti.com \
    --cc=richardcochran@gmail.com \
    --cc=vigneshr@ti.com \
    --cc=willemdebruijn.kernel@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