Skip to contentSkip to conversation

udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames

PATCH In review Jiri Pirko 3 participants 6 messages Sep 30, 2013 – Oct 2, 2013

Subsystems (4)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames

if up->pending != 0 dontfrag is left with default value -1. That causes that application that do:
sendto len>mtu flag MSG_MORE
sendto len>mtu flag 0
will receive EMSGSIZE errno as the result of the second sendto.

This patch fixes it by respecting IPV6_DONTFRAG socket option.

introduced by:
commit 4b340ae20d0e2366792abe70f46629e576adaf5e "IPv6: Complete IPV6_DONTFRAG support"

Please push to stable as well.

---
 net/ipv6/udp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/ipv6/udp.c +2 -3
index 72b7eaa..1878609 100644
@@ -1225,9 +1225,6 @@ do_udp_sendmsg:
 	if (tclass < 0)
 		tclass = np->tclass;
 
-	if (dontfrag < 0)
-		dontfrag = np->dontfrag;
-
 	if (msg->msg_flags&MSG_CONFIRM)
 		goto do_confirm;
 back_from_confirm:
@@ -1246,6 +1243,8 @@ back_from_confirm:
 	up->pending = AF_INET6;
 
 do_append_data:
+	if (dontfrag < 0)
+		dontfrag = np->dontfrag;
 	up->len += ulen;
 	getfrag  =  is_udplite ?  udplite_getfrag : ip_generic_getfrag;
 	err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 33 lines · Jiri Pirko

if up->pending != 0 dontfrag is left with default value -1. That causes that application that do:
sendto len>mtu flag MSG_MORE
sendto len>mtu flag 0
will receive EMSGSIZE errno as the result of the second sendto.

This patch fixes it by respecting IPV6_DONTFRAG socket option.

introduced by:
commit 4b340ae20d0e2366792abe70f46629e576adaf5e "IPv6: Complete IPV6_DONTFRAG support"

Please push to stable as well.

---
 net/ipv6/udp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/ipv6/udp.c +0 -3
index 72b7eaa..1878609 100644
@@ -1225,9 +1225,6 @@ do_udp_sendmsg:
 	if (tclass < 0)
 		tclass = np->tclass;
 
-	if (dontfrag < 0)
-		dontfrag = np->dontfrag;
-
 	if (msg->msg_flags&MSG_CONFIRM)
 		goto do_confirm;
 back_from_confirm:

net/ipv6/udp.c back_from_confirm: · line 1250

Quoted 8 lines
net/ipv6/udp.c +2 -0
@@ -1246,6 +1243,8 @@ back_from_confirm:
 	up->pending = AF_INET6;
 
 do_append_data:
+	if (dontfrag < 0)
+		dontfrag = np->dontfrag;
 	up->len += ulen;
 	getfrag  =  is_udplite ?  udplite_getfrag : ip_generic_getfrag;
 	err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,

Hmm, I wonder if we need the same change in ipv6/raw.c.

Looks good at first sight, but I need to do some more tests.

#2 lore raw
Quoted 1 line · Hannes Frederic Sowa

Hmm, I wonder if we need the same change in ipv6/raw.c.

Nope, ipv6/raw.c is fine.

Quoted 1 line

Looks good at first sight, but I need to do some more tests.

Strange, loopback traffic is not bound by the frag_size. This fixes it but should not be necessary. Don't know the reason, yet.

net/ipv6/ip6_output.c +8 -1
index a54c45c..9dd136e 100644
@@ -124,7 +124,14 @@ static int ip6_finish_output2(struct sk_buff *skb)
 
 static int ip6_finish_output(struct sk_buff *skb)
 {
-	if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) ||
+	int mtu;
+	struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
+
+	mtu = ip6_skb_dst_mtu(skb);
+	if (np && np->frag_size && np->frag_size < mtu)
+		mtu = np->frag_size;
+
+	if ((skb->len > mtu && !skb_is_gso(skb)) ||
 	    dst_allfrag(skb_dst(skb)))
 		return ip6_fragment(skb, ip6_finish_output2);
 	else

Regarding your patch, this is fine by me:

Thanks,

Hannes

#3 lore raw

Hi David!

Quoted 1 line · Hannes Frederic Sowa

(for patchwork correspondence)

I still think this patch is perfectly fine but it opens up a hole in the ip6_append_data logic where it is possible to crash the kernel. Jiri and me will look after it in the thread " ipv6: udp packets following an UFO enqueued packet need also be handled by UFO".

So, for the time being, I would like to withdraw my Acked-by until this is sorted out.

Thanks,

Hannes

maintainer
#4 lore raw

From: Hannes Frederic Sowa <[email protected]>
Date: Wed, 2 Oct 2013 00:03:54 +0200

Quoted 7 lines

Hi David!

Quoted 1 line · Hannes Frederic Sowa

(for patchwork correspondence)

Quoted 7 lines

I still think this patch is perfectly fine but it opens up a hole in the ip6_append_data logic where it is possible to crash the kernel. Jiri and me will look after it in the thread " ipv6: udp packets following an UFO enqueued packet need also be handled by UFO".

So, for the time being, I would like to withdraw my Acked-by until this is sorted out.

Jiri please repost the IPV6_DONTFRAG patch once things are sorted, thanks.

author
#5 lore raw
Quoted 15 lines · Wed, Oct 02, 2013 at 10:00:28PM CEST, [email protected] wrote:

From: Hannes Frederic Sowa <[email protected]>
Date: Wed, 2 Oct 2013 00:03:54 +0200

Quoted 12 lines

Hi David!

Quoted 1 line · Hannes Frederic Sowa

(for patchwork correspondence)

I still think this patch is perfectly fine but it opens up a hole in the ip6_append_data logic where it is possible to crash the kernel. Jiri and me will look after it in the thread " ipv6: udp packets following an UFO enqueued packet need also be handled by UFO".

Quoted 4 lines
Quoted 2 lines

So, for the time being, I would like to withdraw my Acked-by until this is sorted out.

Jiri please repost the IPV6_DONTFRAG patch once things are sorted, thanks.

allright