Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 65000
b: refs/heads/master
c: d9cc204
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Sep 16, 2007
1 parent b61d4bf commit a46632d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e081e1e3ef4682802ac63b1e5e26158fb9ca9e90
refs/heads/master: d9cc20484e5e48c6a5deb4387c20fd45bfbdde8c
2 changes: 1 addition & 1 deletion trunk/drivers/net/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)
/* Copy the data if there is no space for the header or if it's
* read-only.
*/
if (skb_cow(skb, sizeof(*ph) + dev->hard_header_len))
if (skb_cow_head(skb, sizeof(*ph) + dev->hard_header_len))
goto abort;

__skb_push(skb, sizeof(*ph));
Expand Down
40 changes: 31 additions & 9 deletions trunk/include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,22 @@ static inline int skb_clone_writable(struct sk_buff *skb, int len)
skb_headroom(skb) + len <= skb->hdr_len;
}

static inline int __skb_cow(struct sk_buff *skb, unsigned int headroom,
int cloned)
{
int delta = 0;

if (headroom < NET_SKB_PAD)
headroom = NET_SKB_PAD;
if (headroom > skb_headroom(skb))
delta = headroom - skb_headroom(skb);

if (delta || cloned)
return pskb_expand_head(skb, ALIGN(delta, NET_SKB_PAD), 0,
GFP_ATOMIC);
return 0;
}

/**
* skb_cow - copy header of skb when it is required
* @skb: buffer to cow
Expand All @@ -1366,16 +1382,22 @@ static inline int skb_clone_writable(struct sk_buff *skb, int len)
*/
static inline int skb_cow(struct sk_buff *skb, unsigned int headroom)
{
int delta = (headroom > NET_SKB_PAD ? headroom : NET_SKB_PAD) -
skb_headroom(skb);

if (delta < 0)
delta = 0;
return __skb_cow(skb, headroom, skb_cloned(skb));
}

if (delta || skb_cloned(skb))
return pskb_expand_head(skb, (delta + (NET_SKB_PAD-1)) &
~(NET_SKB_PAD-1), 0, GFP_ATOMIC);
return 0;
/**
* skb_cow_head - skb_cow but only making the head writable
* @skb: buffer to cow
* @headroom: needed headroom
*
* This function is identical to skb_cow except that we replace the
* skb_cloned check by skb_header_cloned. It should be used when
* you only need to push on some header and do not need to modify
* the data.
*/
static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
{
return __skb_cow(skb, headroom, skb_header_cloned(skb));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int nf_bridge_copy_header(struct sk_buff *skb)
int err;
int header_size = ETH_HLEN + nf_bridge_encap_header_len(skb);

err = skb_cow(skb, header_size);
err = skb_cow_head(skb, header_size);
if (err)
return err;

Expand Down

0 comments on commit a46632d

Please sign in to comment.