aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/skbuff.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2012-07-20 05:23:10 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-22 15:39:33 -0400
commit70008aa50e927670ceee7f0c87e159ca7b1517a2 (patch)
tree378f175d159a03f1e2fc9c93d654d4f2a776c3cf /net/core/skbuff.c
parenta353e0ce0fd42d8859260666d1e9b10f2abd4698 (diff)
skbuff: convert to skb_orphan_frags
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>
Diffstat (limited to 'net/core/skbuff.c')
-rw-r--r--net/core/skbuff.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ccfcb7d8711e..438bbc5fd898 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -804,10 +804,8 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask)
804{ 804{
805 struct sk_buff *n; 805 struct sk_buff *n;
806 806
807 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { 807 if (skb_orphan_frags(skb, gfp_mask))
808 if (skb_copy_ubufs(skb, gfp_mask)) 808 return NULL;
809 return NULL;
810 }
811 809
812 n = skb + 1; 810 n = skb + 1;
813 if (skb->fclone == SKB_FCLONE_ORIG && 811 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)
927 if (skb_shinfo(skb)->nr_frags) { 925 if (skb_shinfo(skb)->nr_frags) {
928 int i; 926 int i;
929 927
930 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { 928 if (skb_orphan_frags(skb, gfp_mask)) {
931 if (skb_copy_ubufs(skb, gfp_mask)) { 929 kfree_skb(n);
932 kfree_skb(n); 930 n = NULL;
933 n = NULL; 931 goto out;
934 goto out;
935 }
936 } 932 }
937 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 933 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
938 skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i]; 934 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,
1005 */ 1001 */
1006 if (skb_cloned(skb)) { 1002 if (skb_cloned(skb)) {
1007 /* copy this zero copy skb frags */ 1003 /* copy this zero copy skb frags */
1008 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { 1004 if (skb_orphan_frags(skb, gfp_mask))
1009 if (skb_copy_ubufs(skb, gfp_mask)) 1005 goto nofrags;
1010 goto nofrags;
1011 }
1012 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) 1006 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1013 skb_frag_ref(skb, i); 1007 skb_frag_ref(skb, i);
1014 1008