mvebu: Remove patch only needed for kernel 5.10
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 050-gro-fix-napi_gro_frags-Fast-GRO-breakage-due-to-IP-a.patch
1 From 3007b05df4301aad179acc6ca1c3645785576df6 Mon Sep 17 00:00:00 2001
2 From: Alexander Lobakin <alobakin@pm.me>
3 Date: Mon, 19 Apr 2021 12:53:06 +0000
4 Subject: gro: fix napi_gro_frags() Fast GRO breakage due to IP
5 alignment check
6
7 Commit 7ad18ff6449cbd6beb26b53128ddf56d2685aa93 upstream.
8
9 Commit 38ec4944b593 ("gro: ensure frag0 meets IP header alignment")
10 did the right thing, but missed the fact that napi_gro_frags() logics
11 calls for skb_gro_reset_offset() *before* pulling Ethernet header
12 to the skb linear space.
13 That said, the introduced check for frag0 address being aligned to 4
14 always fails for it as Ethernet header is obviously 14 bytes long,
15 and in case with NET_IP_ALIGN its start is not aligned to 4.
16
17 Fix this by adding @nhoff argument to skb_gro_reset_offset() which
18 tells if an IP header is placed right at the start of frag0 or not.
19 This restores Fast GRO for napi_gro_frags() that became very slow
20 after the mentioned commit, and preserves the introduced check to
21 avoid silent unaligned accesses.
22
23 From v1 [0]:
24 - inline tiny skb_gro_reset_offset() to let the code be optimized
25 more efficively (esp. for the !NET_IP_ALIGN case) (Eric);
26 - pull in Reviewed-by from Eric.
27
28 [0] https://lore.kernel.org/netdev/20210418114200.5839-1-alobakin@pm.me
29
30 Fixes: 38ec4944b593 ("gro: ensure frag0 meets IP header alignment")
31 Reviewed-by: Eric Dumazet <edumazet@google.com>
32 Signed-off-by: Alexander Lobakin <alobakin@pm.me>
33 Signed-off-by: David S. Miller <davem@davemloft.net>
34 ---
35 net/core/dev.c | 8 ++++----
36 1 file changed, 4 insertions(+), 4 deletions(-)
37
38 --- a/net/core/dev.c
39 +++ b/net/core/dev.c
40 @@ -5395,7 +5395,7 @@ static struct list_head *gro_list_prepar
41 return head;
42 }
43
44 -static void skb_gro_reset_offset(struct sk_buff *skb)
45 +static inline void skb_gro_reset_offset(struct sk_buff *skb, u32 nhoff)
46 {
47 const struct skb_shared_info *pinfo = skb_shinfo(skb);
48 const skb_frag_t *frag0 = &pinfo->frags[0];
49 @@ -5407,7 +5407,7 @@ static void skb_gro_reset_offset(struct
50 if (skb_mac_header(skb) == skb_tail_pointer(skb) &&
51 pinfo->nr_frags &&
52 !PageHighMem(skb_frag_page(frag0)) &&
53 - (!NET_IP_ALIGN || !(skb_frag_off(frag0) & 3))) {
54 + (!NET_IP_ALIGN || !((skb_frag_off(frag0) + nhoff) & 3))) {
55 NAPI_GRO_CB(skb)->frag0 = skb_frag_address(frag0);
56 NAPI_GRO_CB(skb)->frag0_len = min_t(unsigned int,
57 skb_frag_size(frag0),
58 @@ -5640,7 +5640,7 @@ gro_result_t napi_gro_receive(struct nap
59 skb_mark_napi_id(skb, napi);
60 trace_napi_gro_receive_entry(skb);
61
62 - skb_gro_reset_offset(skb);
63 + skb_gro_reset_offset(skb, 0);
64
65 ret = napi_skb_finish(napi, skb, dev_gro_receive(napi, skb));
66 trace_napi_gro_receive_exit(ret);
67 @@ -5733,7 +5733,7 @@ static struct sk_buff *napi_frags_skb(st
68 napi->skb = NULL;
69
70 skb_reset_mac_header(skb);
71 - skb_gro_reset_offset(skb);
72 + skb_gro_reset_offset(skb, hlen);
73
74 if (unlikely(skb_gro_header_hard(skb, hlen))) {
75 eth = skb_gro_header_slow(skb, hlen, 0);