skbuff: convert to skb_orphan_frags
authorMichael S. Tsirkin <mst@redhat.com>
Fri, 20 Jul 2012 09:23:10 +0000 (09:23 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 Jul 2012 19:39:33 +0000 (12:39 -0700)
Reduce code duplication a bit using the new helper.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c

index ccfcb7d8711ec475f2c77f0ea3b2ead088c9f334..438bbc5fd89855121aa3dd95aee9099de2ee83d3 100644 (file)
@@ -804,10 +804,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
 {
        struct sk_buff *n;
 
-       if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
-               if (skb_copy_ubufs(skb, gfp_mask))
-                       return NULL;
-       }
+       if (skb_orphan_frags(skb, gfp_mask))
+               return NULL;
 
        n = skb + 1;
        if (skb->fclone == SKB_FCLONE_ORIG &&
@@ -927,12 +925,10 @@ struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask)
        if (skb_shinfo(skb)->nr_frags) {
                int i;
 
-               if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
-                       if (skb_copy_ubufs(skb, gfp_mask)) {
-                               kfree_skb(n);
-                               n = NULL;
-                               goto out;
-                       }
+               if (skb_orphan_frags(skb, gfp_mask)) {
+                       kfree_skb(n);
+                       n = NULL;
+                       goto out;
                }
                for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
                        skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i];
@@ -1005,10 +1001,8 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
         */
        if (skb_cloned(skb)) {
                /* copy this zero copy skb frags */
-               if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
-                       if (skb_copy_ubufs(skb, gfp_mask))
-                               goto nofrags;
-               }
+               if (skb_orphan_frags(skb, gfp_mask))
+                       goto nofrags;
                for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
                        skb_frag_ref(skb, i);