Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp583081img; Fri, 22 Mar 2019 04:32:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvK6Ecg5wLfXQP8DpHOjEnlShBXtfXY8nd5FH0vz/VsowqVAxjfVyDvSmnH9rK02nO8nYN X-Received: by 2002:a17:902:8d89:: with SMTP id v9mr9138533plo.254.1553254321340; Fri, 22 Mar 2019 04:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553254321; cv=none; d=google.com; s=arc-20160816; b=RafFHI4lhwOxKBUFc+lZpSoZKtXUFeruvJTFrKyRaJ4GeOpBBPEjGFPz/Mt6GISasn dxpW/E2MA/1R+A59v0e4LSSvXKS7l0o7lS/N5Hb9aq9P7cApyjQTgcc9L6UwQ/9bwGSV 0TO3SsJxJm7RxiqGndFBLYjrfL9aMNGuPZCwmCTjVaQJHEhNiqn6/YZ4sVjPco8wC7XN vR6h0btUy0TDKvsjPtrzxDn1cVjZzG2dQhTIWBhN54C92tIxg5kYbl8oKKnFBYShb1mU R4E9ENEo5ZJSQo+102zgF2saIzHNDmVhHkvfcHodjvXW6niGvMnchsLWGVBn10sMPZ0e eCtg== 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=ifq7m8FCoGDQLyeHvs6meuN1K7ViIoat8ra4yf5DWYY=; b=K32AUPAicY7oqjrcPNPSw9Ud1iUWWeKPZUQmlDLpIqKuxX7UJw3orZ9aMabMzLqUqK 0WFBtdW1shpvHqJYTrVY6+wqcJ6XyAzGRZee/bkK5dKtUHr+JgJw08AKi12YZK9efibk o5cFN7/QGSQXOHS/Umzmgcff31Yxxb2zeyER+RCzeZwsXV1fzEMNr+JQs3vAFuIVYZr8 AyUusfuIyMKP/+emO+e+0S+KJ58CzvMBVJ73NRXd9LXsFG2jbeyBe698hdl3UQolgBJR AA2AxvmPQ7o4URSgYagrM3qDKofk6NZERPM6uzYk1lN58pk6tQSloMRZW9s98r/cTx6p 6zig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fgngpEJ6; 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 k6si4858571pls.254.2019.03.22.04.31.43; Fri, 22 Mar 2019 04:32:01 -0700 (PDT) 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=fgngpEJ6; 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 S1729764AbfCVL3F (ORCPT + 99 others); Fri, 22 Mar 2019 07:29:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728509AbfCVL26 (ORCPT ); Fri, 22 Mar 2019 07:28:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 B8CDC21917; Fri, 22 Mar 2019 11:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254137; bh=Tuh43H7lY/8v9UFO6LIA+0i0DxTd/pkKVNmkxOsvEzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fgngpEJ6tcb6oqnD/e0m9yE6MAJuC1FMBuFs2G+rkp78/f3pBDAtR803LrT+ds6Uz k70JMPVfcaWejsN8ZVZFWcajJWBtB0m5fobi3qBPLi6KCldNVVu2KrSKNSUdr6Lh4t 9VhSBHgJFcg7KBwyjPT1w7dfFSoVSWmr7nWhWR60= 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.4 027/230] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Date: Fri, 22 Mar 2019 12:12:45 +0100 Message-Id: <20190322111238.593288935@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111236.796964179@linuxfoundation.org> References: <20190322111236.796964179@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.4-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 @@ -725,13 +725,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) && @@ -851,6 +865,11 @@ int mlx4_en_process_rx_cq(struct net_dev (cqe->vlan_my_qpn & cpu_to_be32(MLX4_CQE_L2_TUNNEL)); 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)) &&