From: netdev-bot+sashiko@kernel.org
To: bigeasy@linutronix.de
Cc: netdev@vger.kernel.org, j-rameshbabu@ti.com,
andrew+netdev@lunn.ch, 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 v14 6/8] hsr: Assign a socket for cloned skbs
Date: Fri, 04 Dec 2026 17:55:55 +0000 [thread overview]
Message-ID: <179640695518.3146.18120858440869969765@kernel.org> (raw)
In-Reply-To: <20261203-hsr_ptp-v14-6-1511ffd4c362@linutronix.de>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] A PRP device now delivers a TX timestamp for a PTP frame only
when has_hsr_header=1; with has_hsr_header=0 it silently drops it.
- [Low] Both call sites added by this patch give clones a socket only
when the frame came through the new PTP inline header.
--
hsr: Assign a socket for cloned skbs
This patch gives skbs cloned in hsr_create_tagged_frame() and in the
has_hsr_header branch of hsr_forward_do() the socket of the original skb.
skb_clone() clears skb->sk and hsr_forward_skb() frees the original.
Without this change, skb_tstamp_tx() has no socket to report the requested
TX timestamp to.
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 1d1d75ed8cd06..9cb3297a8640a 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
[ ... ]
> @@ -347,6 +348,9 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame,
> if (!skb)
> return NULL;
>
> + if (frame->req_tx_port != HSR_PT_NONE && frame->skb_std->sk)
> + skb_set_owner_w(skb, frame->skb_std->sk);
> +
[Severity: Low]
This isn't a bug, but the subject ("hsr: Assign a socket for cloned
skbs") and the last paragraph ("Assign the socket of the original skb to
the clone") suggest that every HSR clone is now owned by a socket.
The socket is only assigned when the frame came in through the new PTP
inline header. Normal HSR traffic still gets clones with no owner. Could
the changelog mention that restriction?
The two sites also use different conditions. This one checks
frame->req_tx_port, while the hsr_forward_do() site below checks
frame->has_hsr_header. Both are meant to cover frames from the PTP inline
header.
That only works because hsr_ptp_parse_header() is the only place that sets
either field. It rejects frames without skb->sk, and it rejects any
req_tx_port other than HSR_PT_SLAVE_A or HSR_PT_SLAVE_B:
net/hsr/hsr_device.c:hsr_ptp_parse_header() {
...
if (!skb->sk)
return -EINVAL;
...
*has_hsr_header = !!hsr_inline_hdr->has_hsr_header;
*req_tx_port = hsr_inline_hdr->req_tx_port;
if (*req_tx_port != HSR_PT_SLAVE_A && *req_tx_port != HSR_PT_SLAVE_B)
return -EINVAL;
...
}
If a later change sets one of these fields without the other, the two
checks would no longer agree. Would a single shared condition be easier
to keep consistent?
> if (port->dev->features & NETIF_F_HW_HSR_TAG_INS)
> return skb;
>
[ ... ]
> @@ -582,6 +586,8 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
> */
> if (frame->has_hsr_header && frame->skb_std) {
> skb = skb_clone(frame->skb_std, GFP_ATOMIC);
> + if (skb && frame->skb_std->sk)
> + skb_set_owner_w(skb, frame->skb_std->sk);
> goto inject_into_stack;
> }
[Severity: Medium]
The changelog says:
This does not consider PRP part of the stack. The specification says
that PTP-PRP packets do not have the RCT therefore these packets can be
sent directly from userland skipping the stack.
Is that accurate? This branch of hsr_forward_do() runs for both HSR and
PRP devices.
Neither hsr_dev_xmit() nor hsr_ptp_parse_header() checks
hsr->prot_version. A PRP device therefore accepts struct
hsr_inline_header with req_tx_port set to port A or B. For ETH_P_1588 it
also requires that header.
With has_hsr_header=1 on a PRP device, prp_fill_frame_info() finds no RCT
and calls handle_std_frame(). That sets skb_std, so this branch is taken.
The clone gets skb_set_owner_w() and the timestamp reaches the user.
With has_hsr_header=0 on the same device, hsr_forward_do() calls
hsr->proto_ops->create_tagged_frame(), which is prp_create_tagged_frame():
net/hsr/hsr_forward.c:prp_create_tagged_frame() {
...
} else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) {
return skb_clone(frame->skb_std, GFP_ATOMIC);
}
skb = skb_copy_expand(frame->skb_std, skb_headroom(frame->skb_std),
skb_tailroom(frame->skb_std) + HSR_HLEN,
GFP_ATOMIC);
return prp_fill_rct(skb, frame, port);
}
Neither of these paths assigns an owner. skb_tstamp_tx() then has no
socket, so the requested timestamp is silently lost. The frame also gets
an RCT appended, and the changelog says PTP-PRP frames should not carry
one.
After this patch, hsr_create_tagged_frame() and the shared has_hsr_header
branch both set the owner for req_tx_port frames.
prp_create_tagged_frame() is the only req_tx_port transmit path that
doesn't. On PRP, whether the timestamp arrives therefore depends on the
HSR-named has_hsr_header flag.
Should hsr_ptp_parse_header() reject the inline header on PRP_V1 devices?
Alternatively, should prp_create_tagged_frame() handle req_tx_port frames
the same way hsr_create_tagged_frame() now does? If neither, could the
changelog at least describe what happens on PRP?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-hsr_ptp-v14-0-1511ffd4c362%40linutronix.de
next prev parent reply other threads:[~2026-12-04 17:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 17:44 [PATCH net-next v14 0/8] hsr: Allow to send packets on specific port and pass the timestamp Sebastian Andrzej Siewior
2026-12-03 17:44 ` [PATCH net-next v14 1/8] hsr: Add header_ops::parse_protocol Sebastian Andrzej Siewior
2026-12-03 17:44 ` [PATCH net-next v14 2/8] hsr: Use skb_clone() while adding the HSR header Sebastian Andrzej Siewior
2026-12-04 17:55 ` netdev-bot+sashiko
2026-12-03 17:44 ` [PATCH net-next v14 3/8] hsr: Add a magic header for sending PTP packets Sebastian Andrzej Siewior
2026-12-04 17:55 ` netdev-bot+sashiko
2026-12-03 17:44 ` [PATCH net-next v14 4/8] hsr: Drop received " Sebastian Andrzej Siewior
2026-12-03 17:44 ` [PATCH net-next v14 5/8] hsr: Use the port and header information in hsr_forward_skb() Sebastian Andrzej Siewior
2026-12-04 17:55 ` netdev-bot+sashiko
2026-12-03 17:44 ` [PATCH net-next v14 6/8] hsr: Assign a socket for cloned skbs Sebastian Andrzej Siewior
2026-12-04 17:55 ` netdev-bot+sashiko [this message]
2026-12-03 17:44 ` [PATCH net-next v14 7/8] hsr: Move struct hsr_ethhdr to a global header Sebastian Andrzej Siewior
2026-12-03 17:44 ` [PATCH net-next v14 8/8] selftests: hsr: Add test for the inline PTP header on HSR Sebastian Andrzej Siewior
2026-12-04 17:55 ` netdev-bot+sashiko
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=179640695518.3146.18120858440869969765@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bigeasy@linutronix.de \
--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