From nobody Mon Feb 9 11:46:46 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BBC6345745 for ; Wed, 28 Jan 2026 09:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769592571; cv=none; b=mXM0Xc66b+e1xbf1uIepAHaLN34tyQPd/QMQ8vO3q57CNcRojJezweS70mZBV/F3p0YMZZdGuh5Fm4nQ2petDdghw/CM8QoUlWki/CBQfN8Lpb6Z74Kpx3g3SkQx8ydpZNpnDK4IJf6HEG4X2kIWY7QiR82OMQPsR2nByoLmgkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769592571; c=relaxed/simple; bh=WVu8/kqahlNbZGD8WK1R44jw+AVgtyIkl0iWAfZYO74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q2kZ66Ynb8B8dRAfKIKHv3fTIXFCeX6pOUI3DGFG8x0FWxJdSYZnoq9kRsdSprZr+/LbR2JBLYbBc+6QQ63OJ6h5MOYTzlTRZEj8H4R1myg93w8jomiZd9+HUy68MYrWj8v0oAtTUuQw2yllcW3Q9C12v303EjMi+cX0mzZyVTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vl1rN-0007xb-Mv; Wed, 28 Jan 2026 10:29:13 +0100 Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vl1rN-002tQM-24; Wed, 28 Jan 2026 10:29:13 +0100 Received: from hardanger.blackshift.org (p54b15bf8.dip0.t-ipconnect.de [84.177.91.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id A32044DA031; Wed, 28 Jan 2026 09:29:12 +0000 (UTC) From: Marc Kleine-Budde Date: Wed, 28 Jan 2026 10:28:58 +0100 Subject: [PATCH can-next v2 6/6] can: gw: use can_gw_hops instead of sk_buff::csum_start Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260128-can-skb-ext-v2-6-fe64aa152c8a@pengutronix.de> References: <20260128-can-skb-ext-v2-0-fe64aa152c8a@pengutronix.de> In-Reply-To: <20260128-can-skb-ext-v2-0-fe64aa152c8a@pengutronix.de> To: Marc Kleine-Budde , Vincent Mailhol , Oliver Hartkopp , Robin van der Gracht , Oleksij Rempel , kernel@pengutronix.de, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=2771; i=mkl@pengutronix.de; h=from:subject:message-id; bh=PqxHagvAwkQO9Lf5q1TvpNsqgySOE9ALOyhaXCgYc/I=; b=owEBbQGS/pANAwAKAQx0Zd/5kJGcAcsmYgBpedbmnCmd7pg6V2J/gIHUMyhBfsh4BovVkjgIM c/w7R7QCEeJATMEAAEKAB0WIQSf+wzYr2eoX/wVbPMMdGXf+ZCRnAUCaXnW5gAKCRAMdGXf+ZCR nLujB/9ErsWjPCf6h2BvdnHuxENIVNerpNC5grQGH4jEUdKyaLtf4pqeGETqSSAXjg7EfbK70/E 5NrVIPek73IXsSXEmPZxB31kve9dgER6RBf+BYHy2qC8Wc0K6i1Dm8pQePA+YqXRpWu1oESAylS pqsuM6+ufe1IntqdbT0MV54azsqgWXj5tBA5ePAVC5RRut1W0BKB49nNK38NRsfLzPl48mK0Thn SQvzvuB/LcmY4Snj1wSzNw6w3vIpVDdIpf2vligwec6sWz/f3KwzBMSxPbNJrT+UbKJT+DNhLlz FcvKgpSyFDfPmS04Dcdtr86YjFg06MBxV7Mr1rJw62Kut5fk X-Developer-Key: i=mkl@pengutronix.de; a=openpgp; fpr=C1400BA0B3989E6FBC7D5B5C2B5EE211C58AEA54 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org From: Oliver Hartkopp As CAN skbs don't use IP checksums the skb->csum_start variable was used to store the can-gw CAN frame time-to-live counter together with skb->ip_summed set to CHECKSUM_UNNECESSARY. Remove the 'hack' using the skb->csum_start variable and move the content to can_skb_ext::can_gw_hops of the CAN skb extensions. The module parameter 'max_hops' has been reduced to a single byte to fit can_skb_ext::can_gw_hops as the maximum value to be stored is 6. Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde --- net/can/gw.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/net/can/gw.c b/net/can/gw.c index ad89a1913b34..2c134c9e5159 100644 --- a/net/can/gw.c +++ b/net/can/gw.c @@ -71,8 +71,8 @@ MODULE_ALIAS(CAN_GW_NAME); #define CGW_MAX_HOPS 6 #define CGW_DEFAULT_HOPS 1 =20 -static unsigned int max_hops __read_mostly =3D CGW_DEFAULT_HOPS; -module_param(max_hops, uint, 0444); +static unsigned char max_hops __read_mostly =3D CGW_DEFAULT_HOPS; +module_param(max_hops, byte, 0444); MODULE_PARM_DESC(max_hops, "maximum " CAN_GW_NAME " routing hops for CAN frames " "(valid values: " __stringify(CGW_MIN_HOPS) "-" @@ -480,19 +480,8 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *= data) /* Do not handle CAN frames routed more than 'max_hops' times. * In general we should never catch this delimiter which is intended * to cover a misconfiguration protection (e.g. circular CAN routes). - * - * The Controller Area Network controllers only accept CAN frames with - * correct CRCs - which are not visible in the controller registers. - * According to skbuff.h documentation the csum_start element for IP - * checksums is undefined/unused when ip_summed =3D=3D CHECKSUM_UNNECESSA= RY. - * Only CAN skbs can be processed here which already have this property. */ - -#define cgw_hops(skb) ((skb)->csum_start) - - BUG_ON(skb->ip_summed !=3D CHECKSUM_UNNECESSARY); - - if (cgw_hops(skb) >=3D max_hops) { + if (csx->can_gw_hops >=3D max_hops) { /* indicate deleted frames due to misconfiguration */ gwj->deleted_frames++; return; @@ -532,11 +521,11 @@ static void can_can_gw_rcv(struct sk_buff *skb, void = *data) } =20 /* put the incremented hop counter in the cloned skb */ - cgw_hops(nskb) =3D cgw_hops(skb) + 1; + ncsx->can_gw_hops =3D csx->can_gw_hops + 1; =20 /* first processing of this CAN frame -> adjust to private hop limit */ - if (gwj->limit_hops && cgw_hops(nskb) =3D=3D 1) - cgw_hops(nskb) =3D max_hops - gwj->limit_hops + 1; + if (gwj->limit_hops && ncsx->can_gw_hops =3D=3D 1) + ncsx->can_gw_hops =3D max_hops - gwj->limit_hops + 1; =20 nskb->dev =3D gwj->dst.dev; =20 --=20 2.51.0