]> git.proxmox.com Git - mirror_ovs.git/commitdiff
datapath: more accurate checksumming in queue_userspace_packet()
authorJoe Stringer <joe@ovn.org>
Fri, 21 Jul 2017 23:46:05 +0000 (16:46 -0700)
committerJoe Stringer <joe@ovn.org>
Mon, 24 Jul 2017 18:24:32 +0000 (11:24 -0700)
Upstream commit:
    commit 7529390d08f07fbf9b0174c5a87600b5caa1a8e8
    Author: Davide Caratti <dcaratti@redhat.com>
    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 <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Joe Stringer <joe@ovn.org>
acinclude.m4
datapath/datapath.c
datapath/linux/compat/include/linux/netdevice.h

index 62a91e650a4a01cc70e15bd0b5fcd63f76606bcf..91a5585e25127ff22da31c63665c08ece829a866 100644 (file)
@@ -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])])
index 82cad74b797241507bf05aeeef4d92a47d6f809f..6d252d7516d34ae610fc3f32d1261586815a4c57 100644 (file)
@@ -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
index 75315dc16e026e9a81abbf7187ebb20ce9ec84b7..878c30a6da4a0eb813226515d895904bebee2ddd 100644 (file)
@@ -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 */