Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14bbd6a5 authored by Pravin B Shelar's avatar Pravin B Shelar Committed by David S. Miller
Browse files

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: default avatarPravin B Shelar <pshelar@nicira.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
parent d887199d
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -1805,8 +1805,7 @@ ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
		/* the filter instructions are constructed assuming
		/* the filter instructions are constructed assuming
		   a four-byte PPP header on each packet */
		   a four-byte PPP header on each packet */
		if (ppp->pass_filter || ppp->active_filter) {
		if (ppp->pass_filter || ppp->active_filter) {
			if (skb_cloned(skb) &&
			if (skb_unclone(skb, GFP_ATOMIC))
			    pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
				goto err;
				goto err;


			*skb_push(skb, 2) = 0;
			*skb_push(skb, 2) = 0;
+10 −0
Original line number Original line Diff line number Diff line
@@ -804,6 +804,16 @@ static inline int skb_cloned(const struct sk_buff *skb)
	       (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1;
	       (atomic_read(&skb_shinfo(skb)->dataref) & SKB_DATAREF_MASK) != 1;
}
}


static inline int skb_unclone(struct sk_buff *skb, gfp_t pri)
{
	might_sleep_if(pri & __GFP_WAIT);

	if (skb_cloned(skb))
		return pskb_expand_head(skb, 0, 0, pri);

	return 0;
}

/**
/**
 *	skb_header_cloned - is the header a clone
 *	skb_header_cloned - is the header a clone
 *	@skb: buffer to check
 *	@skb: buffer to check
+1 −2
Original line number Original line Diff line number Diff line
@@ -321,8 +321,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)


	/* We are going to _remove_ AH header to keep sockets happy,
	/* We are going to _remove_ AH header to keep sockets happy,
	 * so... Later this can change. */
	 * so... Later this can change. */
	if (skb_cloned(skb) &&
	if (skb_unclone(skb, GFP_ATOMIC))
	    pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
		goto out;
		goto out;


	skb->ip_summed = CHECKSUM_NONE;
	skb->ip_summed = CHECKSUM_NONE;
+1 −1
Original line number Original line Diff line number Diff line
@@ -590,7 +590,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
		goto out_oversize;
		goto out_oversize;


	/* Head of list must not be cloned. */
	/* Head of list must not be cloned. */
	if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC))
	if (skb_unclone(head, GFP_ATOMIC))
		goto out_nomem;
		goto out_nomem;


	/* If the first fragment is fragmented itself, we split
	/* If the first fragment is fragmented itself, we split
+1 −1
Original line number Original line Diff line number Diff line
@@ -1331,7 +1331,7 @@ static void __pskb_trim_head(struct sk_buff *skb, int len)
/* Remove acked data from a packet in the transmit queue. */
/* Remove acked data from a packet in the transmit queue. */
int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
{
{
	if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
	if (skb_unclone(skb, GFP_ATOMIC))
		return -ENOMEM;
		return -ENOMEM;


	__pskb_trim_head(skb, len);
	__pskb_trim_head(skb, len);
Loading