Received: by 2002:a05:6622:f08:0:0:0:0 with SMTP id l8csp4488576ivc; Tue, 3 Nov 2020 13:22:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSM4TrHaI0+B6k9eIdUwuO/lgK5jmnHcv+xOdcAwVO/mvLzO7ZyOYaAie0xTg0953SLpEp X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr15221439edp.66.1604438541011; Tue, 03 Nov 2020 13:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438541; cv=none; d=google.com; s=arc-20160816; b=D5sUigbO3lSTyVgRzKPSzoITMeVduy5Cia+PNx2IjJtmuttx6/n8NVoNxkgdX3fhr7 Kwaimn6aqvUU3a1kOpKbqOYnqhRGsRs9naWPVmBkvel6p/S1zQbvzAycW8dtkoZ2OGTD ahlclSVjRlGmGbs34PtYOvztMa9VtFpOmQ3jmmFnTpJulXVkTusRBm8l+vCLl5TI/8gB uwGSOrtZBSx+zd2KGApovoacpaC60gbUtjrbiiYOWcq8F9kmT8OtOLmKBa6fNirtEgu9 EsMJ5m04QxMB6rOeA7162MlVOSgkB1AK+flo7AmD1SWvL2aqVDGPAkoHSEW1G5n/owgK bd6g== 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=gF1wLdu1K1kJ6KyK+8MhjQvGkOf6TMuwb2Xkm1p8cl0=; b=Gu97dhW+IceFGhuUAO5hzR/SbxXoZChTJ5AlYy9s2hKX3XVIcQa9y2yFcCrr0eofAy R/AHcXBDG11WTMMQYh62wGqFl3+f5UZWSDWuWHGSqz6VJ76G4lbcUJNGe0AJj2NDuC+n 2GqV70PNLZQYGOlmw50K2QcHuNmBt061krHRbsdOuwsoqPPwgp7mtlhQF+PkLpvsPHE8 9l2lsZ5eKRrxB2KHC0nPScqNWS7X8vzN2Ke+o/hjkvEv3vpmK4Wj59dfFuEfksBLBP8C arJ2uGANgbk0kmpm6qYbdR1HlLmOT11Dnz66xsLsUqwgqMdy8dmhoyRdffrbYq0tTwFM Jo/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AL4Qnnq6; 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 e10si12007103edc.106.2020.11.03.13.21.57; Tue, 03 Nov 2020 13:22:20 -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=AL4Qnnq6; 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 S2388432AbgKCVIc (ORCPT + 99 others); Tue, 3 Nov 2020 16:08:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:47880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388437AbgKCVI3 (ORCPT ); Tue, 3 Nov 2020 16:08:29 -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 DCF74205ED; Tue, 3 Nov 2020 21:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437708; bh=IWEh56u87Cs6dYeC6BIPkFHiQMdL4trEXbO7sVHIeds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AL4Qnnq6P9UZswIJSMiS5xvzpkhof0n/V70uumbYSIuWjK+hXblSamdfe0HY/r5iE F9Sxp4O/z26hs58nfC5WuSKOwnjuh8AiNCifZB7a47/2imcvgLfM3zjexXjzbf3lLH 4rF2numZzbqr9iFW3Zw+ZV2VGqL7TB6tmTEXnRD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sverdlin Subject: [PATCH 4.19 191/191] staging: octeon: Drop on uncorrectable alignment or FCS error Date: Tue, 3 Nov 2020 21:38:03 +0100 Message-Id: <20201103203250.761067158@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 @@ -80,15 +80,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 @@ -119,7 +121,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; @@ -129,21 +134,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)