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/2026…%40linutronix.de