Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3729695imm; Mon, 8 Oct 2018 08:37:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV62RFzy5UGXlr5rDShokIgU2ihNpNq02ZkQAcp8PsPAEW47CKDHKkcDjYFe6hDlQ1bi7zNyD X-Received: by 2002:a63:3285:: with SMTP id y127-v6mr22177925pgy.104.1539013034026; Mon, 08 Oct 2018 08:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013033; cv=none; d=google.com; s=arc-20160816; b=ACHYrmFHgZYXB79LB69+JL6YvQA2zYNh+eNNxwzpB5tlCIy5bFLAXjUtQGvuB1qTza SVt1ZENz9Z4/Nysd2XWKYEEgeQDwwpOJli1HFzhFRl0VSz4UpVDSoASZLFmv+K7U5FgV +KaHxcv/QTvgr8AkyHaCcw+ewY0egliKMT2377MCLRZDRfQtLzw+OFjAeldydJAP3GLX fj5iP64rNT+x1vGzbWEkiumtiuVPNMPeKqXS4NbSYYHRPZT7FD9IntZCIcGLaLQDHiqM 8GQkzDf9KjaDVocjoU5qDdnzimraLfJgbV3QUbVg2zdqSItxqAwvlOchueEYIOz3QjK/ OVJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dZo9H7BGjPK4nB16JmfYjLbJCeWN0uNhwK7rxseftHY=; b=QG/7ig29dSwsF4VjsEaVEK7IV6tmODBavyXrckE7dYo70veuxegzEbzfG2BmlpJKKl iKVVxV+jFRt2CtXb5wlkSbwxODulTQch359Iehz2CIs+rLudsN23atj8OJOR7911YbxD hDkIeh7UHGkY+dGKgpp2j7t6IVjqA/GmYoGYWjJYe3Ck+Ptv3Y1wyfljCcJDtXlRyDmz cJKMj4keh/ssgE0oqS7F+KrCRKgIAgN9mCGFkDIUlU0QezivcGWuqgR8Rj/zMr+Sk9Ul ZoU23XhOExxXjj7oOTpNKI5hIrAHM0QtxM9X7a6ZornUzaD/en+WVfU61cSOYWb4AVNj fdtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gXh4Lrbz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17-v6si18022497plp.335.2018.10.08.08.36.58; Mon, 08 Oct 2018 08:37:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gXh4Lrbz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbeJHWiW (ORCPT + 99 others); Mon, 8 Oct 2018 18:38:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:56802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbeJHWiV (ORCPT ); Mon, 8 Oct 2018 18:38:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72000214FA; Mon, 8 Oct 2018 15:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012366; bh=n0YveCtHLTwW8GiKDkUaXoKB65GoB7l/27hMIT4HNBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXh4LrbzoBgSCABlmulPoqgfKmUIJL3WOvxO9YPL+xxyTrBjFx8dEBTBb8XWbHzXX Fxa6GTWh1qN59EUd+mUQkHFRkxMPfLtc5OphmL/lLX3qbrrs7hne45ToOBsyMElVhD 5rndZDQxi2woWixgyI5amShpF4Uf9FmsEtimLk2Y= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Antoine Tenart , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.18 41/58] net: mscc: fix the frame extraction into the skb Date: Mon, 8 Oct 2018 11:25:06 -0400 Message-Id: <20181008152523.70705-41-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Antoine Tenart [ Upstream commit 652ef42c134da1bbb03bd4c9b4291dfaf8d7febb ] When extracting frames from the Ocelot switch, the frame check sequence (FCS) is present at the end of the data extracted. The FCS was put into the sk buffer which introduced some issues (as length related ones), as the FCS shouldn't be part of an Rx sk buffer. This patch fixes the Ocelot switch extraction behaviour by discarding the FCS. Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support") Signed-off-by: Antoine Tenart Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mscc/ocelot_board.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c index 18df7d934e81..ccfcf3048cd0 100644 --- a/drivers/net/ethernet/mscc/ocelot_board.c +++ b/drivers/net/ethernet/mscc/ocelot_board.c @@ -91,7 +91,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) struct sk_buff *skb; struct net_device *dev; u32 *buf; - int sz, len; + int sz, len, buf_len; u32 ifh[4]; u32 val; struct frame_info info; @@ -116,14 +116,20 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) err = -ENOMEM; break; } - buf = (u32 *)skb_put(skb, info.len); + buf_len = info.len - ETH_FCS_LEN; + buf = (u32 *)skb_put(skb, buf_len); len = 0; do { sz = ocelot_rx_frame_word(ocelot, grp, false, &val); *buf++ = val; len += sz; - } while ((sz == 4) && (len < info.len)); + } while (len < buf_len); + + /* Read the FCS and discard it */ + sz = ocelot_rx_frame_word(ocelot, grp, false, &val); + /* Update the statistics if part of the FCS was read before */ + len -= ETH_FCS_LEN - sz; if (sz < 0) { err = sz; -- 2.17.1