Skip to content

Commit b1f4fba

Browse files
committed
Merge tag 'linux-can-fixes-for-6.2-20230207' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== can 2023-02-07 The patch is from Devid Antonio Filoni and fixes an address claiming problem in the J1939 CAN protocol. * tag 'linux-can-fixes-for-6.2-20230207' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can: can: j1939: do not wait 250 ms if the same addr was already claimed ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents c6aa9d3 + 4ae5e1e commit b1f4fba

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

net/can/j1939/address-claim.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,46 @@ static void j1939_ac_process(struct j1939_priv *priv, struct sk_buff *skb)
165165
* leaving this function.
166166
*/
167167
ecu = j1939_ecu_get_by_name_locked(priv, name);
168+
169+
if (ecu && ecu->addr == skcb->addr.sa) {
170+
/* The ISO 11783-5 standard, in "4.5.2 - Address claim
171+
* requirements", states:
172+
* d) No CF shall begin, or resume, transmission on the
173+
* network until 250 ms after it has successfully claimed
174+
* an address except when responding to a request for
175+
* address-claimed.
176+
*
177+
* But "Figure 6" and "Figure 7" in "4.5.4.2 - Address-claim
178+
* prioritization" show that the CF begins the transmission
179+
* after 250 ms from the first AC (address-claimed) message
180+
* even if it sends another AC message during that time window
181+
* to resolve the address contention with another CF.
182+
*
183+
* As stated in "4.4.2.3 - Address-claimed message":
184+
* In order to successfully claim an address, the CF sending
185+
* an address claimed message shall not receive a contending
186+
* claim from another CF for at least 250 ms.
187+
*
188+
* As stated in "4.4.3.2 - NAME management (NM) message":
189+
* 1) A commanding CF can
190+
* d) request that a CF with a specified NAME transmit
191+
* the address-claimed message with its current NAME.
192+
* 2) A target CF shall
193+
* d) send an address-claimed message in response to a
194+
* request for a matching NAME
195+
*
196+
* Taking the above arguments into account, the 250 ms wait is
197+
* requested only during network initialization.
198+
*
199+
* Do not restart the timer on AC message if both the NAME and
200+
* the address match and so if the address has already been
201+
* claimed (timer has expired) or the AC message has been sent
202+
* to resolve the contention with another CF (timer is still
203+
* running).
204+
*/
205+
goto out_ecu_put;
206+
}
207+
168208
if (!ecu && j1939_address_is_unicast(skcb->addr.sa))
169209
ecu = j1939_ecu_create_locked(priv, name);
170210

0 commit comments

Comments
 (0)