Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3210661pxb; Mon, 9 Nov 2020 05:41:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdV2uteYYjHYiHIbyVLMUF57Bj4W8u4rP8CzmrYYQckqQ1qKWfUl9NpTgvRQfMb4czT7hV X-Received: by 2002:a17:906:604e:: with SMTP id p14mr15843203ejj.515.1604929284361; Mon, 09 Nov 2020 05:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929284; cv=none; d=google.com; s=arc-20160816; b=VSAmeW9viO5f9vHVZm7DLOjpTA4oBSIDm9z2cVVR+SBU4C5qqYcQ2PCPv3GsMTMvsl j/DQ6pLPKxoLvSmpPqH7SDglHiH/Pf7Nkj74R1dcWhh5g0HvYGDVEvazX/v1PJUzeNIH IYNvsSfdGdHBXkILO6awrIq2eLN6kGRWsgC5DnIz0LPRvPGBI6cxMJB/j5xG/bHbyBPF Uyg4CEY3+24QQ65pMpZpp625XtYHorDXXBr4DrF6HnHWeeOZ7Oz/3HM00d1M3z96uTV/ UnVHbmS0OVUERFRH6RAsjiQ2j0hsA6lYE6mSB3FL0WT//qlzel5wxW8qqzgHEtAnQTvQ pYLQ== 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=r9klRk8Hl4YPIjM7fzu+GfIrCqmuknxEoVeye++uZc0=; b=SM8zvc/AAWMktyd377BT8DbAqmZf/md0AcZDX0aQgPnBNjy6C8pi+VFdeGMSf5NHwH +IIcAuA+qT8RFsM707+8DnDVhvL0OnO2QE0y/S51G8KX5ZzlJ71TRXqBM85Mv2DlKpxM JHmDXGOOl3sUsZSNl/4/63raCNwg/XOSwFAQQfKg8ZXMQZQackauSkKD9huyraUgytB/ GtL6M9bZE+SGo42VDBhUlUY0Ir400vVEu2i71jl4faDciP7Q7TuNm374UugicmExGTco JANnIO5oW4oLdXcPwFw5ttub+atTsPjXQs5oOYGDhF5W2ZcZ+GZEH7IVorvBMANorgyO HnYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zEC+L7Fq; 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 bu23si7118445ejb.83.2020.11.09.05.41.01; Mon, 09 Nov 2020 05:41:24 -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=zEC+L7Fq; 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 S1731877AbgKINhs (ORCPT + 99 others); Mon, 9 Nov 2020 08:37:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:57186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730574AbgKINEB (ORCPT ); Mon, 9 Nov 2020 08:04:01 -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 5834C206C0; Mon, 9 Nov 2020 13:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927040; bh=MtlvGRWe2qwEI7VVlrOQM0QQgFMweTtcax3lMK04H5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zEC+L7FqEDkFYzNP0K2n61QHw1H6iLmQARk4OCPT3tpYIRkT0SCVclJrdd246nYNd FqeCkfsDvuwlQXaoKmJTrkKi1wmSroCK7dmIwtIUB/aQU0Pm/rRFXd/rf1ev6GoO6x aOS0AMmbOdmWn2wpJbI053LH03a7Z7rBlu/Utby0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander Sverdlin Subject: [PATCH 4.9 091/117] staging: octeon: Drop on uncorrectable alignment or FCS error Date: Mon, 9 Nov 2020 13:55:17 +0100 Message-Id: <20201109125030.013078386@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@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 @@ -83,15 +83,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 @@ -122,7 +124,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; @@ -132,21 +137,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 int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)