Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4922221imc; Mon, 25 Feb 2019 13:42:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IYcxc+ows+Xr5r5fk090QWdKUBOBmsiAQOG9FKdwR2W5I95TIEhtAdsUWTe+pxrLeLQAWqv X-Received: by 2002:a63:4342:: with SMTP id q63mr21131402pga.63.1551130937488; Mon, 25 Feb 2019 13:42:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551130937; cv=none; d=google.com; s=arc-20160816; b=hG8DzA47TuC8WAVrVZxsce1TMIIup9qF2cOpiXXcR1q7tEyg4MQSiPn6C6oXYmLZZG tCMl4cPuUp7uDG8uiN7kG4LASCuwYll4MsEFZoY6sDBfU6nJQ46JtTadbvv/XTSTJbxI 8RHtb4+kvRxsPWgBYBbyedzmO5ZKId2qVr07tNNDufp4A059a+1uKcluSc9j/RXx0OH+ PP0G4rPW2idfLI9uwhjLOWjd7tf1mVSQn+gkWLCfXREaK+a8gs13pc4FevlOuT5ZVYve JuCwVjXbm/OvSTcltRXt2lQDoMiixG5kRCfnm0k2ctm08JSlp37Dfo+fVagbRSFxJjhH aSOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E4tdKOUleOA71QFGnwRpHjJpUlx2PyR/ldLHrJSOkgM=; b=wAQeZuIDfmyEL2h1CvMsyhvMp8H5e6y3xRQuHsSuf6dn+RmKa9I7e/9MV9SrS6U4dE 5n2WQzFcuD5gbompTykmuWMqIY+xpUWmSma2bQdJ/0Sy0+4sp8N54kIOaFwQeqx0bec9 Ba2NNoreP9xX/FrDWk+ysmtlTD9NROBGdkHLv7A4QjfbkVYxF4jal/8uRMBt6E40zwUL E5yBXfREtphPF+88VGdvndxc4FWfObYCn3N349smFpMvglf/w9V20YRGVAhukoqrsRKx NQfJKvi86/vtliwSDzjPoi5JUG99Zz3r6X+2hd4DwaPdiBKYK/KzqlKfXpIN3YKDjicF Huxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LiompUkM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23si10386086pgk.54.2019.02.25.13.42.02; Mon, 25 Feb 2019 13:42:17 -0800 (PST) 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=LiompUkM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732389AbfBYVeR (ORCPT + 99 others); Mon, 25 Feb 2019 16:34:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:40494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732788AbfBYVeP (ORCPT ); Mon, 25 Feb 2019 16:34:15 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 9497A20578; Mon, 25 Feb 2019 21:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551130454; bh=MgpIExTFyEDj+4qqdEctvPVj9nsrFADLJOZSpW7oOX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiompUkMWt6DK2kH7+3C8f/U/sOjJ1QYmdYya+1U+8lp6e+4ixps2TrqmTQUwV1rL p6gOUyiJL1uUa8vi3Ig+egeBBAT7g801aPWfL9uciyBmAcV6LEuEPnW/zSofGbQepX BIyseStEkAkfddXRcVmmaDtUAeUrj9s9+4Bads+A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Saeed Mahameed , Tariq Toukan , "David S. Miller" Subject: [PATCH 4.20 126/183] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Date: Mon, 25 Feb 2019 22:11:39 +0100 Message-Id: <20190225195115.958152604@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195054.748060397@linuxfoundation.org> References: <20190225195054.748060397@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Saeed Mahameed [ Upstream commit 29dded89e80e3fff61efb34f07a8a3fba3ea146d ] When an ethernet frame is padded to meet the minimum ethernet frame size, the padding octets are not covered by the hardware checksum. Fortunately the padding octets are usually zero's, which don't affect checksum. However, it is not guaranteed. For example, switches might choose to make other use of these octets. This repeatedly causes kernel hardware checksum fault. Prior to the cited commit below, skb checksum was forced to be CHECKSUM_NONE when padding is detected. After it, we need to keep skb->csum updated. However, fixing up CHECKSUM_COMPLETE requires to verify and parse IP headers, it does not worth the effort as the packets are so small that CHECKSUM_COMPLETE has no significant advantage. Future work: when reporting checksum complete is not an option for IP non-TCP/UDP packets, we can actually fallback to report checksum unnecessary, by looking at cqe IPOK bit. Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends") Cc: Eric Dumazet Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -620,6 +620,8 @@ static int get_fixed_ipv6_csum(__wsum hw } #endif +#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) + /* We reach this function only after checking that any of * the (IPv4 | IPv6) bits are set in cqe->status. */ @@ -627,9 +629,20 @@ static int check_csum(struct mlx4_cqe *c netdev_features_t dev_features) { __wsum hw_checksum = 0; + void *hdr; - void *hdr = (u8 *)va + sizeof(struct ethhdr); + /* CQE csum doesn't cover padding octets in short ethernet + * frames. And the pad field is appended prior to calculating + * and appending the FCS field. + * + * Detecting these padded frames requires to verify and parse + * IP headers, so we simply force all those small frames to skip + * checksum complete. + */ + if (short_frame(skb->len)) + return -EINVAL; + hdr = (u8 *)va + sizeof(struct ethhdr); hw_checksum = csum_unfold((__force __sum16)cqe->checksum); if (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_CVLAN_PRESENT_MASK) && @@ -822,6 +835,11 @@ xdp_drop_no_cnt: skb_record_rx_queue(skb, cq_ring); if (likely(dev->features & NETIF_F_RXCSUM)) { + /* TODO: For IP non TCP/UDP packets when csum complete is + * not an option (not supported or any other reason) we can + * actually check cqe IPOK status bit and report + * CHECKSUM_UNNECESSARY rather than CHECKSUM_NONE + */ if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_TCP | MLX4_CQE_STATUS_UDP)) && (cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) &&