From patchwork Fri Jul 21 23:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 792410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xDnWX0DQBz9s7m for ; Sat, 22 Jul 2017 09:47:52 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id ADC13BDE; Fri, 21 Jul 2017 23:46:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0BDF2BC8 for ; Fri, 21 Jul 2017 23:46:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8A2C7171 for ; Fri, 21 Jul 2017 23:46:26 +0000 (UTC) Received: from mfilter14-d.gandi.net (mfilter14-d.gandi.net [217.70.178.142]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 5CC5517209A; Sat, 22 Jul 2017 01:46:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter14-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter14-d.gandi.net (mfilter14-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id YBt81ax8bB_1; Sat, 22 Jul 2017 01:46:23 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CEA5D172094; Sat, 22 Jul 2017 01:46:22 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Fri, 21 Jul 2017 16:46:05 -0700 Message-Id: <20170721234614.2800-3-joe@ovn.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170721234614.2800-1-joe@ovn.org> References: <20170721234614.2800-1-joe@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 02/11] datapath: more accurate checksumming in queue_userspace_packet() X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Upstream commit: commit 7529390d08f07fbf9b0174c5a87600b5caa1a8e8 Author: Davide Caratti Date: Thu May 18 15:44:42 2017 +0200 openvswitch: more accurate checksumming in queue_userspace_packet() if skb carries an SCTP packet and ip_summed is CHECKSUM_PARTIAL, it needs CRC32c in place of Internet Checksum: use skb_csum_hwoffload_help to avoid corrupting such packets while queueing them towards userspace. Signed-off-by: Davide Caratti Signed-off-by: David S. Miller Signed-off-by: Joe Stringer --- acinclude.m4 | 1 + datapath/datapath.c | 2 +- datapath/linux/compat/include/linux/netdevice.h | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 62a91e650a4a..91a5585e2512 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -538,6 +538,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [OVS_DEFINE([HAVE_PCPU_SW_NETSTATS])]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netif_needs_gso.*net_device], [OVS_DEFINE([HAVE_NETIF_NEEDS_GSO_NETDEV])]) + OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [skb_csum_hwoffload_help]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [udp_offload]) OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [udp_offload.*uoff], [OVS_DEFINE([HAVE_UDP_OFFLOAD_ARG_UOFF])]) diff --git a/datapath/datapath.c b/datapath/datapath.c index 82cad74b7972..6d252d7516d3 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -460,7 +460,7 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb, /* Complete checksum if needed */ if (skb->ip_summed == CHECKSUM_PARTIAL && - (err = skb_checksum_help(skb))) + (err = skb_csum_hwoffload_help(skb, 0))) goto out; /* Older versions of OVS user space enforce alignment of the last diff --git a/datapath/linux/compat/include/linux/netdevice.h b/datapath/linux/compat/include/linux/netdevice.h index 75315dc16e02..878c30a6da4a 100644 --- a/datapath/linux/compat/include/linux/netdevice.h +++ b/datapath/linux/compat/include/linux/netdevice.h @@ -270,4 +270,19 @@ static inline void netdev_reset_rx_headroom(struct net_device *dev) #define IFF_NO_QUEUE 0 #endif +#ifndef HAVE_SKB_CSUM_HWOFFLOAD_HELP +static inline int skb_csum_hwoffload_help(struct sk_buff *skb, + const netdev_features_t features) +{ + /* It's less accurate to approximate to this for older kernels, but + * it was sufficient for a long time. If you care about ensuring that + * upstream commit 7529390d08f0 has the same effect on older kernels, + * consider backporting the following commits: + * b72b5bf6a8fc ("net: introduce skb_crc32c_csum_help") + * 43c26a1a4593 ("net: more accurate checksumming in validate_xmit_skb()") + */ + return skb_checksum_help(skb); +} +#endif + #endif /* __LINUX_NETDEVICE_WRAPPER_H */