netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280
@ 2013-10-03 13:49 Oussama Ghorbel
  2013-10-04 13:32 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 3+ messages in thread
From: Oussama Ghorbel @ 2013-10-03 13:49 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy
  Cc: netdev, linux-kernel, Oussama Ghorbel

The (inner) MTU of a ipip6 (IPv4-in-IPv6) tunnel cannot be set below 1280, which is the minimum MTU in IPv6.
However, there should be no IPv6 on the tunnel interface at all, so the IPv6 rules should not apply.
More info at https://bugzilla.kernel.org/show_bug.cgi?id=15530

This patch allows to check the minimum MTU for ipv6 tunnel according to these rules:
-In case the tunnel is configured with ipip6 mode the minimum MTU is 68.
-In case the tunnel is configured with ip6ip6 or any mode the minimum MTU is 1280.

Signed-off-by: Oussama Ghorbel <ou.ghorbel@gmail.com>
---
 net/ipv6/ip6_tunnel.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 46ba243..4b51b03 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1429,9 +1429,17 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 static int
 ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
 {
-	if (new_mtu < IPV6_MIN_MTU) {
-		return -EINVAL;
+	struct ip6_tnl *tnl = netdev_priv(dev);
+
+	if (tnl->parms.proto == IPPROTO_IPIP) {
+		if (new_mtu < 68)
+			return -EINVAL;
+	} else {
+		if (new_mtu < IPV6_MIN_MTU)
+			return -EINVAL;
 	}
+	if (new_mtu > 0xFFF8 - dev->hard_header_len)
+		return -EINVAL;
 	dev->mtu = new_mtu;
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280
  2013-10-03 13:49 [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280 Oussama Ghorbel
@ 2013-10-04 13:32 ` Hannes Frederic Sowa
  2013-10-07 16:33   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-04 13:32 UTC (permalink / raw)
  To: Oussama Ghorbel
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, netdev, linux-kernel

On Thu, Oct 03, 2013 at 02:49:26PM +0100, Oussama Ghorbel wrote:
> The (inner) MTU of a ipip6 (IPv4-in-IPv6) tunnel cannot be set below 1280, which is the minimum MTU in IPv6.
> However, there should be no IPv6 on the tunnel interface at all, so the IPv6 rules should not apply.
> More info at https://bugzilla.kernel.org/show_bug.cgi?id=15530
> 
> This patch allows to check the minimum MTU for ipv6 tunnel according to these rules:
> -In case the tunnel is configured with ipip6 mode the minimum MTU is 68.
> -In case the tunnel is configured with ip6ip6 or any mode the minimum MTU is 1280.
> 
> Signed-off-by: Oussama Ghorbel <ou.ghorbel@gmail.com>
> ---
>  net/ipv6/ip6_tunnel.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 46ba243..4b51b03 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -1429,9 +1429,17 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
>  static int
>  ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
>  {
> -	if (new_mtu < IPV6_MIN_MTU) {
> -		return -EINVAL;
> +	struct ip6_tnl *tnl = netdev_priv(dev);
> +
> +	if (tnl->parms.proto == IPPROTO_IPIP) {
> +		if (new_mtu < 68)
> +			return -EINVAL;
> +	} else {
> +		if (new_mtu < IPV6_MIN_MTU)
> +			return -EINVAL;
>  	}
> +	if (new_mtu > 0xFFF8 - dev->hard_header_len)
> +		return -EINVAL;
>  	dev->mtu = new_mtu;
>  	return 0;
>  }

Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Anytime soon we should replace all the FFF8 with a symbolic constant.

Thanks,

  Hannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280
  2013-10-04 13:32 ` Hannes Frederic Sowa
@ 2013-10-07 16:33   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-10-07 16:33 UTC (permalink / raw)
  To: hannes; +Cc: ou.ghorbel, kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Fri, 4 Oct 2013 15:32:23 +0200

> On Thu, Oct 03, 2013 at 02:49:26PM +0100, Oussama Ghorbel wrote:
>> The (inner) MTU of a ipip6 (IPv4-in-IPv6) tunnel cannot be set below 1280, which is the minimum MTU in IPv6.
>> However, there should be no IPv6 on the tunnel interface at all, so the IPv6 rules should not apply.
>> More info at https://bugzilla.kernel.org/show_bug.cgi?id=15530
>> 
>> This patch allows to check the minimum MTU for ipv6 tunnel according to these rules:
>> -In case the tunnel is configured with ipip6 mode the minimum MTU is 68.
>> -In case the tunnel is configured with ip6ip6 or any mode the minimum MTU is 1280.
>> 
>> Signed-off-by: Oussama Ghorbel <ou.ghorbel@gmail.com>
 ...
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Applied, but please do not capitalize "IPv6" when using it as a subsystem
prefix in Subject lines.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-07 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-03 13:49 [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280 Oussama Ghorbel
2013-10-04 13:32 ` Hannes Frederic Sowa
2013-10-07 16:33   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).