Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Add skb_unclone() helper function.

This function will be used in next GRE_GSO patch. This patch does
not change any functionality.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Eric Dumazet <edumazet@google.com>

authored by

Pravin B Shelar and committed by
David S. Miller
14bbd6a5 d887199d

+23 -21
+1 -2
drivers/net/ppp/ppp_generic.c
··· 1805 1805 /* the filter instructions are constructed assuming 1806 1806 a four-byte PPP header on each packet */ 1807 1807 if (ppp->pass_filter || ppp->active_filter) { 1808 - if (skb_cloned(skb) && 1809 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 1808 + if (skb_unclone(skb, GFP_ATOMIC)) 1810 1809 goto err; 1811 1810 1812 1811 *skb_push(skb, 2) = 0;
+10
include/linux/skbuff.h
··· 804 804 (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; 805 805 } 806 806 807 + static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) 808 + { 809 + might_sleep_if(pri & __GFP_WAIT); 810 + 811 + if (skb_cloned(skb)) 812 + return pskb_expand_head(skb, 0, 0, pri); 813 + 814 + return 0; 815 + } 816 + 807 817 /** 808 818 * skb_header_cloned - is the header a clone 809 819 * @skb: buffer to check
+1 -2
net/ipv4/ah4.c
··· 321 321 322 322 /* We are going to _remove_ AH header to keep sockets happy, 323 323 * so... Later this can change. */ 324 - if (skb_cloned(skb) && 325 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 324 + if (skb_unclone(skb, GFP_ATOMIC)) 326 325 goto out; 327 326 328 327 skb->ip_summed = CHECKSUM_NONE;
+1 -1
net/ipv4/ip_fragment.c
··· 590 590 goto out_oversize; 591 591 592 592 /* Head of list must not be cloned. */ 593 - if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) 593 + if (skb_unclone(head, GFP_ATOMIC)) 594 594 goto out_nomem; 595 595 596 596 /* If the first fragment is fragmented itself, we split
+1 -1
net/ipv4/tcp_output.c
··· 1331 1331 /* Remove acked data from a packet in the transmit queue. */ 1332 1332 int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) 1333 1333 { 1334 - if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 1334 + if (skb_unclone(skb, GFP_ATOMIC)) 1335 1335 return -ENOMEM; 1336 1336 1337 1337 __pskb_trim_head(skb, len);
+1 -1
net/ipv4/xfrm4_input.c
··· 132 132 * header and optional ESP marker bytes) and then modify the 133 133 * protocol to ESP, and then call into the transform receiver. 134 134 */ 135 - if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 135 + if (skb_unclone(skb, GFP_ATOMIC)) 136 136 goto drop; 137 137 138 138 /* Now we can update and verify the packet length... */
+1 -2
net/ipv4/xfrm4_mode_tunnel.c
··· 142 142 for_each_input_rcu(rcv_notify_handlers, handler) 143 143 handler->handler(skb); 144 144 145 - if (skb_cloned(skb) && 146 - (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) 145 + if (err = skb_unclone(skb, GFP_ATOMIC)) 147 146 goto out; 148 147 149 148 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
+1 -2
net/ipv6/ah6.c
··· 521 521 522 522 /* We are going to _remove_ AH header to keep sockets happy, 523 523 * so... Later this can change. */ 524 - if (skb_cloned(skb) && 525 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 524 + if (skb_unclone(skb, GFP_ATOMIC)) 526 525 goto out; 527 526 528 527 skb->ip_summed = CHECKSUM_NONE;
+1 -1
net/ipv6/netfilter/nf_conntrack_reasm.c
··· 368 368 } 369 369 370 370 /* Head of list must not be cloned. */ 371 - if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) { 371 + if (skb_unclone(head, GFP_ATOMIC)) { 372 372 pr_debug("skb is cloned but can't expand head"); 373 373 goto out_oom; 374 374 }
+1 -1
net/ipv6/reassembly.c
··· 404 404 goto out_oversize; 405 405 406 406 /* Head of list must not be cloned. */ 407 - if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) 407 + if (skb_unclone(head, GFP_ATOMIC)) 408 408 goto out_oom; 409 409 410 410 /* If the first fragment is fragmented itself, we split
+1 -2
net/ipv6/xfrm6_mode_tunnel.c
··· 69 69 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) 70 70 goto out; 71 71 72 - if (skb_cloned(skb) && 73 - (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) 72 + if (err = skb_unclone(skb, GFP_ATOMIC)) 74 73 goto out; 75 74 76 75 if (x->props.flags & XFRM_STATE_DECAP_DSCP)
+2 -4
net/sched/act_ipt.c
··· 207 207 struct tcf_ipt *ipt = a->priv; 208 208 struct xt_action_param par; 209 209 210 - if (skb_cloned(skb)) { 211 - if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 212 - return TC_ACT_UNSPEC; 213 - } 210 + if (skb_unclone(skb, GFP_ATOMIC)) 211 + return TC_ACT_UNSPEC; 214 212 215 213 spin_lock(&ipt->tcf_lock); 216 214
+1 -2
net/sched/act_pedit.c
··· 131 131 int i, munged = 0; 132 132 unsigned int off; 133 133 134 - if (skb_cloned(skb) && 135 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) 134 + if (skb_unclone(skb, GFP_ATOMIC)) 136 135 return p->tcf_action; 137 136 138 137 off = skb_network_offset(skb);