Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 (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] hsr: hsr_create_tagged_frame() retains TX timestamp flags on unowned clones - [Low] prp_create_tagged_frame() (net/hsr/hsr_forward.c) still builds tagged frames with skb_copy_expand(). Pre-existing issues: - [Medium] This problem wasn't introduced by this patch, but hsr_create_tagged_frame() returns a bare skb_clone() in two places… -- hsr: Use skb_clone() while adding the HSR header This commit replaces __pskb_copy() in hsr_create_tagged_frame() with skb_clone() followed by skb_cow_head(). This keeps skb_shared_info, and any timestamp request in it, on the HSR tagged frame. The NETIF_F_HW_HSR_TAG_INS case now shares the same clone path, and skb_postpush_data_move() and skb_reset_mac_len() move the header and metadata and update mac_len.
> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c > index 44f6d9c83180a..b183358207506 100644 > --- a/net/hsr/hsr_forward.c > +++ b/net/hsr/hsr_forward.c
[ ... ]
> @@ -342,33 +341,40 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame, > /* set the lane id properly */ > hsr_set_path_id(frame, hsr_ethhdr, port); > return skb_clone(frame->skb_hsr, GFP_ATOMIC); > - } else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) { > - return skb_clone(frame->skb_std, GFP_ATOMIC); > } > > - /* Create the new skb with enough headroom to fit the HSR tag */ > - skb = __pskb_copy(frame->skb_std, > - skb_headroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC); > + skb = skb_clone(frame->skb_std, GFP_ATOMIC); > if (!skb) > return NULL; > - skb_reset_mac_header(skb); > > - if (skb->ip_summed == CHECKSUM_PARTIAL) > - skb->csum_start += HSR_HLEN; > + if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) > + return skb;
[Severity: Medium] Before this patch, __pskb_copy() went through skb_copy_header(), which only carries over the gso fields of skb_shared_info. The software tagged frames handed to the slaves therefore never had any SKBTX_* bits set. With skb_clone() that changes. __skb_clone() sets n->sk to NULL. Since frame->skb_std is still alive, skb_header_cloned() is true here, so skb_cow_head() always ends up in pskb_expand_head(). That copies the old skb_shared_info, tx_flags and tskey included, into the new private one. So the frames for SLAVE_A and SLAVE_B now reach the slave drivers with SKBTX_HW_TSTAMP still set and skb->sk == NULL. Drivers such as igb only look at the flag: drivers/net/ethernet/intel/igb/igb_main.c:igb_xmit_frame_ring() { ... if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { ... if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && !test_and_set_bit_lock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state)) { ... } The timestamp they eventually report is then thrown away by the !sk check in __skb_tstamp_tx(). Requesting SOF_TIMESTAMPING_TX_HARDWARE needs no privileges, so any socket sending over hsr0 can now take the single TX timestamp slot on both slaves for nothing. A ptp4l frame sent at the same time can then be skipped (tx_hwtstamp_skipped). "hsr: Assign a socket for cloned skbs" later in the series only calls skb_set_owner_w() when frame->req_tx_port != HSR_PT_NONE. hsr_dev_xmit() sets that only for ETH_P_1588 frames carrying the HSR_INLINE_HDR magic header. All other traffic still ends up with this combination at the end of the series. This path already owns a private skb_shared_info after skb_cow_head(). Would it make sense to clear SKBTX_ANY_TSTAMP there when the clone has no socket? Also, the commit message says skb_shared_info is shared via skb_clone() and skb_cow_head(). On this path pskb_expand_head() makes a private copy of it instead. Could that sentence be reworded? [Severity: Medium] This isn't a bug introduced by this patch, but the clone returned here still shares its head with frame->skb_std and with the clone made for the other port. The same applies to skb_clone(frame->skb_hsr) above. Is that safe, given what hsr_xmit() writes into the header afterwards? When frame->port_rcv is the master, hsr_xmit() does: net/hsr/hsr_forward.c:hsr_xmit() { ... if (frame->port_rcv->type == HSR_PT_MASTER) { hsr_addr_subst_dest(frame->node_src, skb, port); ... ether_addr_copy(eth_hdr(skb)->h_source, port->dev->dev_addr); } ... } hsr_addr_subst_dest() rewrites h_dest for only one of the ports: net/hsr/hsr_framereg.c:hsr_addr_subst_dest() { ... if (port->type != node_dst->addr_B_port) return; if (is_valid_ether_addr(node_dst->macaddress_B)) ether_addr_copy(eth_hdr(skb)->h_dest, node_dst->macaddress_B); } The h_source writes look harmless, because hsr_dev_finalize() gives both slaves the same MAC address. The h_dest substitution is per port, though. Take a slave with NETIF_F_HW_HSR_TAG_INS but without NETIF_F_HW_HSR_DUP, and a unicast destination node with a valid macaddress_B on SLAVE_B. Could port A's frame, still queued, go out with port B's macaddress_B as its destination? Taps that share the head would also see the rewritten addresses. The comment above hsr_create_tagged_frame() says "Otherwise, create a private frame especially tagged for 'port'", but only the non-offloaded path provides that. Should these clones also get a private header before they are returned? [ ... ]
> /* skb_put_padto free skb on error and hsr_fill_tag returns NULL in > * that case > */ > return hsr_fill_tag(skb, frame, port, port->hsr->prot_version); > +err: > + kfree_skb(skb); > + return NULL; > } > > struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame,
[Severity: Low] prp_create_tagged_frame() still builds its tagged frame with skb_copy_expand(): skb = skb_copy_expand(frame->skb_std, skb_headroom(frame->skb_std), skb_tailroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC); skb_copy_expand() ends in skb_copy_header(), which copies only gso_size, gso_segs and gso_type from skb_shared_info. Doesn't that mean PRP frames still lose the SKBTX_* tx_flags and tskey, the same loss this commit fixes for HSR? A later patch in the series, "hsr: Assign a socket for cloned skbs", says PRP is left out on purpose: "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." PRP also adds an RCT trailer rather than an HSR header, so it is outside the scope of this patch. Could the commit message say that PRP is intentionally left unchanged?
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40linutronix.de