Skip to contentSkip to conversation

udp: segment looped gso packets correctly

PATCH In review Willem de Bruijn 3 participants 5 messages Jan 27, 2020 – Jan 29, 2020

Subsystems (3)
lore
Share & tools
lore

Willem de Bruijn

author maintainer
#0 lore raw

PATCH 1/1 udp: segment looped gso packets correctly

From: Willem de Bruijn <[email protected]>

Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.

udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.

UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)

Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")
---
 include/net/udp.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/udp.h +3 -0
index bad74f7808311..8f163d674f072 100644
@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
 	if (!inet_get_convert_csum(sk))
 		features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 
+	if (skb->pkt_type == PACKET_LOOPBACK)
+		skb->ip_summed = CHECKSUM_PARTIAL;
+
 	/* the GSO CB lays after the UDP one, no need to save and restore any
 	 * CB fragment
 	 */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 27 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.

udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.

UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)

Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")
---
 include/net/udp.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/udp.h +0 -0
index bad74f7808311..8f163d674f072 100644

include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 484

Quoted 9 lines
include/net/udp.h +3 -0
@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
 	if (!inet_get_convert_csum(sk))
 		features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 
+	if (skb->pkt_type == PACKET_LOOPBACK)
+		skb->ip_summed = CHECKSUM_PARTIAL;
+
 	/* the GSO CB lays after the UDP one, no need to save and restore any
 	 * CB fragment
 	 */

LGTM, Thanks!

Out of sheer curiosity, do you know what was the kernel behaviour before the 'fixes' commit ? GSO packet delivered to user-space stillaggregated ?!?

Thanks,

Paolo

author maintainer
#2 lore raw
Quoted 41 lines · Paolo Abeni
Quoted 27 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.

udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.

UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)

Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")
---
 include/net/udp.h | 3 +++
 1 file changed, 3 insertions(+)
include/net/udp.h +0 -0
index bad74f7808311..8f163d674f072 100644

include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 484

Quoted 9 lines
include/net/udp.h +3 -0
@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
      if (!inet_get_convert_csum(sk))
              features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
 
+     if (skb->pkt_type == PACKET_LOOPBACK)
+             skb->ip_summed = CHECKSUM_PARTIAL;
+
      /* the GSO CB lays after the UDP one, no need to save and restore any
       * CB fragment
       */

LGTM, Thanks!

Quoted 4 lines

Out of sheer curiosity, do you know what was the kernel behaviour before the 'fixes' commit ? GSO packet delivered to user-space stillaggregated ?!?

Yes.. I had missed this entire ip_mc_output path when adding segmentation (clearly).

Your patch fixed that. The other options would be segmenting in dev_loopback_xmit or outright failing the call in udp_send_skb. Neither of which is appealing.

Thanks for reviewing!

maintainer
#3 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Mon, 27 Jan 2020 15:40:31 -0500

Quoted 11 lines

From: Willem de Bruijn <[email protected]>

Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.

udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.

Quoted 7 lines

UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)

Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")

Applied and queued up for -stable, but I have to say:

include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 481

Quoted 3 lines
include/net/udp.h +3 -0
+	if (skb->pkt_type == PACKET_LOOPBACK)
+		skb->ip_summed = CHECKSUM_PARTIAL;
+

There are a lot of implementation detail assumptions encoded into that conditional statement :-)

Feel free to follow-up with a patch adding a comment containing a condensed version of your commit log here.

Thanks.

author maintainer
#4 lore raw
Quoted 29 lines · David Miller

From: Willem de Bruijn <[email protected]>
Date: Mon, 27 Jan 2020 15:40:31 -0500

Quoted 11 lines

From: Willem de Bruijn <[email protected]>

Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.

udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.

Quoted 7 lines

UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)

Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")

Applied and queued up for -stable, but I have to say:

include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 481

Quoted 3 lines
include/net/udp.h +3 -0
+     if (skb->pkt_type == PACKET_LOOPBACK)
+             skb->ip_summed = CHECKSUM_PARTIAL;
+
Quoted 5 lines

There are a lot of implementation detail assumptions encoded into that conditional statement :-)

Feel free to follow-up with a patch adding a comment containing a condensed version of your commit log here.

Will do. Yeah, that does look pretty obscure. I may have gotten a bit too used to relying solely on git blame ;-)

Thanks!