提交 43480aec 编写于 作者: E Eric Dumazet 提交者: David S. Miller

gro: more generic L2 header check

Shlomo Pongratz reported GRO L2 header check was suited for Ethernet
only, and failed on IB/ipoib traffic.

He provided a patch faking a zeroed header to let GRO aggregates frames.

Roland Dreier, Herbert Xu, and others suggested we change GRO L2 header
check to be more generic, ie not assuming L2 header is 14 bytes, but
taking into account hard_header_len.

__napi_gro_receive() has special handling for the common case (Ethernet)
to avoid a memcmp() call and use an inline optimized function instead.
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Reported-by: NShlomo Pongratz <shlomop@mellanox.com>
Cc: Roland Dreier <roland@kernel.org>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: NSean Hefty <sean.hefty@intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 377cb4f9
...@@ -3491,14 +3491,20 @@ static inline gro_result_t ...@@ -3491,14 +3491,20 @@ static inline gro_result_t
__napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
{ {
struct sk_buff *p; struct sk_buff *p;
unsigned int maclen = skb->dev->hard_header_len;
for (p = napi->gro_list; p; p = p->next) { for (p = napi->gro_list; p; p = p->next) {
unsigned long diffs; unsigned long diffs;
diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev; diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev;
diffs |= p->vlan_tci ^ skb->vlan_tci; diffs |= p->vlan_tci ^ skb->vlan_tci;
diffs |= compare_ether_header(skb_mac_header(p), if (maclen == ETH_HLEN)
skb_gro_mac_header(skb)); diffs |= compare_ether_header(skb_mac_header(p),
skb_gro_mac_header(skb));
else if (!diffs)
diffs = memcmp(skb_mac_header(p),
skb_gro_mac_header(skb),
maclen);
NAPI_GRO_CB(p)->same_flow = !diffs; NAPI_GRO_CB(p)->same_flow = !diffs;
NAPI_GRO_CB(p)->flush = 0; NAPI_GRO_CB(p)->flush = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册