Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106135
b: refs/heads/master
c: 7d7e5a6
h: refs/heads/master
i:
  106133: 75502ec
  106131: 73662fc
  106127: c649998
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jul 25, 2008
1 parent aff493f commit 6d3db9f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 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: 6fccab671f2f0a24b799f29a4ec878f62d34656c
refs/heads/master: 7d7e5a60c62e88cb8782760bb6c4d3bd1577a6c6
48 changes: 42 additions & 6 deletions trunk/net/xfrm/xfrm_ipcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <linux/crypto.h>
#include <linux/err.h>
#include <linux/gfp.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
Expand Down Expand Up @@ -49,6 +50,7 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu);
struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu);
int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen);
int len;

if (err)
goto out;
Expand All @@ -58,13 +60,47 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
goto out;
}

err = pskb_expand_head(skb, 0, dlen - plen, GFP_ATOMIC);
if (err)
goto out;
len = dlen - plen;
if (len > skb_tailroom(skb))
len = skb_tailroom(skb);

skb->truesize += len;
__skb_put(skb, len);

len += plen;
skb_copy_to_linear_data(skb, scratch, len);

while ((scratch += len, dlen -= len) > 0) {
skb_frag_t *frag;

err = -EMSGSIZE;
if (WARN_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS))
goto out;

frag = skb_shinfo(skb)->frags + skb_shinfo(skb)->nr_frags;
frag->page = alloc_page(GFP_ATOMIC);

err = -ENOMEM;
if (!frag->page)
goto out;

len = PAGE_SIZE;
if (dlen < len)
len = dlen;

memcpy(page_address(frag->page), scratch, len);

frag->page_offset = 0;
frag->size = len;
skb->truesize += len;
skb->data_len += len;
skb->len += len;

skb_shinfo(skb)->nr_frags++;
}

err = 0;

skb->truesize += dlen - plen;
__skb_put(skb, dlen - plen);
skb_copy_to_linear_data(skb, scratch, dlen);
out:
put_cpu();
return err;
Expand Down

0 comments on commit 6d3db9f

Please sign in to comment.