Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11989493rwb; Sat, 26 Nov 2022 02:40:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nRwCMPlKBFyqUyi48QCSNmZYniO+uX17ge95X+lVuTdiggZEipr/tKU2kbcIH+Lk4Rjrx X-Received: by 2002:a17:907:cf84:b0:78d:4795:ff1f with SMTP id ux4-20020a170907cf8400b0078d4795ff1fmr37033092ejc.331.1669459206958; Sat, 26 Nov 2022 02:40:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669459206; cv=none; d=google.com; s=arc-20160816; b=MLe/WML/y+GQFQ2cH1PBMJ5kt5IQiipRSlGha3ZIWwFqTAUC4hjIhawQAxXvFE6osh zFzer7xLCGzmKx3S50hYD3INtD6KqEWilQhpYw8KhInGJITFDchziAXpmsboXJZ0q6PZ knX+l+PYyL2kuAZ9UYZf9D14u9GM1Iad0t+P29J/YgCLNv0ggYdNrIZeP4kiqPSwzIjj Fbmnt2zZgjYMhUep4aUIV0Om0Qi7sfrYrWNnv56tj2q9uk3D0wu3FT0ony1RVjDDJBwI +qFMhptLCccfjWBw+iVBbyjbbNqBXGt6Cz6gQeslxgMp9pX63aYW2ByaEdnaXFCvMIVJ ik9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=VTmMQU6pgrxn/0HIaoq2inW38bZWKM9i9ZQB1eGqiC8=; b=PFN1LampRJj+xmJFZ6w3kmT60sLwwQ9qOBefwxHr3nW9WfscIL27/ezpJRq2CXcgQ3 6Ck2Z0qqBVOnbd4OWHgdx8Bu4h8lgqmKVnREPWDxDj1IwbN9Sxkp8dGnIlbMQVW2qPNk oPneMH8E1JMOS+Zva+SZEZt8bbGkvLMXIjX9AolMGq+yAJQ2YBnm2/8j1fdA4D5ICYVj 8RYBMl6yTILXB9EticLI4yfJlsJ9vt3IZNepB9e9btzNfGgJess30J4I2vuSgG4n0NP5 u0FpBx0bRuYLqOxrH1mXBzgSTgK4ryOr2hGx7BNMno9Zb6U016IJgmJNci1Fih/nqEWr n+sQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg7-20020a170907a40700b007ae83c51922si5952127ejc.45.2022.11.26.02.39.45; Sat, 26 Nov 2022 02:40:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229543AbiKZK3E (ORCPT + 85 others); Sat, 26 Nov 2022 05:29:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiKZK27 (ORCPT ); Sat, 26 Nov 2022 05:28:59 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9F92655D for ; Sat, 26 Nov 2022 02:28:58 -0800 (PST) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oysQM-0000DK-Lc; Sat, 26 Nov 2022 11:28:42 +0100 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1oysQK-0004kT-5j; Sat, 26 Nov 2022 11:28:40 +0100 Date: Sat, 26 Nov 2022 11:28:40 +0100 From: Oleksij Rempel To: Devid Antonio Filoni Cc: Robin van der Gracht , Oleksij Rempel , kernel@pengutronix.de, Oliver Hartkopp , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] can: j1939: do not wait 250 ms if the same addr was already claimed Message-ID: <20221126102840.GA21761@pengutronix.de> References: <20221124051611.GA7870@pengutronix.de> <20221125170418.34575-1-devid.filoni@egluetechnologies.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20221125170418.34575-1-devid.filoni@egluetechnologies.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 25, 2022 at 06:04:18PM +0100, Devid Antonio Filoni wrote: > The ISO 11783-5 standard, in "4.5.2 - Address claim requirements", states: > d) No CF shall begin, or resume, transmission on the network until 250 > ms after it has successfully claimed an address except when > responding to a request for address-claimed. > > But "Figure 6" and "Figure 7" in "4.5.4.2 - Address-claim > prioritization" show that the CF begins the transmission after 250 ms > from the first AC (address-claimed) message even if it sends another AC > message during that time window to resolve the address contention with > another CF. > > As stated in "4.4.2.3 - Address-claimed message": > In order to successfully claim an address, the CF sending an address > claimed message shall not receive a contending claim from another CF > for at least 250 ms. > > As stated in "4.4.3.2 - NAME management (NM) message": > 1) A commanding CF can > d) request that a CF with a specified NAME transmit the address- > claimed message with its current NAME. > 2) A target CF shall > d) send an address-claimed message in response to a request for a > matching NAME > > Taking the above arguments into account, the 250 ms wait is requested > only during network initialization. > > Do not restart the timer on AC message if both the NAME and the address > match and so if the address has already been claimed (timer has expired) > or the AC message has been sent to resolve the contention with another > CF (timer is still running). > > Signed-off-by: Devid Antonio Filoni Acked-by: Oleksij Rempel > --- > v1 -> v2: Added ISO 11783-5 standard references > > net/can/j1939/address-claim.c | 40 +++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/net/can/j1939/address-claim.c b/net/can/j1939/address-claim.c > index f33c47327927..ca4ad6cdd5cb 100644 > --- a/net/can/j1939/address-claim.c > +++ b/net/can/j1939/address-claim.c > @@ -165,6 +165,46 @@ 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 ISO 11783-5 standard, in "4.5.2 - Address claim > + * requirements", states: > + * d) No CF shall begin, or resume, transmission on the > + * network until 250 ms after it has successfully claimed > + * an address except when responding to a request for > + * address-claimed. > + * > + * But "Figure 6" and "Figure 7" in "4.5.4.2 - Address-claim > + * prioritization" show that the CF begins the transmission > + * after 250 ms from the first AC (address-claimed) message > + * even if it sends another AC message during that time window > + * to resolve the address contention with another CF. > + * > + * As stated in "4.4.2.3 - Address-claimed message": > + * In order to successfully claim an address, the CF sending > + * an address claimed message shall not receive a contending > + * claim from another CF for at least 250 ms. > + * > + * As stated in "4.4.3.2 - NAME management (NM) message": > + * 1) A commanding CF can > + * d) request that a CF with a specified NAME transmit > + * the address-claimed message with its current NAME. > + * 2) A target CF shall > + * d) send an address-claimed message in response to a > + * request for a matching NAME > + * > + * Taking the above arguments into account, the 250 ms wait is > + * requested only during network initialization. > + * > + * Do not restart the timer on AC message if both the NAME and > + * the address match and so if the address has already been > + * claimed (timer has expired) or the AC message has been sent > + * to resolve the contention with another CF (timer is still > + * running). > + */ > + goto out_ecu_put; > + } > + > if (!ecu && j1939_address_is_unicast(skcb->addr.sa)) > ecu = j1939_ecu_create_locked(priv, name); > > -- > 2.34.1 > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |