From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796434042; b=uAv6E2iVj99efgyU5lJuFcX4mAN+9zYc43XGOTIVYxd2VHG6rpPQ9Yp1ZQugnTX+Wc5C flVDF25cDlX6t2EcztFzJ9vqeQc0KKSzFckYjqdlzIEKsa9VizG8BqjvZd9bsFAhCjSTE s1t8XSD17db7LypbF+TwrYfaUQBH6Rp2rtFDUtE0os0fPedNloGE4nUWwIM5J9Oz1IRFI 2JrbHfUwYlJrNUR89SmyI/EtrJJUkxP8StJCYhcEYx3llrFf9ny4yq+RH6m9LlnHP2EYg V1MWgSh+JB9ZxhW5vZPXqQyYlYigb0hwTHeCqHiQ5swl6eSaQChcjA2OmCcNILhJZsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796434042; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=fGwmDV/+b38vhXTqjcEAakHFdgBQrCRB0BMF8k528qs=; b=MyMB5a2PRTQtOM58uxRVwoCAkFqdH/qVjYIOETdGxSnPP7l8YnY/8wPoUTw9l0m5njjg oBJsF1vocWZWXekmee2HQ0LTLrDldUsy4uNoOEyLRfx/BIYKG9C7ioBmQpcnDwD0g6eVo /7Ubvs6SzAhePbBU75aNPTRu8SXidU0KU9mKEv5TkyiafCRXKXlH/vJDuVX0acNV9XXtJ 62Eer4Ut1GQhKrdQyQSnlnUo+P+gKgN0ChCgk3VKLeENAwLC47e65HnJ5eJqs7ZwucKqR r/OacBXuANIcVTdjGNdNcfoDJlEG8spAw6fw0qq5Yp1vDqQhSGCUSkR+EQvurwyws2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mt+X6ctG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30964606A322 for ; Sat, 5 Dec 2026 01:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mt+X6ctG Received: by smtp.kernel.org (Postfix) with ESMTPSA id B88E51F0092B; Sat, 5 Dec 2026 01:27:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796434042; bh=fGwmDV/+b38vhXTqjcEAakHFdgBQrCRB0BMF8k528qs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=mt+X6ctGa16H9/9kKiyzgyRl7W0uK827beKozdYpkeXnv+FK4GoyiFpiHtp2IRx3M peOeWekMpoAPmtbI/o9xUnL3gXdK6urV5vy0lkOabOQRS4qv5QIOXjZABc59PMo7gd Gv82NHQ2YSIoN/ZS8FmeTTXZcqYfRApUdKdKjn8dv3brV6gG3ChTumPoeBDFlnoLCL ZI9T3ykkqQdcwEFX5e85Zb9XC+ZRjmbhIn29M03q3JYwtYMikZ4a8nZgzWLChnTBC6 cwta2tw13VlZUSrIKnWpZIIhQRZ+JXdp1A00g6nmmx55CtlSn1kF3RjmdEf6ShQ4lV HEPIJlFNjtFhg== Subject: Re: [PATCH can-next v5 09/24] can: isotp: add N_Ar timeout monitoring for FC From: netdev-bot+sashiko@kernel.org To: socketcan@hartkopp.net Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, kuba@kernel.org Date: Sat, 05 Dec 2026 01:27:21 +0000 Message-ID: <179643404128.3142.14055274426478600467@kernel.org> In-Reply-To: <20261203-getsockopt-memcg-isotp-v5-9-bbe89b3d3b71@hartkopp.net> References: <20261203-getsockopt-memcg-isotp-v5-9-bbe89b3d3b71@hartkopp.net> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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