diff options
| author | Pravin B Shelar <pshelar@nicira.com> | 2013-02-14 04:44:49 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-02-15 15:10:37 -0500 |
| commit | 14bbd6a565e1bcdc240d44687edb93f721cfdf99 (patch) | |
| tree | b2001bb985856d2177212451273d1f6ebcc55035 | |
| parent | d887199dc28c46788b155b234274d5ff41afed8e (diff) | |
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>
| -rw-r--r-- | drivers/net/ppp/ppp_generic.c | 3 | ||||
| -rw-r--r-- | include/linux/skbuff.h | 10 | ||||
| -rw-r--r-- | net/ipv4/ah4.c | 3 | ||||
| -rw-r--r-- | net/ipv4/ip_fragment.c | 2 | ||||
| -rw-r--r-- | net/ipv4/tcp_output.c | 2 | ||||
| -rw-r--r-- | net/ipv4/xfrm4_input.c | 2 | ||||
| -rw-r--r-- | net/ipv4/xfrm4_mode_tunnel.c | 3 | ||||
| -rw-r--r-- | net/ipv6/ah6.c | 3 | ||||
| -rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 2 | ||||
| -rw-r--r-- | net/ipv6/reassembly.c | 2 | ||||
| -rw-r--r-- | net/ipv6/xfrm6_mode_tunnel.c | 3 | ||||
| -rw-r--r-- | net/sched/act_ipt.c | 6 | ||||
| -rw-r--r-- | net/sched/act_pedit.c | 3 |
13 files changed, 23 insertions, 21 deletions
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 0b2706abe3e3..4fd754e74eb2 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c | |||
| @@ -1805,8 +1805,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) | |||
| 1805 | /* the filter instructions are constructed assuming | 1805 | /* the filter instructions are constructed assuming |
| 1806 | a four-byte PPP header on each packet */ | 1806 | a four-byte PPP header on each packet */ |
| 1807 | if (ppp->pass_filter || ppp->active_filter) { | 1807 | if (ppp->pass_filter || ppp->active_filter) { |
| 1808 | if (skb_cloned(skb) && | 1808 | if (skb_unclone(skb, GFP_ATOMIC)) |
| 1809 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | ||
| 1810 | goto err; | 1809 | goto err; |
| 1811 | 1810 | ||
| 1812 | *skb_push(skb, 2) = 0; | 1811 | *skb_push(skb, 2) = 0; |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 9da99520ccd5..ca6ee7d93edb 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
| @@ -804,6 +804,16 @@ static inline int skb_cloned(const struct sk_buff *skb) | |||
| 804 | (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1; | 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 | * skb_header_cloned - is the header a clone | 818 | * skb_header_cloned - is the header a clone |
| 809 | * @skb: buffer to check | 819 | * @skb: buffer to check |
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index a69b4e4a02b5..2e7f1948216f 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
| @@ -321,8 +321,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 321 | 321 | ||
| 322 | /* We are going to _remove_ AH header to keep sockets happy, | 322 | /* We are going to _remove_ AH header to keep sockets happy, |
| 323 | * so... Later this can change. */ | 323 | * so... Later this can change. */ |
| 324 | if (skb_cloned(skb) && | 324 | if (skb_unclone(skb, GFP_ATOMIC)) |
| 325 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | ||
| 326 | goto out; | 325 | goto out; |
| 327 | 326 | ||
| 328 | skb->ip_summed = CHECKSUM_NONE; | 327 | skb->ip_summed = CHECKSUM_NONE; |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 1211613c6c34..b6d30acb600c 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
| @@ -590,7 +590,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, | |||
| 590 | goto out_oversize; | 590 | goto out_oversize; |
| 591 | 591 | ||
| 592 | /* Head of list must not be cloned. */ | 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 | goto out_nomem; | 594 | goto out_nomem; |
| 595 | 595 | ||
| 596 | /* If the first fragment is fragmented itself, we split | 596 | /* If the first fragment is fragmented itself, we split |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 6182d90e97b0..fd0cea114b5d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -1331,7 +1331,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
| 1331 | /* Remove acked data from a packet in the transmit queue. */ | 1331 | /* Remove acked data from a packet in the transmit queue. */ |
| 1332 | int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | 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 | return -ENOMEM; | 1335 | return -ENOMEM; |
| 1336 | 1336 | ||
| 1337 | __pskb_trim_head(skb, len); | 1337 | __pskb_trim_head(skb, len); |
diff --git a/net/ipv4/xfrm4_input.c b/net/ipv4/xfrm4_input.c index 06814b6216dc..1f12c8b45864 100644 --- a/net/ipv4/xfrm4_input.c +++ b/net/ipv4/xfrm4_input.c | |||
| @@ -132,7 +132,7 @@ int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 132 | * header and optional ESP marker bytes) and then modify the | 132 | * header and optional ESP marker bytes) and then modify the |
| 133 | * protocol to ESP, and then call into the transform receiver. | 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 | goto drop; | 136 | goto drop; |
| 137 | 137 | ||
| 138 | /* Now we can update and verify the packet length... */ | 138 | /* Now we can update and verify the packet length... */ |
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c index ddee0a099a2c..1162ace30838 100644 --- a/net/ipv4/xfrm4_mode_tunnel.c +++ b/net/ipv4/xfrm4_mode_tunnel.c | |||
| @@ -142,8 +142,7 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 142 | for_each_input_rcu(rcv_notify_handlers, handler) | 142 | for_each_input_rcu(rcv_notify_handlers, handler) |
| 143 | handler->handler(skb); | 143 | handler->handler(skb); |
| 144 | 144 | ||
| 145 | if (skb_cloned(skb) && | 145 | if (err = skb_unclone(skb, GFP_ATOMIC)) |
| 146 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) | ||
| 147 | goto out; | 146 | goto out; |
| 148 | 147 | ||
| 149 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) | 148 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) |
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index 384233188ac1..bb02e176cb70 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c | |||
| @@ -521,8 +521,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 521 | 521 | ||
| 522 | /* We are going to _remove_ AH header to keep sockets happy, | 522 | /* We are going to _remove_ AH header to keep sockets happy, |
| 523 | * so... Later this can change. */ | 523 | * so... Later this can change. */ |
| 524 | if (skb_cloned(skb) && | 524 | if (skb_unclone(skb, GFP_ATOMIC)) |
| 525 | pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | ||
| 526 | goto out; | 525 | goto out; |
| 527 | 526 | ||
| 528 | skb->ip_summed = CHECKSUM_NONE; | 527 | skb->ip_summed = CHECKSUM_NONE; |
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index c674f158efa8..b89a8c3186cd 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
| @@ -368,7 +368,7 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev) | |||
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | /* Head of list must not be cloned. */ | 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 | pr_debug("skb is cloned but can't expand head"); | 372 | pr_debug("skb is cloned but can't expand head"); |
| 373 | goto out_oom; | 373 | goto out_oom; |
| 374 | } | 374 | } |
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index bab2c270f292..e354743ed426 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
| @@ -404,7 +404,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev, | |||
| 404 | goto out_oversize; | 404 | goto out_oversize; |
| 405 | 405 | ||
| 406 | /* Head of list must not be cloned. */ | 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 | goto out_oom; | 408 | goto out_oom; |
| 409 | 409 | ||
| 410 | /* If the first fragment is fragmented itself, we split | 410 | /* If the first fragment is fragmented itself, we split |
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index 9f2095b19ad0..93c41a81c4c3 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c | |||
| @@ -69,8 +69,7 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 69 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) | 69 | if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) |
| 70 | goto out; | 70 | goto out; |
| 71 | 71 | ||
| 72 | if (skb_cloned(skb) && | 72 | if (err = skb_unclone(skb, GFP_ATOMIC)) |
| 73 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) | ||
| 74 | goto out; | 73 | goto out; |
| 75 | 74 | ||
| 76 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) | 75 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) |
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 0fb9e3f567e6..e0f6de64afec 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c | |||
| @@ -207,10 +207,8 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, | |||
| 207 | struct tcf_ipt *ipt = a->priv; | 207 | struct tcf_ipt *ipt = a->priv; |
| 208 | struct xt_action_param par; | 208 | struct xt_action_param par; |
| 209 | 209 | ||
| 210 | if (skb_cloned(skb)) { | 210 | if (skb_unclone(skb, GFP_ATOMIC)) |
| 211 | if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) | 211 | return TC_ACT_UNSPEC; |
| 212 | return TC_ACT_UNSPEC; | ||
| 213 | } | ||
| 214 | 212 | ||
| 215 | spin_lock(&ipt->tcf_lock); | ||
