Skip to content

Commit

Permalink
gro: Fix handling of headers that extend over the tail
Browse files Browse the repository at this point in the history
The skb_gro_* code fails to handle the case where a header starts
in the linear area but ends in the frags area.  Since the goal
of skb_gro_* is to optimise the case of completely non-linear
packets, we can simply bail out if we have anything in the linear
area.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Apr 27, 2009
1 parent 56ed435 commit edbd9e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ static inline void skb_gro_reset_offset(struct sk_buff *skb)

static inline void *skb_gro_mac_header(struct sk_buff *skb)
{
return skb_mac_header(skb) < skb->data ? skb_mac_header(skb) :
return skb_headlen(skb) ? skb_mac_header(skb) :
page_address(skb_shinfo(skb)->frags[0].page) +
skb_shinfo(skb)->frags[0].page_offset;
}
Expand Down
11 changes: 3 additions & 8 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2378,18 +2378,13 @@ void *skb_gro_header(struct sk_buff *skb, unsigned int hlen)
unsigned int offset = skb_gro_offset(skb);

hlen += offset;
if (hlen <= skb_headlen(skb))
return skb->data + offset;

if (unlikely(!skb_shinfo(skb)->nr_frags ||
skb_shinfo(skb)->frags[0].size <=
hlen - skb_headlen(skb) ||
if (unlikely(skb_headlen(skb) ||
skb_shinfo(skb)->frags[0].size < hlen ||
PageHighMem(skb_shinfo(skb)->frags[0].page)))
return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL;

return page_address(skb_shinfo(skb)->frags[0].page) +
skb_shinfo(skb)->frags[0].page_offset +
offset - skb_headlen(skb);
skb_shinfo(skb)->frags[0].page_offset + offset;
}
EXPORT_SYMBOL(skb_gro_header);

Expand Down

0 comments on commit edbd9e3

Please sign in to comment.