Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4940737imc; Mon, 25 Feb 2019 14:05:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IYz29M0gtvyCX5j3IraTiMPoRp6ca/63KrpIWJbL5801VvMm0AoxTzfUVD/Di/feEhVFhXQ X-Received: by 2002:a17:902:8346:: with SMTP id z6mr22878082pln.74.1551132301084; Mon, 25 Feb 2019 14:05:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551132301; cv=none; d=google.com; s=arc-20160816; b=y4rrHU5MfvVaORmstPt2KQLjqaupnHzlnnPN4y2ioCRhWEy193e77hq7E0pP3uB9co HBpj0KaNHOQ8X8XqRYMf+XaeNPpKygqqDr+/z6TISvEtaWhupWx+DnozTdOLnRO7C1m3 cErAy6jMlZaQfHF6ldHrtJ022y18a22Lf784I5fygWxP3O787hqnzaybepjSFhz7Bnyb qSnDnCya3o9svxD+4Hh9ot5vPQcvnPmlrcv0juJ4eLl8Fg8Y/n+p1aCQJNpFzpjclmjM OPgJUO4RefXQ1gVjjSn+ucCeOH7XovIyuxyMAaxRgRXTwhQjZWK4i6WiBJREeoz0k4iu YIUg== 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=nCZzpOq2/aWxnO4rvAsTg03TGpXXEgrfiih/29S+9Jc=; b=pwa1m4zZn6yc+MkjR0I1Pgz4oWUQcKAncD4TxamapuquF0/9euFhykdHnR5O1HVnKl NzHXBNSU4bcJw1BG7xOJWV3zRHsmu/8GssT5ZjASZ1lALtg4zYYhcMX8pkc97eL39RQG uc5y2CVvYxs89wZJnWHOUwag6RynsNPVggA6vN6tdmqzCs4zdJN8s9LaSt7R70SYNcJU o/RqKE+ZAxhCSAqogc9dULRtNMJvX9lp6zqNcvk1oMIuGwrnSqcwcdjDFQ4MDQQA6H5Q Yj7XvhraOqC71Ycfx2DwPzlY4NiY9Vq5EWj1IkCeO9ImuWScXZ/3emgJ4b+yiZM4cLVY yvNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RVBS1LpO; 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 u7si2801765pls.237.2019.02.25.14.04.45; Mon, 25 Feb 2019 14:05:01 -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=RVBS1LpO; 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 S1729240AbfBYVOY (ORCPT + 99 others); Mon, 25 Feb 2019 16:14:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:45162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729210AbfBYVOT (ORCPT ); Mon, 25 Feb 2019 16:14:19 -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 3908520C01; Mon, 25 Feb 2019 21:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551129258; bh=H0+6gDf339U5PUYr5p2SZOiNk64zP/Ama84sqgoxFIM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVBS1LpO5M8tihV9uZmS5xl8avzLhXPfIy6Gm1gAR2aZjWWTWfQp9rcqDhPVDYVp6 lPqA8mCQP9aIYJoyrHeUn9DMG9qWOOjYb1/DabrKcivITvtI93lGB3rMyr54NUl+bU 9+Hdr8bTtFpCuUl49LEkdixnicwi2McbhWVND4uw= 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.9 37/63] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Date: Mon, 25 Feb 2019 22:11:37 +0100 Message-Id: <20190225195038.653707314@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195035.713274200@linuxfoundation.org> References: <20190225195035.713274200@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.9-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 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c @@ -777,13 +777,27 @@ static int get_fixed_ipv6_csum(__wsum hw return 0; } #endif + +#define short_frame(size) ((size) <= ETH_ZLEN + ETH_FCS_LEN) + static int check_csum(struct mlx4_cqe *cqe, struct sk_buff *skb, void *va, 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) && @@ -945,6 +959,11 @@ xdp_drop: } 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)) { if ((cqe->status & cpu_to_be16(MLX4_CQE_STATUS_IPOK)) &&