From patchwork Wed Feb 28 08:56:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 13575071 X-Patchwork-Delegate: kuba@kernel.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABD642E83F for ; Wed, 28 Feb 2024 08:57:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110633; cv=none; b=UnYISktSsuYKpueFlrTmPBzKeny9ppK2PZiHAH4jon7nNCLQrHHetSm1lnHaqkgT2T7uhmuc4r7xm5TIR0g/nZha7Irk818wd4JQQ1zfKfUoUAj7GntPNowb4ZJGWLe9XjBUsnpesxvhRzfifhAJwF2vAQXzOUyzwY4/BrIuNvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709110633; c=relaxed/simple; bh=CFmQs1hUchX1CA4A9NNW6SX0KfyqP2OlQweDEldWOWY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=EObQeSlZy/ist/orPlKPhHX5yruYMdij5x3UnNye9fXZTx+8wGub7PCIvaUCGp1OfdFlfNDJId/vLFNmyE/ZSOT2g5tetLTlq/94fbIPA8CWIMZ8GT4mwXtdZxq/+os277DDw7cS7NuflK9/1ILd7NiWsY2YbBm2tGt01u2RT1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=XYWRf9FI; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="XYWRf9FI" Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 3B99587DC2; Wed, 28 Feb 2024 09:57:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1709110629; bh=LqWrJ6MXrX71B8Nztq7mqbMnfSBpJcjZJZK33jnQTfw=; h=From:To:Cc:Subject:Date:From; b=XYWRf9FIwtzJkbmTCOZ5jum4FIBZ1cCmS9sl5nQPRtJrVUU3eHYaiql/ZGXXQGwzm s/NHfC4djG/8kBHZLHv+Y3T0FaGO20ZOAYoD0/RArTLN4VbTJ/v5WSi+IhdI38O9mC 6O7PnqtsjjpPpWNefA+R7De1m0Y0Cwuk6jxfP2buN5tQG5R9r/u4cl1LJ72ORacbMX kMLsq+U8YmICXeTPwvpPuwAs56/bFZbou8SgRVN09ZiBKDDzm/C/meNEsGiKf0w62G N7tLThzXlQeuZKVU+XGq5g/EmoB6/RHlo1w+3t/cuH6jhBQprtSpCcNT1R/USNpCPE U/8RTFRxCrkTA== From: Lukasz Majewski To: Oleksij Rempel Cc: Andrew Lunn , Eric Dumazet , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, Tristram.Ha@microchip.com, Sebastian Andrzej Siewior , Lukasz Majewski Subject: [PATCH v2] net: hsr: Use correct offset for HSR TLV values in supervisory HSR frames Date: Wed, 28 Feb 2024 09:56:44 +0100 Message-Id: <20240228085644.3618044-1-lukma@denx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Patchwork-Delegate: kuba@kernel.org Current HSR implementation uses following supervisory frame (even for HSRv1 the HSR tag is not is not present): 00000000: 01 15 4e 00 01 2d XX YY ZZ 94 77 10 88 fb 00 01 00000010: 7e 1c 17 06 XX YY ZZ 94 77 10 1e 06 XX YY ZZ 94 00000020: 77 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00000030: 00 00 00 00 00 00 00 00 00 00 00 00 The current code adds extra two bytes (i.e. sizeof(struct hsr_sup_tlv)) when offset for skb_pull() is calculated. This is wrong, as both 'struct hsrv1_ethhdr_sp' and 'hsrv0_ethhdr_sp' already have 'struct hsr_sup_tag' defined in them, so there is no need for adding extra two bytes. This code was working correctly as with no RedBox support, the check for HSR_TLV_EOT (0x00) was off by two bytes, which were corresponding to zeroed padded bytes for minimal packet size. Fixes: eafaa88b3eb7 ("net: hsr: Add support for redbox supervision frames") Signed-off-by: Lukasz Majewski Reviewed-by: Jiri Pirko --- Changes for v2: - Update commit message to point to correct commit in "Fixes:" --- net/hsr/hsr_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index 2afe28712a7a..5d68cb181695 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -83,7 +83,7 @@ static bool is_supervision_frame(struct hsr_priv *hsr, struct sk_buff *skb) return false; /* Get next tlv */ - total_length += sizeof(struct hsr_sup_tlv) + hsr_sup_tag->tlv.HSR_TLV_length; + total_length += hsr_sup_tag->tlv.HSR_TLV_length; if (!pskb_may_pull(skb, total_length)) return false; skb_pull(skb, total_length);