Skip to contentSkip to conversation

xfrm: interface: fix ipv4 pmtu check to honor ip header df

PATCH Superseded Eyal Birger 4 participants 6 messages Feb 19, 2021 – Feb 23, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: interface: fix ipv4 pmtu check to honor ip header df

Frag needed should only be sent if the header enables DF.

This fix allows packets larger than MTU to pass the xfrm interface and be fragmented after encapsulation, aligning behavior with non-interface xfrm.

Fixes f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
---
 net/xfrm/xfrm_interface.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
net/xfrm/xfrm_interface.c +7 -4
index 697cdcfbb5e1..257b3c8b3995 100644
@@ -304,13 +304,16 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 				mtu = IPV6_MIN_MTU;
 
 			icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
-		} else {
+			err = -EMSGSIZE;
+			goto tx_err_dst_release;
+		}
+
+		if (ip_hdr(skb)->frag_off & htons(IP_DF)) {
 			icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
 				      htonl(mtu));
+			err = -EMSGSIZE;
+			goto tx_err_dst_release;
 		}
-
-		dst_release(dst);
-		return -EMSGSIZE;
 	}
 
 	xfrmi_scrub_packet(skb, !net_eq(xi->net, dev_net(dev)));
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 xfrm: interface: fix ipv4 pmtu check to honor ip header df

Frag needed should only be sent if the header enables DF.

This fix allows packets larger than MTU to pass the xfrm interface and be fragmented after encapsulation, aligning behavior with non-interface xfrm.

Fixes f203b76d7809 ("xfrm: Add virtual xfrm interfaces")

-----

v2: better align coding with ip_vti

---
 net/xfrm/xfrm_interface.c | 3 +++
 1 file changed, 3 insertions(+)
net/xfrm/xfrm_interface.c +3 -0
index 697cdcfbb5e1..3f42c2f15ba4 100644
@@ -305,6 +305,8 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 
 			icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
 		} else {
+			if (!(ip_hdr(skb)->frag_off & htons(IP_DF)))
+				goto xmit;
 			icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
 				      htonl(mtu));
 		}
@@ -313,6 +315,7 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
 		return -EMSGSIZE;
 	}
 
+xmit:
 	xfrmi_scrub_packet(skb, !net_eq(xi->net, dev_net(dev)));
 	skb_dst_set(skb, dst);
 	skb->dev = tdev;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#2 lore raw
Quoted 6 lines · Eyal Birger

Frag needed should only be sent if the header enables DF.

This fix allows packets larger than MTU to pass the xfrm interface and be fragmented after encapsulation, aligning behavior with non-interface xfrm.

Quoted 6 lines
Fixes f203b76d7809 ("xfrm: Add virtual xfrm interfaces")

-----

v2: better align coding with ip_vti

LGTM. We also need to do the same thing in ip_vti and ip6_vti. Do you want to take care of it, or should I?

Either way, for this patch:

Signature · 1 line
Sabrina
#3 lore raw
Quoted 3 lines · Sabrina Dubroca

LGTM. We also need to do the same thing in ip_vti and ip6_vti. Do you want to take care of it, or should I?

See the thread
https://lore.kernel.org/netdev/[email protected]/
(I'm assuming the patches no longer applies cleanly but given that I was ignored last time I will not be resubmitting them.)

--
Bram

#4 lore raw
In reply to Sabrina Dubroca

Hi,

Quoted 11 lines · Sabrina Dubroca
Quoted 9 lines · Eyal Birger

Frag needed should only be sent if the header enables DF.

This fix allows packets larger than MTU to pass the xfrm interface and be fragmented after encapsulation, aligning behavior with non-interface xfrm.

Fixes f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Quoted 6 lines
Quoted 3 lines

-----

v2: better align coding with ip_vti

LGTM. We also need to do the same thing in ip_vti and ip6_vti. Do you want to take care of it, or should I?

I can submit the same fix for vti{,6}.

Quoted 3 lines

Either way, for this patch:

Thanks!
Eyal.

maintainer Applied
#5 lore raw
In reply to Sabrina Dubroca
Quoted 12 lines · Sabrina Dubroca
Quoted 11 lines · Eyal Birger

Frag needed should only be sent if the header enables DF.

This fix allows packets larger than MTU to pass the xfrm interface and be fragmented after encapsulation, aligning behavior with non-interface xfrm.

Fixes f203b76d7809 ("xfrm: Add virtual xfrm interfaces")

-----

Quoted 7 lines
Quoted 1 line

v2: better align coding with ip_vti

LGTM. We also need to do the same thing in ip_vti and ip6_vti. Do you want to take care of it, or should I?

Either way, for this patch:

Applied, thanks everyone!