From mboxrd@z Thu Jan 1 00:00:00 1970 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 718B8156C40; Mon, 16 Sep 2024 12:08:50 +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=1726488530; cv=none; b=hvKpa+7QtqoZgV+KzxKeqVHkMBxLzwmpfAMBh7F0mM+L49toj4xzyU27Xlp1BjWryGq7SiBHmUHYzmtiD+HFH7+uc5UUWaLWBpuIi0+b4GknnldS2JrHyVfxE2NYE5ynzTmUdCKUr85dP2nC8DbMG6DnT9HcdfF0jf7DvP+praI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488530; c=relaxed/simple; bh=U/1RJmhci2gZUf38P7j8c5mkA6h9xXFuLScxDCBmroo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CuhXgDReHkjwLJfABkW9eNuehDYK+0dqCNLHbD+DsmZ75F+WOQmJvo0qXf3cOApQcbLeRU151faGEiJl/9clBrxMMUknvgjfYZ6brV1yqWLw/AmpJDHVbAAZVukUiF5khuAra10Hm0+IOoNhuOZFIA+n8oWMXpbWxpwrHgy7Biw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sAobL2wo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sAobL2wo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDE84C4CEC4; Mon, 16 Sep 2024 12:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1726488530; bh=U/1RJmhci2gZUf38P7j8c5mkA6h9xXFuLScxDCBmroo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sAobL2wocooI6Vxw859z22de63iFIGT3GfeCchgsAUAC+5q6jlzhKSPPtLqXfSD2K phVcgDb1rYuc/WwxlhSL8Rl03eO2eO/EWUWg3wDDBnnyAjgf7zlAVqulpceOBzL1na ORNx0qOtJp6baspUosFngFB/Eo3VZuPF5Gxn4Qt4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Moon Yeounsu , Christophe JAILLET , "David S. Miller" , Sasha Levin Subject: [PATCH 6.6 16/91] net: ethernet: use ip_hdrlen() instead of bit shift Date: Mon, 16 Sep 2024 13:43:52 +0200 Message-ID: <20240916114225.065655928@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240916114224.509743970@linuxfoundation.org> References: <20240916114224.509743970@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moon Yeounsu [ Upstream commit 9a039eeb71a42c8b13408a1976e300f3898e1be0 ] `ip_hdr(skb)->ihl << 2` is the same as `ip_hdrlen(skb)` Therefore, we should use a well-defined function not a bit shift to find the header length. It also compresses two lines to a single line. Signed-off-by: Moon Yeounsu Reviewed-by: Christophe JAILLET Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/jme.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 1732ec3c3dbd..a718207988f2 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c @@ -946,15 +946,13 @@ jme_udpsum(struct sk_buff *skb) if (skb->protocol != htons(ETH_P_IP)) return csum; skb_set_network_header(skb, ETH_HLEN); - if ((ip_hdr(skb)->protocol != IPPROTO_UDP) || - (skb->len < (ETH_HLEN + - (ip_hdr(skb)->ihl << 2) + - sizeof(struct udphdr)))) { + + if (ip_hdr(skb)->protocol != IPPROTO_UDP || + skb->len < (ETH_HLEN + ip_hdrlen(skb) + sizeof(struct udphdr))) { skb_reset_network_header(skb); return csum; } - skb_set_transport_header(skb, - ETH_HLEN + (ip_hdr(skb)->ihl << 2)); + skb_set_transport_header(skb, ETH_HLEN + ip_hdrlen(skb)); csum = udp_hdr(skb)->check; skb_reset_transport_header(skb); skb_reset_network_header(skb); -- 2.43.0