inet_gso_segment() and inet_gso_send_check() are called by
skb_mac_gso_segment() under rcu lock, no need to use
rcu_read_lock() / rcu_read_unlock()
Avoid calling ip_hdr() twice per function.
We can use ip_send_check() helper.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
if (ihl < sizeof(*iph))
goto out;
if (ihl < sizeof(*iph))
goto out;
+ proto = iph->protocol;
+
+ /* Warning: after this point, iph might be no longer valid */
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
skb_reset_transport_header(skb);
skb_reset_transport_header(skb);
- iph = ip_hdr(skb);
- proto = iph->protocol;
ops = rcu_dereference(inet_offloads[proto]);
if (likely(ops && ops->callbacks.gso_send_check))
err = ops->callbacks.gso_send_check(skb);
ops = rcu_dereference(inet_offloads[proto]);
if (likely(ops && ops->callbacks.gso_send_check))
err = ops->callbacks.gso_send_check(skb);
if (ihl < sizeof(*iph))
goto out;
if (ihl < sizeof(*iph))
goto out;
+ id = ntohs(iph->id);
+ proto = iph->protocol;
+
+ /* Warning: after this point, iph might be no longer valid */
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
if (unlikely(!pskb_may_pull(skb, ihl)))
goto out;
tunnel = !!skb->encapsulation;
tunnel = !!skb->encapsulation;
skb_reset_transport_header(skb);
skb_reset_transport_header(skb);
- iph = ip_hdr(skb);
- id = ntohs(iph->id);
- proto = iph->protocol;
segs = ERR_PTR(-EPROTONOSUPPORT);
segs = ERR_PTR(-EPROTONOSUPPORT);
ops = rcu_dereference(inet_offloads[proto]);
if (likely(ops && ops->callbacks.gso_segment))
segs = ops->callbacks.gso_segment(skb, features);
ops = rcu_dereference(inet_offloads[proto]);
if (likely(ops && ops->callbacks.gso_segment))
segs = ops->callbacks.gso_segment(skb, features);
if (IS_ERR_OR_NULL(segs))
goto out;
if (IS_ERR_OR_NULL(segs))
goto out;
iph->id = htons(id++);
}
iph->tot_len = htons(skb->len - skb->mac_len);
iph->id = htons(id++);
}
iph->tot_len = htons(skb->len - skb->mac_len);
- iph->check = 0;
- iph->check = ip_fast_csum(skb_network_header(skb), iph->ihl);
} while ((skb = skb->next));
out:
} while ((skb = skb->next));
out: