Commit e081ecf0 authored by Richard Gobert's avatar Richard Gobert Committed by Paolo Abeni

gro: avoid checking for a failed search

After searching for a protocol handler in dev_gro_receive, checking for
failure is redundant. Skip the failure code after finding the
corresponding handler.
Suggested-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarRichard Gobert <richardbgobert@gmail.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20221108123320.GA59373@debianSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent e29edc47
...@@ -489,45 +489,45 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff ...@@ -489,45 +489,45 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(ptype, head, list) { list_for_each_entry_rcu(ptype, head, list) {
if (ptype->type != type || !ptype->callbacks.gro_receive) if (ptype->type == type && ptype->callbacks.gro_receive)
continue; goto found_ptype;
}
skb_set_network_header(skb, skb_gro_offset(skb)); rcu_read_unlock();
skb_reset_mac_len(skb); goto normal;
BUILD_BUG_ON(sizeof_field(struct napi_gro_cb, zeroed) != sizeof(u32));
BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct napi_gro_cb, zeroed), found_ptype:
sizeof(u32))); /* Avoid slow unaligned acc */ skb_set_network_header(skb, skb_gro_offset(skb));
*(u32 *)&NAPI_GRO_CB(skb)->zeroed = 0; skb_reset_mac_len(skb);
NAPI_GRO_CB(skb)->flush = skb_has_frag_list(skb); BUILD_BUG_ON(sizeof_field(struct napi_gro_cb, zeroed) != sizeof(u32));
NAPI_GRO_CB(skb)->is_atomic = 1; BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct napi_gro_cb, zeroed),
NAPI_GRO_CB(skb)->count = 1; sizeof(u32))); /* Avoid slow unaligned acc */
if (unlikely(skb_is_gso(skb))) { *(u32 *)&NAPI_GRO_CB(skb)->zeroed = 0;
NAPI_GRO_CB(skb)->count = skb_shinfo(skb)->gso_segs; NAPI_GRO_CB(skb)->flush = skb_has_frag_list(skb);
/* Only support TCP at the moment. */ NAPI_GRO_CB(skb)->is_atomic = 1;
if (!skb_is_gso_tcp(skb)) NAPI_GRO_CB(skb)->count = 1;
NAPI_GRO_CB(skb)->flush = 1; if (unlikely(skb_is_gso(skb))) {
} NAPI_GRO_CB(skb)->count = skb_shinfo(skb)->gso_segs;
/* Only support TCP at the moment. */
/* Setup for GRO checksum validation */ if (!skb_is_gso_tcp(skb))
switch (skb->ip_summed) { NAPI_GRO_CB(skb)->flush = 1;
case CHECKSUM_COMPLETE: }
NAPI_GRO_CB(skb)->csum = skb->csum;
NAPI_GRO_CB(skb)->csum_valid = 1;
break;
case CHECKSUM_UNNECESSARY:
NAPI_GRO_CB(skb)->csum_cnt = skb->csum_level + 1;
break;
}
pp = INDIRECT_CALL_INET(ptype->callbacks.gro_receive, /* Setup for GRO checksum validation */
ipv6_gro_receive, inet_gro_receive, switch (skb->ip_summed) {
&gro_list->list, skb); case CHECKSUM_COMPLETE:
NAPI_GRO_CB(skb)->csum = skb->csum;
NAPI_GRO_CB(skb)->csum_valid = 1;
break;
case CHECKSUM_UNNECESSARY:
NAPI_GRO_CB(skb)->csum_cnt = skb->csum_level + 1;
break; break;
} }
rcu_read_unlock();
if (&ptype->list == head) pp = INDIRECT_CALL_INET(ptype->callbacks.gro_receive,
goto normal; ipv6_gro_receive, inet_gro_receive,
&gro_list->list, skb);
rcu_read_unlock();
if (PTR_ERR(pp) == -EINPROGRESS) { if (PTR_ERR(pp) == -EINPROGRESS) {
ret = GRO_CONSUMED; ret = GRO_CONSUMED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment