600-v6.9-03-net-gro-add-flush-check-in-udp_gro_receive_segment.patch 1.6 KB

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