72b76dd938bf83b6b2518b4f0093995963f8681c
[openwrt/staging/ansuel.git] /
1 From: Richard Gobert <richardbgobert@gmail.com>
2 Date: Tue, 30 Apr 2024 16:35:55 +0200
3 Subject: [PATCH] net: gro: add flush check in udp_gro_receive_segment
4
5 GRO-GSO path is supposed to be transparent and as such L3 flush checks are
6 relevant to all UDP flows merging in GRO. This patch uses the same logic
7 and code from tcp_gro_receive, terminating merge if flush is non zero.
8
9 Fixes: e20cf8d3f1f7 ("udp: implement GRO for plain UDP sockets.")
10 Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
11 Reviewed-by: Willem de Bruijn <willemb@google.com>
12 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
13 ---
14
15 --- a/net/ipv4/udp_offload.c
16 +++ b/net/ipv4/udp_offload.c
17 @@ -471,6 +471,7 @@ static struct sk_buff *udp_gro_receive_s
18 struct sk_buff *p;
19 unsigned int ulen;
20 int ret = 0;
21 + int flush;
22
23 /* requires non zero csum, for symmetry with GSO */
24 if (!uh->check) {
25 @@ -504,13 +505,22 @@ static struct sk_buff *udp_gro_receive_s
26 return p;
27 }
28
29 + flush = NAPI_GRO_CB(p)->flush;
30 +
31 + if (NAPI_GRO_CB(p)->flush_id != 1 ||
32 + NAPI_GRO_CB(p)->count != 1 ||
33 + !NAPI_GRO_CB(p)->is_atomic)
34 + flush |= NAPI_GRO_CB(p)->flush_id;
35 + else
36 + NAPI_GRO_CB(p)->is_atomic = false;
37 +
38 /* Terminate the flow on len mismatch or if it grow "too much".
39 * Under small packet flood GRO count could elsewhere grow a lot
40 * leading to excessive truesize values.
41 * On len mismatch merge the first packet shorter than gso_size,
42 * otherwise complete the GRO packet.
43 */
44 - if (ulen > ntohs(uh2->len)) {
45 + if (ulen > ntohs(uh2->len) || flush) {
46 pp = p;
47 } else {
48 if (NAPI_GRO_CB(skb)->is_flist) {