aboutsummaryrefslogtreecommitdiffstats
path: root/linux-2.6-xen-sparse/net/core/skbuff.c
diff options
context:
space:
mode:
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>2006-02-02 19:16:38 +0000
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>2006-02-02 19:16:38 +0000
commita8f141f4650c46f2800f955da67e4299cb8c832d (patch)
tree1f88753734cd82d05918eea2b7af530b8f880029 /linux-2.6-xen-sparse/net/core/skbuff.c
parente1aded64c50200c03c296f65867aad6355ad62c3 (diff)
downloadxen-a8f141f4650c46f2800f955da67e4299cb8c832d.tar.gz
xen-a8f141f4650c46f2800f955da67e4299cb8c832d.tar.bz2
xen-a8f141f4650c46f2800f955da67e4299cb8c832d.zip
Update to Linux 2.6.16-rc1-git4.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk> --HG-- rename : patches/linux-2.6.15/i386-mach-io-check-nmi.patch => patches/linux-2.6.16-rc1-git4/i386-mach-io-check-nmi.patch rename : patches/linux-2.6.15/net-csum.patch => patches/linux-2.6.16-rc1-git4/net-csum.patch rename : patches/linux-2.6.15/pmd-shared.patch => patches/linux-2.6.16-rc1-git4/pmd-shared.patch rename : patches/linux-2.6.15/smp-alts.patch => patches/linux-2.6.16-rc1-git4/smp-alts.patch
Diffstat (limited to 'linux-2.6-xen-sparse/net/core/skbuff.c')
-rw-r--r--linux-2.6-xen-sparse/net/core/skbuff.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/linux-2.6-xen-sparse/net/core/skbuff.c b/linux-2.6-xen-sparse/net/core/skbuff.c
index 7cd17430e2..976e5ab1df 100644
--- a/linux-2.6-xen-sparse/net/core/skbuff.c
+++ b/linux-2.6-xen-sparse/net/core/skbuff.c
@@ -136,17 +136,13 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
int fclone)
{
+ struct skb_shared_info *shinfo;
struct sk_buff *skb;
u8 *data;
/* Get the HEAD */
- if (fclone)
- skb = kmem_cache_alloc(skbuff_fclone_cache,
- gfp_mask & ~__GFP_DMA);
- else
- skb = kmem_cache_alloc(skbuff_head_cache,
- gfp_mask & ~__GFP_DMA);
-
+ skb = kmem_cache_alloc(fclone ? skbuff_fclone_cache : skbuff_head_cache,
+ gfp_mask & ~__GFP_DMA);
if (!skb)
goto out;
@@ -163,6 +159,16 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
skb->data = data;
skb->tail = data;
skb->end = data + size;
+ /* make sure we initialize shinfo sequentially */
+ shinfo = skb_shinfo(skb);
+ atomic_set(&shinfo->dataref, 1);
+ shinfo->nr_frags = 0;
+ shinfo->tso_size = 0;
+ shinfo->tso_segs = 0;
+ shinfo->ufo_size = 0;
+ shinfo->ip6_frag_id = 0;
+ shinfo->frag_list = NULL;
+
if (fclone) {
struct sk_buff *child = skb + 1;
atomic_t *fclone_ref = (atomic_t *) (child + 1);
@@ -172,20 +178,10 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
child->fclone = SKB_FCLONE_UNAVAILABLE;
}
- atomic_set(&(skb_shinfo(skb)->dataref), 1);
- skb_shinfo(skb)->nr_frags = 0;
- skb_shinfo(skb)->tso_size = 0;
- skb_shinfo(skb)->tso_segs = 0;
- skb_shinfo(skb)->frag_list = NULL;
- skb_shinfo(skb)->ufo_size = 0;
- skb_shinfo(skb)->ip6_frag_id = 0;
out:
return skb;
nodata:
- if (fclone)
- kmem_cache_free(skbuff_fclone_cache, skb);
- else
- kmem_cache_free(skbuff_head_cache, skb);
+ kmem_cache_free(fclone ? skbuff_fclone_cache : skbuff_head_cache, skb);
skb = NULL;
goto out;
}
@@ -210,17 +206,13 @@ struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
gfp_t gfp_mask,
int fclone)
{
+ struct skb_shared_info *shinfo;
struct sk_buff *skb;
u8 *data;
/* Get the HEAD */
- if (fclone)
- skb = kmem_cache_alloc(skbuff_fclone_cache,
- gfp_mask & ~__GFP_DMA);
- else
- skb = kmem_cache_alloc(skbuff_head_cache,
- gfp_mask & ~__GFP_DMA);
-
+ skb = kmem_cache_alloc(fclone ? skbuff_fclone_cache : skbuff_head_cache,
+ gfp_mask & ~__GFP_DMA);
if (!skb)
goto out;
@@ -237,6 +229,16 @@ struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
skb->data = data;
skb->tail = data;
skb->end = data + size;
+ /* make sure we initialize shinfo sequentially */
+ shinfo = skb_shinfo(skb);
+ atomic_set(&shinfo->dataref, 1);
+ shinfo->nr_frags = 0;
+ shinfo->tso_size = 0;
+ shinfo->tso_segs = 0;
+ shinfo->ufo_size = 0;
+ shinfo->ip6_frag_id = 0;
+ shinfo->frag_list = NULL;
+
if (fclone) {
struct sk_buff *child = skb + 1;
atomic_t *fclone_ref = (atomic_t *) (child + 1);
@@ -246,20 +248,10 @@ struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
child->fclone = SKB_FCLONE_UNAVAILABLE;
}
- atomic_set(&(skb_shinfo(skb)->dataref), 1);
- skb_shinfo(skb)->nr_frags = 0;
- skb_shinfo(skb)->tso_size = 0;
- skb_shinfo(skb)->tso_segs = 0;
- skb_shinfo(skb)->frag_list = NULL;
- skb_shinfo(skb)->ufo_size = 0;
- skb_shinfo(skb)->ip6_frag_id = 0;
out:
return skb;
nodata:
- if (fclone)
- kmem_cache_free(skbuff_fclone_cache, skb);
- else
- kmem_cache_free(skbuff_head_cache, skb);
+ kmem_cache_free(fclone ? skbuff_fclone_cache : skbuff_head_cache, skb);
skb = NULL;
goto out;
}
@@ -820,8 +812,7 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
int end = offset + skb_shinfo(skb)->frags[i].size;
if (end > len) {
if (skb_cloned(skb)) {
- if (!realloc)
- BUG();
+ BUG_ON(!realloc);
if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
return -ENOMEM;
}
@@ -923,8 +914,7 @@ unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta)
struct sk_buff *insp = NULL;
do {
- if (!list)
- BUG();
+ BUG_ON(!list);
if (list->len <= eat) {
/* Eaten as whole. */
@@ -1228,8 +1218,7 @@ unsigned int skb_checksum(const struct sk_buff *skb, int offset,
start = end;
}
}
- if (len)
- BUG();
+ BUG_ON(len);
return csum;
}
@@ -1311,8 +1300,7 @@ unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
start = end;
}
}
- if (len)
- BUG();
+ BUG_ON(len);
return csum;
}
@@ -1326,8 +1314,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
else
csstart = skb_headlen(skb);
- if (csstart > skb_headlen(skb))
- BUG();
+ BUG_ON(csstart > skb_headlen(skb));
memcpy(to, skb->data, csstart);