gro: Nasty optimisations for page frags in skb_gro_receive

This patch reverses the direction of the frags array copy in
skb_gro_receive in order simplify the loop conditional.  It
also avoids touching the first element of the original frags
array.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Herbert Xu 2009-05-26 18:50:32 +00:00 committed by David S. Miller
parent cb18978cbf
commit 66e92fcf1d
1 changed files with 16 additions and 11 deletions

View File

@ -2676,22 +2676,27 @@ int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb)
goto merge;
else if (headlen <= offset) {
skb_frag_t *frag;
int i;
skb_frag_t *frag2;
int i = skb_shinfo(skb)->nr_frags;
int nr_frags = skb_shinfo(p)->nr_frags + i;
if (skb_shinfo(p)->nr_frags + skb_shinfo(skb)->nr_frags >
MAX_SKB_FRAGS)
offset -= headlen;
if (nr_frags > MAX_SKB_FRAGS)
return -E2BIG;
skb_shinfo(skb)->frags[0].page_offset += offset - headlen;
skb_shinfo(skb)->frags[0].size -= offset - headlen;
frag = skb_shinfo(p)->frags + skb_shinfo(p)->nr_frags;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
*frag++ = skb_shinfo(skb)->frags[i];
skb_shinfo(p)->nr_frags += skb_shinfo(skb)->nr_frags;
skb_shinfo(p)->nr_frags = nr_frags;
skb_shinfo(skb)->nr_frags = 0;
frag = skb_shinfo(p)->frags + nr_frags;
frag2 = skb_shinfo(skb)->frags + i;
do {
*--frag = *--frag2;
} while (--i);
frag->page_offset += offset;
frag->size -= offset;
skb->truesize -= skb->data_len;
skb->len -= skb->data_len;
skb->data_len = 0;