From: netdev-bot+sashiko@kernel.org
To: socketcan@hartkopp.net
Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, kuba@kernel.org
Subject: Re: [PATCH can-next v5 09/24] can: isotp: add N_Ar timeout monitoring for FC
Date: Sat, 05 Dec 2026 01:27:21 +0000 [thread overview]
Message-ID: <179643404128.3142.14055274426478600467@kernel.org> (raw)
In-Reply-To: <20261203-getsockopt-memcg-isotp-v5-9-bbe89b3d3b71@hartkopp.net>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] Documentation is incomplete, and one new comment overstates what
the code does.
- [Low] A late FC local echo restarts the N_Cr timer even after a CF has
already proven that the FC was sent.
--
can: isotp: add N_Ar timeout monitoring for FC
This patch uses the CAN local echo to supervise transmission of the flow
control frame on the receiver side (N_Ar). The FC skb gets its own uid,
stored in so->fcecho. When isotp_rcv_echo() sees that echo, it starts
the CF timeout (N_Cr). Before this change, N_Cr started when the FC
transmission was requested.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 368e50bd82fd7..d1f98c8d5c851 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
[ ... ]
> @@ -339,6 +344,9 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
>
> ncf->flags = so->ll.tx_flags;
>
> + /* set flow control echo tag to start the CF timeout */
> + WRITE_ONCE(so->fcecho, csx->can_skb_uid);
> +
> can_send_ret = can_send(nskb, 1);
> if (can_send_ret)
> pr_notice_once("can-isotp: %s: can_send_ret %pe\n",
> @@ -352,7 +360,7 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
> /* reset last CF frame rx timestamp for rx stmin enforcement */
> so->lastrxcf_tstamp = ktime_set(0, 0);
>
> - /* start rx timeout watchdog */
> + /* start rx timeout watchdog for the FC transmission (N_Ar) */
> hrtimer_start(&so->rxtimer, ktime_set(ISOTP_TIMEOUT, 0),
> HRTIMER_MODE_REL_SOFT);
[Severity: Low]
Is this comment accurate for an FC with overflow status? isotp_rcv_ff()
sets rx.state to ISOTP_IDLE before it sends the overflow FC:
net/can/isotp.c:isotp_rcv_ff() {
hrtimer_cancel(&so->rxtimer);
WRITE_ONCE(so->rx.state, ISOTP_IDLE);
...
if (so->rx.len > so->rx.buflen) {
/* send FC frame with overflow status */
isotp_send_fc(sk, ae, ISOTP_FC_OVFLW);
return 1;
}
...
}
isotp_rx_timer_handler() only acts when rx.state is ISOTP_WAIT_DATA. So
for ISOTP_FC_OVFLW this N_Ar watchdog does nothing.
There is a related documentation gap. With this change, an FC whose local
echo never arrives is reported as ETIMEDOUT by isotp_rx_timer_handler().
That function still describes the condition as "we did not get new data
frames in time".
The RX error table in Documentation/networking/iso15765-2.rst still reads:
-ETIMEDOUT timeout of data reception
The header comment in net/can/isotp.c also still reads:
* - RX path timeout of data reception leads to -ETIMEDOUT
The earlier N_As patch in this series updated the TX entries to "flow
control or local echo reception timeout" for -ECOMM.
Could the RX entries be extended in the same way to cover the FC local
echo timeout?
> return 0;
[ ... ]
> @@ -1008,6 +1016,16 @@ static void isotp_rcv_echo(struct sk_buff *skb, void *data)
> */
> spin_lock(&so->rx_lock);
>
> + /* the FC has been sent => start the CF timeout (N_Cr) */
> + if (READ_ONCE(so->fcecho) == csx->can_skb_uid) {
> + WRITE_ONCE(so->fcecho, 0);
> + if (READ_ONCE(so->rx.state) == ISOTP_WAIT_DATA)
> + hrtimer_start(&so->rxtimer,
> + ktime_set(ISOTP_TIMEOUT, 0),
> + HRTIMER_MODE_REL_SOFT);
[Severity: Low]
What happens if the peer's first CF is handled before this FC echo
arrives?
isotp_rcv_cf() restarts so->rxtimer for 1 s on every valid CF, but it
leaves so->fcecho set:
net/can/isotp.c:isotp_rcv_cf() {
...
/* start rx timeout, isotp_send_fc() restarts it */
hrtimer_start(&so->rxtimer, ktime_set(ISOTP_TIMEOUT, 0),
HRTIMER_MODE_REL_SOFT);
...
}
When the late FC echo then reaches isotp_rcv_echo(), so->fcecho still
matches and rx.state is ISOTP_WAIT_DATA, so rxtimer is restarted once
more. N_Cr then counts from when the echo is processed, not from the last
CF reception. That stretches the timeout by the echo latency, which is
always under 1 s.
This ordering looks possible. The echo comes through netif_rx() or the
driver's TX completion, while the CF comes through the normal RX path.
On the TX side, isotp_rcv_fc() handles the matching case (peer reply
before our own echo) by clearing the pending tag:
if (READ_ONCE(so->tx.state) == ISOTP_WAIT_FIRST_FC) {
hrtimer_cancel(&so->echotimer);
WRITE_ONCE(so->cfecho, 0);
}
A received CF already proves the FC was sent. Should isotp_rcv_cf() clear
so->fcecho in the same way?
The commit message says:
A CF that is received before the local echo of the FC restarts the rx
timeout as before.
It doesn't say that the late echo restarts the timeout again after that.
> + goto out_unlock;
> + }
> +
> /* so->cfecho may since belong to a new transfer; recheck under lock */
> if (READ_ONCE(so->cfecho) != csx->can_skb_uid)
> goto out_unlock;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-getsockopt-memcg-isotp-v5-0-bbe89b3d3b71%40hartkopp.net
next prev parent reply other threads:[~2026-12-05 1:27 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:55 [PATCH can-next v5 00/24] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-12-03 11:55 ` [PATCH can-next v5 01/24] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-12-03 11:55 ` [PATCH can-next v5 02/24] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-12-03 12:22 ` sashiko-bot
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 03/24] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-12-03 12:41 ` sashiko-bot
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 04/24] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 05/24] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 06/24] can: isotp: add the frame transmission time to the CF broadcast gap Oliver Hartkopp
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 07/24] can: isotp: limit the frame transmission time to the N_As/N_Ar timeout Oliver Hartkopp
2026-12-03 11:55 ` [PATCH can-next v5 08/24] can: isotp: add N_As timeout monitoring for SF/FF/CF Oliver Hartkopp
2026-12-03 14:11 ` sashiko-bot
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:55 ` [PATCH can-next v5 09/24] can: isotp: add N_Ar timeout monitoring for FC Oliver Hartkopp
2026-12-03 14:30 ` sashiko-bot
2026-12-05 1:27 ` netdev-bot+sashiko [this message]
2026-12-03 11:56 ` [PATCH can-next v5 10/24] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-12-03 14:50 ` sashiko-bot
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:56 ` [PATCH can-next v5 11/24] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 12/24] can: isotp: ignore CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 13/24] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 14/24] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 15/24] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 16/24] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 17/24] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 18/24] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-12-05 1:27 ` netdev-bot+sashiko
2026-12-03 11:56 ` [PATCH can-next v5 19/24] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 20/24] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 21/24] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 22/24] can: isotp: change return type of functions to void Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 23/24] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-12-03 11:56 ` [PATCH can-next v5 24/24] can: isotp: introduce CAN_ISOTP_MIN_TX_DL Oliver Hartkopp
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=179643404128.3142.14055274426478600467@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
/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