Skip to content

Commit d7321a4

Browse files
oleremsmb49
authored andcommitted
net: can: j1939: enhanced error handling for tightly received RTS messages in xtp_rx_rts_session_new
BugLink: https://bugs.launchpad.net/bugs/2076435 commit d3e2904f71ea0fe7eaff1d68a2b0363c888ea0fb upstream. This patch enhances error handling in scenarios with RTS (Request to Send) messages arriving closely. It replaces the less informative WARN_ON_ONCE backtraces with a new error handling method. This provides clearer error messages and allows for the early termination of problematic sessions. Previously, sessions were only released at the end of j1939_xtp_rx_rts(). Potentially this could be reproduced with something like: testj1939 -r vcan0:0x80 & while true; do # send first RTS cansend vcan0 18EC8090#1014000303002301; # send second RTS cansend vcan0 18EC8090#1014000303002301; # send abort cansend vcan0 18EC8090#ff00000000002301; done Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol") Reported-by: [email protected] Cc: [email protected] Signed-off-by: Oleksij Rempel <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Portia Stephens <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 9da468c commit d7321a4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

net/can/j1939/transport.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,8 +1593,8 @@ j1939_session *j1939_xtp_rx_rts_session_new(struct j1939_priv *priv,
15931593
struct j1939_sk_buff_cb skcb = *j1939_skb_to_cb(skb);
15941594
struct j1939_session *session;
15951595
const u8 *dat;
1596+
int len, ret;
15961597
pgn_t pgn;
1597-
int len;
15981598

15991599
netdev_dbg(priv->ndev, "%s\n", __func__);
16001600

@@ -1653,7 +1653,22 @@ j1939_session *j1939_xtp_rx_rts_session_new(struct j1939_priv *priv,
16531653
session->tskey = priv->rx_tskey++;
16541654
j1939_sk_errqueue(session, J1939_ERRQUEUE_RX_RTS);
16551655

1656-
WARN_ON_ONCE(j1939_session_activate(session));
1656+
ret = j1939_session_activate(session);
1657+
if (ret) {
1658+
/* Entering this scope indicates an issue with the J1939 bus.
1659+
* Possible scenarios include:
1660+
* - A time lapse occurred, and a new session was initiated
1661+
* due to another packet being sent correctly. This could
1662+
* have been caused by too long interrupt, debugger, or being
1663+
* out-scheduled by another task.
1664+
* - The bus is receiving numerous erroneous packets, either
1665+
* from a malfunctioning device or during a test scenario.
1666+
*/
1667+
netdev_alert(priv->ndev, "%s: 0x%p: concurrent session with same addr (%02x %02x) is already active.\n",
1668+
__func__, session, skcb.addr.sa, skcb.addr.da);
1669+
j1939_session_put(session);
1670+
return NULL;
1671+
}
16571672

16581673
return session;
16591674
}

0 commit comments

Comments
 (0)