Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp806827pxb; Tue, 3 Nov 2020 13:04:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTlT6N17upGr/vmKXL45LNpcAw4y5xxARqhx297yHlhdpAWMo+b9eW+z11uPr7pt512VsQ X-Received: by 2002:a17:906:12c1:: with SMTP id l1mr20991020ejb.528.1604437475108; Tue, 03 Nov 2020 13:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604437475; cv=none; d=google.com; s=arc-20160816; b=qxHynbixqXHsAP6ZPuc3c6AB4h1qq7T2i7tDxvy3fMNj4ftX0PDs4+Oe8RzOBLUtSJ 2FrCukWecvlBgRkKmjeOQqMXa3dVPh+mHBjx/i3tfXD/yTUjiwYqAyKmHdwfuo/6hIv3 giKVNYUKLs9Yp3DaqdLCDS8Av7wQE8f44uOePqLt67nHPGmhkuhwrSIb1QyzUVt5LIHo wI6inoSnnkUKpvEIjhAvPwKbTHxh8GFc8aAihikr5aRmLYItmANK8HnD07iZ6wJE8fp0 wzY8Bn1vk2daDtQFpBxn2JLsj7lA4meHNmLvOLxCjflhsmtcTtFXLhsFQAVPyBqosE6B B4iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5psMYOa2M9zGiBNTRl0HNGv2c7PP65gYbploewYJ7MM=; b=yGFhRkbLHZV4JiKDr6GpTpI+ECREHPduORczOJjXI4PT926QCrk0pYg7ijltZtYl/b +CwLG74LiJ1ZQL3arPmRT5Qzy8uSZQNDNTUZNa5wAsmZJd49PbBMekib9vGTgPISDc99 yS3VtUvNKp3rfzqiuBHsvuR62gCcDXy0gEVNrS7OSHkYy79oNNa5RkT2mx1jexRh8Do5 jP9qh+8xgTMfZU/sxgVOJ98I0WE/0c5Ry+HJiQz/JUj+266C2SSOs0mLJQekGgK01KA9 NoZ042bX6+OEZSt9JtMd1IXfP2F9Kjc8Y4J8H+NvTPI7vU3Dq+fWFPczfhwUSCXkqCBh U+uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yu9m6Kc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si4740ejy.256.2020.11.03.13.04.12; Tue, 03 Nov 2020 13:04:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yu9m6Kc5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733309AbgKCVA5 (ORCPT + 99 others); Tue, 3 Nov 2020 16:00:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:37052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733294AbgKCVAz (ORCPT ); Tue, 3 Nov 2020 16:00:55 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 460872053B; Tue, 3 Nov 2020 21:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437254; bh=yUq7I9Vxixg3t43C1knKc4vnMcQSvQauTmlZQZm4PEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yu9m6Kc5TJlrAO5JOq8ygtLwq5bZeo7u2FKEBcxaWitPL6tIrD2dfe74Zzh+JE0nw GtEv6zB6RJmH1idHLaDHDeVPaS+/ewecQxfDmjf7IpMPMqFwNUsHOUTPzvYD9dM5ir 1LO8yS7HT7n3RfuiPoS6qxwLfOFTbSQf0tuIgTTI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sverdlin Subject: [PATCH 5.4 213/214] staging: octeon: Drop on uncorrectable alignment or FCS error Date: Tue, 3 Nov 2020 21:37:41 +0100 Message-Id: <20201103203310.556111912@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Sverdlin commit 49d28ebdf1e30d806410eefc7de0a7a1ca5d747c upstream. Currently in case of alignment or FCS error if the packet cannot be corrected it's still not dropped. Report the error properly and drop the packet while making the code around a little bit more readable. Fixes: 80ff0fd3ab64 ("Staging: Add octeon-ethernet driver files.") Signed-off-by: Alexander Sverdlin Cc: stable Link: https://lore.kernel.org/r/20201016145630.41852-1-alexander.sverdlin@nokia.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rx.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -69,15 +69,17 @@ static inline int cvm_oct_check_rcv_erro else port = work->word1.cn38xx.ipprt; - if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) { + if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) /* * Ignore length errors on min size packets. Some * equipment incorrectly pads packets to 64+4FCS * instead of 60+4FCS. Note these packets still get * counted as frame errors. */ - } else if (work->word2.snoip.err_code == 5 || - work->word2.snoip.err_code == 7) { + return 0; + + if (work->word2.snoip.err_code == 5 || + work->word2.snoip.err_code == 7) { /* * We received a packet with either an alignment error * or a FCS error. This may be signalling that we are @@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_erro /* Port received 0xd5 preamble */ work->packet_ptr.s.addr += i + 1; work->word1.len -= i + 5; - } else if ((*ptr & 0xf) == 0xd) { + return 0; + } + + if ((*ptr & 0xf) == 0xd) { /* Port received 0xd preamble */ work->packet_ptr.s.addr += i; work->word1.len -= i + 4; @@ -118,21 +123,20 @@ static inline int cvm_oct_check_rcv_erro ((*(ptr + 1) & 0xf) << 4); ptr++; } - } else { - printk_ratelimited("Port %d unknown preamble, packet dropped\n", - port); - cvm_oct_free_work(work); - return 1; + return 0; } + + printk_ratelimited("Port %d unknown preamble, packet dropped\n", + port); + cvm_oct_free_work(work); + return 1; } - } else { - printk_ratelimited("Port %d receive error code %d, packet dropped\n", - port, work->word2.snoip.err_code); - cvm_oct_free_work(work); - return 1; } - return 0; + printk_ratelimited("Port %d receive error code %d, packet dropped\n", + port, work->word2.snoip.err_code); + cvm_oct_free_work(work); + return 1; } static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb)