ip6_tunnel: remove magic mtu value 0xFFF8
authorNicolas Dichtel <nicolas.dichtel@6wind.com>
Thu, 31 May 2018 08:59:33 +0000 (10:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jun 2018 17:56:30 +0000 (13:56 -0400)
I don't know where this value comes from (probably a copy and paste and
paste and paste ...).
Let's use standard values which are a bit greater.

Link: https://git.kernel.org/pub/scm/linux/kernel/git/davem/netdev-vger-cvs.git/commit/?id=e5afd356a411a
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_tunnel.c
net/ipv6/sit.c

index da66aaac51cecbf933827c8842e61a8cbb4d274f..00e138a44cbba2e7c03cb003f5823b42e18a923a 100644 (file)
@@ -1692,8 +1692,13 @@ int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
                if (new_mtu < ETH_MIN_MTU)
                        return -EINVAL;
        }
-       if (new_mtu > 0xFFF8 - dev->hard_header_len)
-               return -EINVAL;
+       if (tnl->parms.proto == IPPROTO_IPV6 || tnl->parms.proto == 0) {
+               if (new_mtu > IP6_MAX_MTU - dev->hard_header_len)
+                       return -EINVAL;
+       } else {
+               if (new_mtu > IP_MAX_MTU - dev->hard_header_len)
+                       return -EINVAL;
+       }
        dev->mtu = new_mtu;
        return 0;
 }
@@ -1841,7 +1846,7 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
        if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
                dev->mtu -= 8;
        dev->min_mtu = ETH_MIN_MTU;
-       dev->max_mtu = 0xFFF8 - dev->hard_header_len;
+       dev->max_mtu = IP6_MAX_MTU - dev->hard_header_len;
 
        return 0;
 
index 2afce37a71776f5ebd44d20e2d064909cb91f8dd..e9400ffa7875c7a81d139618dae53143d164a1e1 100644 (file)
@@ -1371,7 +1371,7 @@ static void ipip6_tunnel_setup(struct net_device *dev)
        dev->hard_header_len    = LL_MAX_HEADER + t_hlen;
        dev->mtu                = ETH_DATA_LEN - t_hlen;
        dev->min_mtu            = IPV6_MIN_MTU;
-       dev->max_mtu            = 0xFFF8 - t_hlen;
+       dev->max_mtu            = IP6_MAX_MTU - t_hlen;
        dev->flags              = IFF_NOARP;
        netif_keep_dst(dev);
        dev->addr_len           = 4;
@@ -1583,7 +1583,8 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
        if (tb[IFLA_MTU]) {
                u32 mtu = nla_get_u32(tb[IFLA_MTU]);
 
-               if (mtu >= IPV6_MIN_MTU && mtu <= 0xFFF8 - dev->hard_header_len)
+               if (mtu >= IPV6_MIN_MTU &&
+                   mtu <= IP6_MAX_MTU - dev->hard_header_len)
                        dev->mtu = mtu;
        }