datapath: Add skb_csum_help compatibility function.
authorJesse Gross <jesse@nicira.com>
Thu, 1 Apr 2010 21:34:18 +0000 (17:34 -0400)
committerJesse Gross <jesse@nicira.com>
Mon, 19 Apr 2010 13:11:57 +0000 (09:11 -0400)
Later kernel versions remove the direction argument from
skb_checksum_help.  This provides a compatibility function so we
can have consistent syntax across versions.

Since CHECKSUM_PARTIAL is the same as CHECKSUM_HW on older kernels
this allows a unified code path for computing checksums.

datapath/datapath.c
datapath/linux-2.6/compat-2.6/include/linux/netdevice.h

index 9b34fcc548b2c223f37f0ecbe7260661cecce652..e1320f24d12e56784cab08ed784c3eedbeccfc88 100644 (file)
@@ -757,8 +757,9 @@ queue_control_packets(struct sk_buff *skb, struct sk_buff_head *queue,
                err = vswitch_skb_checksum_setup(skb);
                if (err)
                        goto err_kfree_skbs;
-#ifndef CHECKSUM_HW
+
                if (skb->ip_summed == CHECKSUM_PARTIAL) {
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
                        /* Until 2.6.22, the start of the transport header was
                         * also the start of data to be checksummed.  Linux
@@ -769,17 +770,11 @@ queue_control_packets(struct sk_buff *skb, struct sk_buff_head *queue,
                        skb_set_transport_header(skb, skb->csum_start -
                                                 skb_headroom(skb));
 #endif
+
                        err = skb_checksum_help(skb);
                        if (err)
                                goto err_kfree_skbs;
                }
-#else
-               if (skb->ip_summed == CHECKSUM_HW) {
-                       err = skb_checksum_help(skb, 0);
-                       if (err)
-                               goto err_kfree_skbs;
-               }
-#endif
 
                err = skb_cow(skb, sizeof *header);
                if (err)
index 7080d0128a68d924a2202d9d840e4bdc5fd44c42..b7fe8deb1a42220c66b08a523acaf3165026d195 100644 (file)
@@ -85,4 +85,8 @@ dev_get_stats(struct net_device *dev)
 }
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
+#define skb_checksum_help(skb) skb_checksum_help((skb), 0)
+#endif
+
 #endif