Skip to content

Commit 18f25dc

Browse files
Paolo Abenidavem330
authored andcommitted
udp: skip L4 aggregation for UDP tunnel packets
If NETIF_F_GRO_FRAGLIST or NETIF_F_GRO_UDP_FWD are enabled, and there are UDP tunnels available in the system, udp_gro_receive() could end-up doing L4 aggregation (either SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST) at the outer UDP tunnel level for packets effectively carrying and UDP tunnel header. That could cause inner protocol corruption. If e.g. the relevant packets carry a vxlan header, different vxlan ids will be ignored/ aggregated to the same GSO packet. Inner headers will be ignored, too, so that e.g. TCP over vxlan push packets will be held in the GRO engine till the next flush, etc. Just skip the SKB_GSO_UDP_L4 and SKB_GSO_FRAGLIST code path if the current packet could land in a UDP tunnel, and let udp_gro_receive() do GRO via udp_sk(sk)->gro_receive. The check implemented in this patch is broader than what is strictly needed, as the existing UDP tunnel could be e.g. configured on top of a different device: we could end-up skipping GRO at-all for some packets. Anyhow, that is a very thin corner case and covering it will add quite a bit of complexity. v1 -> v2: - hopefully clarify the commit message Fixes: 9fd1ff5 ("udp: Support UDP fraglist GRO/GSO.") Fixes: 3670706 ("udp: allow forwarding of plain (non-fraglisted) UDP GRO packets") Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 000ac44 commit 18f25dc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

net/ipv4/udp_offload.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,24 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
515515
unsigned int off = skb_gro_offset(skb);
516516
int flush = 1;
517517

518+
/* we can do L4 aggregation only if the packet can't land in a tunnel
519+
* otherwise we could corrupt the inner stream
520+
*/
518521
NAPI_GRO_CB(skb)->is_flist = 0;
519-
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
520-
NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
522+
if (!sk || !udp_sk(sk)->gro_receive) {
523+
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
524+
NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled : 1;
521525

522-
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
523-
(sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) {
524-
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
526+
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
527+
(sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist)
528+
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
525529
return pp;
526530
}
527531

528-
if (!sk || NAPI_GRO_CB(skb)->encap_mark ||
532+
if (NAPI_GRO_CB(skb)->encap_mark ||
529533
(uh->check && skb->ip_summed != CHECKSUM_PARTIAL &&
530534
NAPI_GRO_CB(skb)->csum_cnt == 0 &&
531-
!NAPI_GRO_CB(skb)->csum_valid) ||
532-
!udp_sk(sk)->gro_receive)
535+
!NAPI_GRO_CB(skb)->csum_valid))
533536
goto out;
534537

535538
/* mark that this skb passed once through the tunnel gro layer */

0 commit comments

Comments
 (0)