aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Dichtel <nicolas.dichtel@6wind.com>2018-05-31 04:59:32 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-01 13:56:29 -0400
commit82612de1c98e610d194e34178bde3cca7dedce41 (patch)
tree383941b19ac9d250901bf771c2bd44d59ca70208
parentccfde6e27d9566bee596d41a2cc6f158af8595d5 (diff)
ip_tunnel: restore binding to ifaces with a large mtu
After commit f6cc9c054e77, the following conf is broken (note that the default loopback mtu is 65536, ie IP_MAX_MTU + 1): $ ip tunnel add gre1 mode gre local 10.125.0.1 remote 10.125.0.2 dev lo add tunnel "gre0" failed: Invalid argument $ ip l a type dummy $ ip l s dummy1 up $ ip l s dummy1 mtu 65535 $ ip tunnel add gre1 mode gre local 10.125.0.1 remote 10.125.0.2 dev dummy1 add tunnel "gre0" failed: Invalid argument dev_set_mtu() doesn't allow to set a mtu which is too large. First, let's cap the mtu returned by ip_tunnel_bind_dev(). Second, remove the magic value 0xFFF8 and use IP_MAX_MTU instead. 0xFFF8 seems to be there for ages, I don't know why this value was used. With a recent kernel, it's also possible to set a mtu > IP_MAX_MTU: $ ip l s dummy1 mtu 66000 After that patch, it's also possible to bind an ip tunnel on that kind of interface. CC: Petr Machata <petrm@mellanox.com> CC: Ido Schimmel <idosch@mellanox.com> Link: https://git.kernel.org/pub/scm/linux/kernel/git/davem/netdev-vger-cvs.git/commit/?id=e5afd356a411a Fixes: f6cc9c054e77 ("ip_tunnel: Emit events for post-register MTU changes") Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/ip_tunnel.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 6b0e362cc99b..38d906baf1df 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -328,7 +328,7 @@ static int ip_tunnel_bind_dev(struct net_device *dev)
328 328
329 if (tdev) { 329 if (tdev) {
330 hlen = tdev->hard_header_len + tdev->needed_headroom; 330 hlen = tdev->hard_header_len + tdev->needed_headroom;
331 mtu = tdev->mtu; 331 mtu = min(tdev->mtu, IP_MAX_MTU);
332 } 332 }
333 333
334 dev->needed_headroom = t_hlen + hlen; 334 dev->needed_headroom = t_hlen + hlen;
@@ -362,7 +362,7 @@ static struct ip_tunnel *ip_tunnel_create(struct net *net,
362 nt = netdev_priv(dev); 362 nt = netdev_priv(dev);
363 t_hlen = nt->hlen + sizeof(struct iphdr); 363 t_hlen = nt->hlen + sizeof(struct iphdr);
364 dev->min_mtu = ETH_MIN_MTU; 364 dev->min_mtu = ETH_MIN_MTU;
365 dev->max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen; 365 dev->max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen;
366 ip_tunnel_add(itn, nt); 366 ip_tunnel_add(itn, nt);
367 return nt; 367 return nt;
368 368
@@ -930,7 +930,7 @@ int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict)
930{ 930{
931 struct ip_tunnel *tunnel = netdev_priv(dev); 931 struct ip_tunnel *tunnel = netdev_priv(dev);
932 int t_hlen = tunnel->hlen + sizeof(struct iphdr); 932 int t_hlen = tunnel->hlen + sizeof(struct iphdr);
933 int max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen; 933 int max_mtu = IP_MAX_MTU - dev->hard_header_len - t_hlen;
934 934
935 if (new_mtu < ETH_MIN_MTU) 935 if (new_mtu < ETH_MIN_MTU)
936 return -EINVAL; 936 return -EINVAL;
@@ -1107,7 +1107,7 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
1107 1107
1108 mtu = ip_tunnel_bind_dev(dev); 1108 mtu = ip_tunnel_bind_dev(dev);
1109 if (tb[IFLA_MTU]) { 1109 if (tb[IFLA_MTU]) {
1110 unsigned int max = 0xfff8 - dev->hard_header_len - nt->hlen; 1110 unsigned int max = IP_MAX_MTU - dev->hard_header_len - nt->hlen;
1111 1111
1112 mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU, 1112 mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU,
1113 (unsigned int)(max - sizeof(struct iphdr))); 1113 (unsigned int)(max - sizeof(struct iphdr)));