mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
7489594cb2
commit
a5b1cf288d
5 changed files with 62 additions and 26 deletions
|
|
@ -1246,13 +1246,20 @@ static struct sk_buff **inet_gro_receive(struct sk_buff **head,
|
|||
struct sk_buff **pp = NULL;
|
||||
struct sk_buff *p;
|
||||
struct iphdr *iph;
|
||||
unsigned int hlen;
|
||||
unsigned int off;
|
||||
int flush = 1;
|
||||
int proto;
|
||||
int id;
|
||||
|
||||
iph = skb_gro_header(skb, sizeof(*iph));
|
||||
if (unlikely(!iph))
|
||||
goto out;
|
||||
off = skb_gro_offset(skb);
|
||||
hlen = off + sizeof(*iph);
|
||||
iph = skb_gro_header_fast(skb, off);
|
||||
if (skb_gro_header_hard(skb, hlen)) {
|
||||
iph = skb_gro_header_slow(skb, hlen, off);
|
||||
if (unlikely(!iph))
|
||||
goto out;
|
||||
}
|
||||
|
||||
proto = iph->protocol & (MAX_INET_PROTOS - 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -2518,20 +2518,30 @@ struct sk_buff **tcp_gro_receive(struct sk_buff **head, struct sk_buff *skb)
|
|||
unsigned int thlen;
|
||||
unsigned int flags;
|
||||
unsigned int mss = 1;
|
||||
unsigned int hlen;
|
||||
unsigned int off;
|
||||
int flush = 1;
|
||||
int i;
|
||||
|
||||
th = skb_gro_header(skb, sizeof(*th));
|
||||
if (unlikely(!th))
|
||||
goto out;
|
||||
off = skb_gro_offset(skb);
|
||||
hlen = off + sizeof(*th);
|
||||
th = skb_gro_header_fast(skb, off);
|
||||
if (skb_gro_header_hard(skb, hlen)) {
|
||||
th = skb_gro_header_slow(skb, hlen, off);
|
||||
if (unlikely(!th))
|
||||
goto out;
|
||||
}
|
||||
|
||||
thlen = th->doff * 4;
|
||||
if (thlen < sizeof(*th))
|
||||
goto out;
|
||||
|
||||
th = skb_gro_header(skb, thlen);
|
||||
if (unlikely(!th))
|
||||
goto out;
|
||||
hlen = off + thlen;
|
||||
if (skb_gro_header_hard(skb, hlen)) {
|
||||
th = skb_gro_header_slow(skb, hlen, off);
|
||||
if (unlikely(!th))
|
||||
goto out;
|
||||
}
|
||||
|
||||
skb_gro_pull(skb, thlen);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue