datapath: Check vswitch_skb_checksum_setup() return code.
authorJesse Gross <jesse@nicira.com>
Thu, 17 Jun 2010 22:17:53 +0000 (15:17 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 18 Jun 2010 18:38:10 +0000 (11:38 -0700)
If vswitch_skb_checksum_setup() returns an error, the checksum
pointers probably haven't been set correctly which could cause
a crash later.  We should give up immediately on error.

datapath/actions.c
datapath/vport-gre.c

index ff67372..f7e51d9 100644 (file)
@@ -113,6 +113,8 @@ modify_vlan_tci(struct datapath *dp, struct sk_buff *skb,
                                                ~skb->csum);
                }
        } else {
+               int err;
+
                /* Add vlan header */
 
                /* Set up checksumming pointers for checksum-deferred packets
@@ -120,7 +122,11 @@ modify_vlan_tci(struct datapath *dp, struct sk_buff *skb,
                 * when we send the packet out on the wire, and it will fail at
                 * that point because skb_checksum_setup() will not look inside
                 * an 802.1Q header. */
-               vswitch_skb_checksum_setup(skb);
+               err = vswitch_skb_checksum_setup(skb);
+               if (unlikely(err)) {
+                       kfree_skb(skb);
+                       return ERR_PTR(err);
+               }       
 
                /* GSO is not implemented for packets with an 802.1Q header, so
                 * we have to do segmentation before we add that header.
index 98e0abc..c71cc34 100644 (file)
@@ -1131,7 +1131,9 @@ gre_send(struct vport *vport, struct sk_buff *skb)
        }
 
        forward_ip_summed(skb);
-       vswitch_skb_checksum_setup(skb);
+
+       if (unlikely(vswitch_skb_checksum_setup(skb)))
+               goto error_free;
 
        skb = handle_gso(skb);
        if (unlikely(IS_ERR(skb))) {