Skip to content

Commit 5babae7

Browse files
Richard GobertPaolo Abeni
authored andcommitted
net: gro: add flush check in udp_gro_receive_segment
GRO-GSO path is supposed to be transparent and as such L3 flush checks are relevant to all UDP flows merging in GRO. This patch uses the same logic and code from tcp_gro_receive, terminating merge if flush is non zero. Fixes: e20cf8d ("udp: implement GRO for plain UDP sockets.") Signed-off-by: Richard Gobert <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 5ef31ea commit 5babae7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

net/ipv4/udp_offload.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
471471
struct sk_buff *p;
472472
unsigned int ulen;
473473
int ret = 0;
474+
int flush;
474475

475476
/* requires non zero csum, for symmetry with GSO */
476477
if (!uh->check) {
@@ -504,13 +505,22 @@ static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
504505
return p;
505506
}
506507

508+
flush = NAPI_GRO_CB(p)->flush;
509+
510+
if (NAPI_GRO_CB(p)->flush_id != 1 ||
511+
NAPI_GRO_CB(p)->count != 1 ||
512+
!NAPI_GRO_CB(p)->is_atomic)
513+
flush |= NAPI_GRO_CB(p)->flush_id;
514+
else
515+
NAPI_GRO_CB(p)->is_atomic = false;
516+
507517
/* Terminate the flow on len mismatch or if it grow "too much".
508518
* Under small packet flood GRO count could elsewhere grow a lot
509519
* leading to excessive truesize values.
510520
* On len mismatch merge the first packet shorter than gso_size,
511521
* otherwise complete the GRO packet.
512522
*/
513-
if (ulen > ntohs(uh2->len)) {
523+
if (ulen > ntohs(uh2->len) || flush) {
514524
pp = p;
515525
} else {
516526
if (NAPI_GRO_CB(skb)->is_flist) {

0 commit comments

Comments
 (0)