[PATCH RESEND] can: j1939: do not wait 250ms if the same addr was already claimed

From: Devid Antonio Filoni
Date: Mon May 09 2022 - 13:05:05 EST


This is not explicitly stated in SAE J1939-21 and some tools used for
ISO-11783 certification do not expect this wait.

Fixes: 9d71dd0 ("can: add support of SAE J1939 protocol")
Signed-off-by: Devid Antonio Filoni <devid.filoni@xxxxxxxxxxxxxxxxxxxxx>
---
net/can/j1939/address-claim.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/can/j1939/address-claim.c b/net/can/j1939/address-claim.c
index f33c47327927..1d070c08edf1 100644
--- a/net/can/j1939/address-claim.c
+++ b/net/can/j1939/address-claim.c
@@ -165,6 +165,12 @@ static void j1939_ac_process(struct j1939_priv *priv, struct sk_buff *skb)
* leaving this function.
*/
ecu = j1939_ecu_get_by_name_locked(priv, name);
+
+ if (ecu && ecu->addr == skcb->addr.sa) {
+ /* the address was already claimed with the same name, nothing to do */
+ goto out_ecu_put;
+ }
+
if (!ecu && j1939_address_is_unicast(skcb->addr.sa))
ecu = j1939_ecu_create_locked(priv, name);

--
2.25.1