Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v2 net-next 6/7] net: dsa: netc: add PTP two-step timestamping support
Date: Sun, 09 Aug 2026 03:19:07 +0000	[thread overview]
Message-ID: <20260809031907.888511F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260808032146.2335723-8-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Lazy garbage collection of timed-out TX SKBs permanently leaks sockets and network namespaces.
--

--- Patch [6]: [PATCH v2 net-next 6/7] net: dsa: netc: add PTP two-step timestamping support ---
commit b5b95ff6c72f97e31680784516eda771a0e7104f
Author: Wei Fang <wei.fang@nxp.com>
Date:   Sat Aug 8 03:21:45 2026 +0000

    net: dsa: netc: add PTP two-step timestamping support

This commit adds two-step TX timestamping and RX timestamping support for the
NETC switch. It installs ingress port filter table rules to redirect RX PTP
frames to the CPU port and handles TX timestamp requests and responses via
switch tags.

> diff --git a/drivers/net/dsa/netc/netc_ptp.c b/drivers/net/dsa/netc/netc_ptp.c
> new file mode 100644
> index 0000000000000..1384a6f31d1c1
> --- /dev/null
> +++ b/drivers/net/dsa/netc/netc_ptp.c

[ ... ]

> @@ -0,0 +1,454 @@

[ ... ]

> +static void netc_port_txtstamp_twostep(struct netc_port *np,
> +				       struct sk_buff *nskb)
> +{
> +	DECLARE_BITMAP(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);
> +	struct sk_buff *clone = skb_clone_sk(nskb);
> +	struct netc_switch *priv = np->switch_priv;
> +	struct sk_buff_head free_list;
> +	struct sk_buff *skb, *skb_tmp;
> +	unsigned long ts_req_id;
> +	int err = 0;
> +
> +	if (unlikely(!clone))
> +		return;
> +
> +	bitmap_zero(ts_req_id_bitmap, NETC_NUM_TS_REQ_ID);
> +	__skb_queue_head_init(&free_list);
> +	spin_lock_bh(&np->tstamp_lock);
> +
> +	skb_queue_walk_safe(&np->skb_txtstamp_queue, skb, skb_tmp) {
> +		if (time_before(NETC_SKB_CB(skb)->ptp_tx_time +
> +				NETC_TXTSTAMP_TIMEOUT, jiffies)) {

[Severity: High]
Does this lazy garbage collection of timed-out TX SKBs permanently leak sockets
and network namespaces?

When a frame requests a two-step hardware TX timestamp, skb_clone_sk() is used,
which takes a reference on the socket. If the frame is dropped in software
(e.g., due to qdisc drops or congestion) before reaching the hardware, the
hardware never generates a timestamp response, and the clone remains in
np->skb_txtstamp_queue.

Because the driver only lazily checks for timed-out SKBs here when a new PTP
packet is transmitted, the queue will not be purged if the application stops
transmitting or closes the socket. The stranded clone holds a reference to the
socket indefinitely, which in turn prevents the associated network namespace
from being destroyed.

> +			dev_dbg_ratelimited(priv->dev,
> +					    "Port %d ts_req_id %u which seems lost\n",
> +					    np->dp->index, NETC_SKB_CB(skb)->ts_req_id);
> +
> +			__skb_unlink(skb, &np->skb_txtstamp_queue);
> +			__skb_queue_tail(&free_list, skb);
> +		} else {
> +			__set_bit(NETC_SKB_CB(skb)->ts_req_id, ts_req_id_bitmap);
> +		}
> +	}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260808032146.2335723-1-wei.fang@oss.nxp.com?part=6

  reply	other threads:[~2026-08-09  3:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08  3:21 [PATCH v2 net-next 0/7] net: dsa: netc: add PTP support for NETC switch wei.fang
2026-08-08  3:21 ` [PATCH] net: dsa: netc: add PTP one-step timestamping support wei.fang
2026-08-08  3:26   ` Wei Fang
2026-08-08  3:21 ` [PATCH v2 net-next 1/7] ptp: netc: use ioread64_lo_hi/iowrite64_lo_hi for 64-bit register access wei.fang
2026-08-09  3:19   ` sashiko-bot
2026-08-08  3:21 ` [PATCH v2 net-next 2/7] ptp: netc: remove unnecessary pcie_flr() call in probe wei.fang
2026-08-09  3:19   ` sashiko-bot
2026-08-08  3:21 ` [PATCH v2 net-next 3/7] ptp: netc: export netc_timer_get_current_time() for cross-driver use wei.fang
2026-08-09  3:19   ` sashiko-bot
2026-08-10  1:30     ` Wei Fang (OSS)
2026-08-08  3:21 ` [PATCH v2 net-next 4/7] net: dsa: netc: use entry ID instead of pointer to track host flood rule wei.fang
2026-08-08  3:21 ` [PATCH v2 net-next 5/7] net: dsa: netc: enable ingress port filtering lookup by default wei.fang
2026-08-09  3:19   ` sashiko-bot
2026-08-10  2:40     ` Wei Fang (OSS)
2026-08-08  3:21 ` [PATCH v2 net-next 6/7] net: dsa: netc: add PTP two-step timestamping support wei.fang
2026-08-09  3:19   ` sashiko-bot [this message]
2026-08-10  3:33     ` Wei Fang (OSS)
2026-08-08  3:21 ` [PATCH v2 net-next 7/7] net: dsa: netc: add PTP one-step " wei.fang
2026-08-09  3:19   ` sashiko-bot
2026-08-10  7:31     ` Wei Fang (OSS)

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=20260809031907.888511F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@oss.nxp.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