diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-05-26 14:50:28 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-27 06:26:01 -0400 |
commit | a5b1cf288d4200506ab62fbb86cc81ace948a306 (patch) | |
tree | c95339866f4d67220d111811a92e5c6b79de6ab4 /net/ipv4/tcp.c | |
parent | 7489594cb249aeb178287c9a43a9e4f366044259 (diff) |
gro: Avoid unnecessary comparison after skb_gro_header
For the overwhelming majority of cases, skb_gro_header's return
value cannot be NULL. Yet we must check it because of its current
form. This patch splits it up into multiple functions in order
to avoid this.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 68342d431896..c3dcec5efea5 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2518,20 +2518,30 @@ struct sk_buff **tcp_gro_receive(struct sk_buff **head, struct sk_buff *skb) | |||
2518 | unsigned int thlen; | 2518 | unsigned int thlen; |
2519 | unsigned int flags; | 2519 | unsigned int flags; |
2520 | unsigned int mss = 1; | 2520 | unsigned int mss = 1; |
2521 | unsigned int hlen; | ||
2522 | unsigned int off; | ||
2521 | int flush = 1; | 2523 | int flush = 1; |
2522 | int i; | 2524 | int i; |
2523 | 2525 | ||
2524 | th = skb_gro_header(skb, sizeof(*th)); | 2526 | off = skb_gro_offset(skb); |
2525 | if (unlikely(!th)) | 2527 | hlen = off + sizeof(*th); |
2526 | goto out; | 2528 | th = skb_gro_header_fast(skb, off); |
2529 | if (skb_gro_header_hard(skb, hlen)) { | ||
2530 | th = skb_gro_header_slow(skb, hlen, off); | ||
2531 | if (unlikely(!th)) | ||
2532 | goto out; | ||
2533 | } | ||
2527 | 2534 | ||
2528 | thlen = th->doff * 4; | 2535 | thlen = th->doff * 4; |
2529 | if (thlen < sizeof(*th)) | 2536 | if (thlen < sizeof(*th)) |
2530 | goto out; | 2537 | goto out; |
2531 | 2538 | ||
2532 | th = skb_gro_header(skb, thlen); | 2539 | hlen = off + thlen; |
2533 | if (unlikely(!th)) | 2540 | if (skb_gro_header_hard(skb, hlen)) { |
2534 | goto out; | 2541 | th = skb_gro_header_slow(skb, hlen, off); |
2542 | if (unlikely(!th)) | ||
2543 | goto out; | ||
2544 | } | ||
2535 | 2545 | ||
2536 | skb_gro_pull(skb, thlen); | 2546 | skb_gro_pull(skb, thlen); |
2537 | 2547 | ||