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
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.
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>
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
23 /* requires non zero csum, for symmetry with GSO */
25 @@ -504,13 +505,22 @@ static struct sk_buff *udp_gro_receive_s
29 + flush = NAPI_GRO_CB(p)->flush;
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;
36 + NAPI_GRO_CB(p)->is_atomic = false;
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.
44 - if (ulen > ntohs(uh2->len)) {
45 + if (ulen > ntohs(uh2->len) || flush) {
48 if (NAPI_GRO_CB(skb)->is_flist) {