Skip to content

Commit 21f1b8a

Browse files
Paolo Abenidavem330
authored andcommitted
udp: fix GRO reception in case of length mismatch
Currently, the UDP GRO code path does bad things on some edge conditions - Aggregation can happen even on packet with different lengths. Fix the above by rewriting the 'complete' condition for GRO packets. While at it, note explicitly that we allow merging the first packet per burst below gso_size. Reported-by: Sean Tong <[email protected]> Fixes: e20cf8d ("udp: implement GRO for plain UDP sockets.") Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fbef947 commit 21f1b8a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/ipv4/udp_offload.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,14 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
377377

378378
/* Terminate the flow on len mismatch or if it grow "too much".
379379
* Under small packet flood GRO count could elsewhere grow a lot
380-
* leading to execessive truesize values
380+
* leading to execessive truesize values.
381+
* On len mismatch merge the first packet shorter than gso_size,
382+
* otherwise complete the GRO packet.
381383
*/
382-
if (!skb_gro_receive(p, skb) &&
384+
if (uh->len > uh2->len || skb_gro_receive(p, skb) ||
385+
uh->len != uh2->len ||
383386
NAPI_GRO_CB(p)->count >= UDP_GRO_CNT_MAX)
384387
pp = p;
385-
else if (uh->len != uh2->len)
386-
pp = p;
387388

388389
return pp;
389390
}

0 commit comments

Comments
 (0)