Skip to content

Commit

Permalink
Merge branch 'tunnel-mtu-fixes'
Browse files Browse the repository at this point in the history
Xin Long says:

====================
net: fix IFLA_MTU ignored on NEWLINK for some ip and ipv6 tunnels

The fix for ip_gre follows the way other ip tunnels do: not to
set mtu in ndo_init, as ip_tunnel_newlink will take care of it
properly.

The fix for ip6_tunnel and sit follows the way ipv6 tunenls do:
to set mtu again according to IFLA_MTU after, as all bind_dev
are called in ndo_init where it can't get the tb[IFLA_MTU].
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Feb 27, 2018
2 parents 9c2c2e6 + 2b3957c commit ff2926d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 0 additions & 5 deletions net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,6 @@ static void __gre_tunnel_init(struct net_device *dev)

t_hlen = tunnel->hlen + sizeof(struct iphdr);

dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
dev->mtu = ETH_DATA_LEN - t_hlen - 4;

dev->features |= GRE_FEATURES;
dev->hw_features |= GRE_FEATURES;

Expand Down Expand Up @@ -1290,8 +1287,6 @@ static int erspan_tunnel_init(struct net_device *dev)
erspan_hdr_len(tunnel->erspan_ver);
t_hlen = tunnel->hlen + sizeof(struct iphdr);

dev->needed_headroom = LL_MAX_HEADER + t_hlen + 4;
dev->mtu = ETH_DATA_LEN - t_hlen - 4;
dev->features |= GRE_FEATURES;
dev->hw_features |= GRE_FEATURES;
dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
Expand Down
12 changes: 8 additions & 4 deletions net/ipv6/ip6_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1982,14 +1982,14 @@ static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
{
struct net *net = dev_net(dev);
struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
struct ip6_tnl *nt, *t;
struct ip_tunnel_encap ipencap;
struct ip6_tnl *nt, *t;
int err;

nt = netdev_priv(dev);

if (ip6_tnl_netlink_encap_parms(data, &ipencap)) {
int err = ip6_tnl_encap_setup(nt, &ipencap);

err = ip6_tnl_encap_setup(nt, &ipencap);
if (err < 0)
return err;
}
Expand All @@ -2005,7 +2005,11 @@ static int ip6_tnl_newlink(struct net *src_net, struct net_device *dev,
return -EEXIST;
}

return ip6_tnl_create2(dev);
err = ip6_tnl_create2(dev);
if (!err && tb[IFLA_MTU])
ip6_tnl_change_mtu(dev, nla_get_u32(tb[IFLA_MTU]));

return err;
}

static int ip6_tnl_changelink(struct net_device *dev, struct nlattr *tb[],
Expand Down
7 changes: 7 additions & 0 deletions net/ipv6/sit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,13 @@ static int ipip6_newlink(struct net *src_net, struct net_device *dev,
if (err < 0)
return err;

if (tb[IFLA_MTU]) {
u32 mtu = nla_get_u32(tb[IFLA_MTU]);

if (mtu >= IPV6_MIN_MTU && mtu <= 0xFFF8 - dev->hard_header_len)
dev->mtu = mtu;
}

#ifdef CONFIG_IPV6_SIT_6RD
if (ipip6_netlink_6rd_parms(data, &ip6rd))
err = ipip6_tunnel_update_6rd(nt, &ip6rd);
Expand Down

0 comments on commit ff2926d

Please sign in to comment.