From nobody Tue Feb 10 11:56:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1C475352C2E; Sat, 31 Jan 2026 13:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769865915; cv=none; b=f5NIhicSZNjVM0kfHtmJDSt5ESKWuYL/89wPLt/wZipdPJD07TQuXfWpl42IefFD4WJtmhrWliHOBRUE9uHpQXRwK0cF2yplErGl2Sz3UaC1Yj/OI3EArZqECxwVOgI0mHBzRelAmZMKYD2qX6toCPTDFaV19IJStntGxULaUQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769865915; c=relaxed/simple; bh=zf3WXPVkSFDzLsDWT4dV9ZRA9kjiomjTQb6KZWd1ANQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lsbz63kKH53JOOu7K2rXLg6gloDYEWgWs43AcH0PxQ5z6LcX4w9X7tguvIaGqvlKEi3uEPEwy6ytRjXNQgmDHmd4w5mAy9V+XQJItaWCx2gUCQfy+Qxof/t6Z65jMZb1ITIt9/R0KCURaxEM6omrgjJUHhNU0nc5RUbVHOTUI2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uo7mAC7r; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uo7mAC7r" Received: by smtp.kernel.org (Postfix) with ESMTPS id EBF41C2BCB7; Sat, 31 Jan 2026 13:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769865915; bh=zf3WXPVkSFDzLsDWT4dV9ZRA9kjiomjTQb6KZWd1ANQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=uo7mAC7rKB9ndz3MUF197/lQHeInV1b0l1JIzFjQavkHqtTd8sjYSn1qAJvnmCnVQ l9OQWVmTplvRPDnA/UavpWUbmnC/tJcfhf+GO7QgEZRlI+IkK/sMeXWpblH8mTeMz4 Idg4y1N8lb1oFncgYdwvGLklqSPstUGOdaFt2Lsh0Uo2EFBLn2yDpeVWSU4W39UnQe Wau+ALYHom5zXqfxyKQEUzmq7skYxEWtmW2EUssNSrHyZ5bFtZ7l218TmGhTReYbsv KxKN8ParUc4XRcdDx848Xt7PwGH1RDgemvA3gM5OUEkkMI9JecOoikB1HsXTyZwOYx nq9fREd8NXTiw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E45D8D79771; Sat, 31 Jan 2026 13:25:14 +0000 (UTC) From: Oliver Hartkopp via B4 Relay Date: Sat, 31 Jan 2026 14:25:11 +0100 Subject: [PATCH net-next v7 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: <20260131-can_skb_ext-v7-6-dd0f8f84a83d@hartkopp.net> References: <20260131-can_skb_ext-v7-0-dd0f8f84a83d@hartkopp.net> In-Reply-To: <20260131-can_skb_ext-v7-0-dd0f8f84a83d@hartkopp.net> 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=ed25519-sha256; t=1769865912; l=3632; i=socketcan@hartkopp.net; s=20260128; h=from:subject:message-id; bh=ov/1Nd5fmtdN4DViiwCnK/2y+He9qcgNw2oZkmdY3H8=; b=qCf8F5KQ+Ulb1P9YvkvH+SJ+7YVcT+z3gd+i0t9ZNQP2anpAKs7qNUyG1aQPujgkg0+ViP6cd NssymmS2ga0Bq43rJeoVo6OtG11jJsf5N23iqvTsD8yZt+lc9LHJCXS X-Developer-Key: i=socketcan@hartkopp.net; a=ed25519; pk=/gU/7/wBqak3kTsTeFbCCqUi9dnh+1i6ITEkfPj/BvU= X-Endpoint-Received: by B4 Relay for socketcan@hartkopp.net/20260128 with auth_id=620 X-Original-From: Oliver Hartkopp Reply-To: socketcan@hartkopp.net 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: Marc Kleine-Budde Signed-off-by: Oliver Hartkopp --- drivers/net/can/vxcan.c | 2 +- net/can/gw.c | 23 ++++++----------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c index 53d7d9046f85..60e5dad0694d 100644 --- a/drivers/net/can/vxcan.c +++ b/drivers/net/can/vxcan.c @@ -76,11 +76,11 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *oskb, str= uct net_device *dev) kfree_skb(oskb); goto out_unlock; } =20 /* reset CAN GW hop counter */ - skb->csum_start =3D 0; + csx->can_gw_hops =3D 0; skb->pkt_type =3D PACKET_BROADCAST; skb->dev =3D peer; skb->ip_summed =3D CHECKSUM_UNNECESSARY; =20 len =3D can_skb_get_data_len(skb); diff --git a/net/can/gw.c b/net/can/gw.c index 816154a978c1..61a1e6b1b83f 100644 --- a/net/can/gw.c +++ b/net/can/gw.c @@ -69,12 +69,12 @@ MODULE_ALIAS(CAN_GW_NAME); =20 #define CGW_MIN_HOPS 1 #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) "-" __stringify(CGW_MAX_HOPS) " hops, " "default: " __stringify(CGW_DEFAULT_HOPS) ")"); @@ -478,23 +478,12 @@ static void can_can_gw_rcv(struct sk_buff *skb, void = *data) return; =20 /* 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; } =20 @@ -534,15 +523,15 @@ static void can_can_gw_rcv(struct sk_buff *skb, void = *data) gwj->dropped_frames++; return; } =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 /* pointer to modifiable CAN frame */ cf =3D (struct canfd_frame *)nskb->data; --=20 2.51.0