Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 122716
b: refs/heads/master
c: 71d93b3
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Dec 16, 2008
1 parent 20d921e commit df1a163
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 73cc19f1556b95976934de236fd9043f7208844f
refs/heads/master: 71d93b39e52e92aea35f1058d957cf12250d0b75
2 changes: 2 additions & 0 deletions trunk/include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,8 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
int shiftlen);

extern struct sk_buff *skb_segment(struct sk_buff *skb, int features);
extern int skb_gro_receive(struct sk_buff **head,
struct sk_buff *skb);

static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
int len, void *buffer)
Expand Down
59 changes: 59 additions & 0 deletions trunk/net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,65 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)

EXPORT_SYMBOL_GPL(skb_segment);

int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
{
struct sk_buff *p = *head;
struct sk_buff *nskb;
unsigned int headroom;
unsigned int hlen = p->data - skb_mac_header(p);

if (hlen + p->len + skb->len >= 65536)
return -E2BIG;

if (skb_shinfo(p)->frag_list)
goto merge;

headroom = skb_headroom(p);
nskb = netdev_alloc_skb(p->dev, headroom);
if (unlikely(!nskb))
return -ENOMEM;

__copy_skb_header(nskb, p);
nskb->mac_len = p->mac_len;

skb_reserve(nskb, headroom);

skb_set_mac_header(nskb, -hlen);
skb_set_network_header(nskb, skb_network_offset(p));
skb_set_transport_header(nskb, skb_transport_offset(p));

memcpy(skb_mac_header(nskb), skb_mac_header(p), hlen);

*NAPI_GRO_CB(nskb) = *NAPI_GRO_CB(p);
skb_shinfo(nskb)->frag_list = p;
skb_header_release(p);
nskb->prev = p;

nskb->data_len += p->len;
nskb->truesize += p->len;
nskb->len += p->len;

*head = nskb;
nskb->next = p->next;
p->next = NULL;

p = nskb;

merge:
NAPI_GRO_CB(p)->count++;
p->prev->next = skb;
p->prev = skb;
skb_header_release(skb);

p->data_len += skb->len;
p->truesize += skb->len;
p->len += skb->len;

NAPI_GRO_CB(skb)->same_flow = 1;
return 0;
}
EXPORT_SYMBOL_GPL(skb_gro_receive);

void __init skb_init(void)
{
skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
Expand Down

0 comments on commit df1a163

Please sign in to comment.