diff mbox

ipv6: Limit mtu to 65572 bytes

Message ID 1397186427.16584.86.camel@edumazet-glaptop2.roam.corp.google.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet April 11, 2014, 3:20 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

Francois reported that setting big mtu on loopback device could prevent
tcp sessions making progress.

We do not support (yet ?) IPv6 Jumbograms and cook corrupted packets.

We must limit the IPv6 MTU to (65535 + 40) bytes in theory.

Tested:

ifconfig lo mtu 70000
netperf -H ::1

Before patch : Throughput :   0.05 Mbits

After patch : Throughput : 35484 Mbits

Reported-by: Francois WELLENREITER <f.wellenreiter@gmail.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
v2: set the max limit, not round-down it.

 include/net/ip6_route.h |    5 +++++
 net/ipv6/route.c        |    5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

YOSHIFUJI Hideaki / 吉藤英明 April 11, 2014, 3:26 a.m. UTC | #1
Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Francois reported that setting big mtu on loopback device could prevent
> tcp sessions making progress.
> 
> We do not support (yet ?) IPv6 Jumbograms and cook corrupted packets.
> 
> We must limit the IPv6 MTU to (65535 + 40) bytes in theory.
> 
> Tested:
> 
> ifconfig lo mtu 70000
> netperf -H ::1
> 
> Before patch : Throughput :   0.05 Mbits
> 
> After patch : Throughput : 35484 Mbits
> 
> Reported-by: Francois WELLENREITER <f.wellenreiter@gmail.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

--yoshfuji


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
YOSHIFUJI Hideaki / 吉藤英明 April 11, 2014, 3:30 a.m. UTC | #2
Eric,

YOSHIFUJI Hideaki wrote:
> Eric Dumazet wrote:
>> From: Eric Dumazet <edumazet@google.com>
>>
>> Francois reported that setting big mtu on loopback device could prevent
>> tcp sessions making progress.
>>
>> We do not support (yet ?) IPv6 Jumbograms and cook corrupted packets.
>>
>> We must limit the IPv6 MTU to (65535 + 40) bytes in theory.
>>
>> Tested:
>>
>> ifconfig lo mtu 70000
>> netperf -H ::1
>>
>> Before patch : Throughput :   0.05 Mbits
>>
>> After patch : Throughput : 35484 Mbits
>>
>> Reported-by: Francois WELLENREITER <f.wellenreiter@gmail.com>
>> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>

Oops, you need to change the subject as well.
Otherwise, I am okay.

Thanks a lot.

--yoshfuji
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 11, 2014, 3:30 a.m. UTC | #3
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 10 Apr 2014 20:20:27 -0700

> +/* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
> + * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
> + */
> +#define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr))

Hmmm, does this still match $Subj?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eric Dumazet April 11, 2014, 4:20 a.m. UTC | #4
On Thu, 2014-04-10 at 23:30 -0400, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>
> Date: Thu, 10 Apr 2014 20:20:27 -0700
> 
> > +/* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
> > + * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
> > + */
> > +#define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr))
> 
> Hmmm, does this still match $Subj?

Ugh, sorry, I had to run. I'll resend. 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 3c3bb184eb8f..6c4f5eac98e7 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -32,6 +32,11 @@  struct route_info {
 #define RT6_LOOKUP_F_SRCPREF_PUBLIC	0x00000010
 #define RT6_LOOKUP_F_SRCPREF_COA	0x00000020
 
+/* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
+ * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
+ */
+#define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr))
+
 /*
  * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
  * between IPV6_ADDR_PREFERENCES socket option values
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 5015c50a5ba7..5ea462eacd9f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1338,7 +1338,7 @@  static unsigned int ip6_mtu(const struct dst_entry *dst)
 	unsigned int mtu = dst_metric_raw(dst, RTAX_MTU);
 
 	if (mtu)
-		return mtu;
+		goto out;
 
 	mtu = IPV6_MIN_MTU;
 
@@ -1348,7 +1348,8 @@  static unsigned int ip6_mtu(const struct dst_entry *dst)
 		mtu = idev->cnf.mtu6;
 	rcu_read_unlock();
 
-	return mtu;
+out:
+	return min_t(unsigned int, mtu, IP6_MAX_MTU);
 }
 
 static struct dst_entry *icmp6_dst_gc_list;