mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	ip6_gre: init dev->mtu and dev->hard_header_len correctly
Commitb05229f442("gre6: Cleanup GREv6 transmit path, call common GRE functions") moved dev->mtu initialization from ip6gre_tunnel_setup() to ip6gre_tunnel_init(), as a result, the previously set values, before ndo_init(), are reset in the following cases: * rtnl_create_link() can update dev->mtu from IFLA_MTU parameter. * ip6gre_tnl_link_config() is invoked before ndo_init() in netlink and ioctl setup, so ndo_init() can reset MTU adjustments with the lower device MTU as well, dev->mtu and dev->hard_header_len. Not applicable for ip6gretap because it has one more call to ip6gre_tnl_link_config(tunnel, 1) in ip6gre_tap_init(). Fix the first case by updating dev->mtu with 'tb[IFLA_MTU]' parameter if a user sets it manually on a device creation, and fix the second one by moving ip6gre_tnl_link_config() call after register_netdevice(). Fixes:b05229f442("gre6: Cleanup GREv6 transmit path, call common GRE functions") Fixes:db2ec95d1b("ip6_gre: Fix MTU setting") Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									ed604c5da3
								
							
						
					
					
						commit
						128bb975dc
					
				
					 1 changed files with 7 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -337,11 +337,12 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
 | 
			
		|||
 | 
			
		||||
	nt->dev = dev;
 | 
			
		||||
	nt->net = dev_net(dev);
 | 
			
		||||
	ip6gre_tnl_link_config(nt, 1);
 | 
			
		||||
 | 
			
		||||
	if (register_netdevice(dev) < 0)
 | 
			
		||||
		goto failed_free;
 | 
			
		||||
 | 
			
		||||
	ip6gre_tnl_link_config(nt, 1);
 | 
			
		||||
 | 
			
		||||
	/* Can use a lockless transmit, unless we generate output sequences */
 | 
			
		||||
	if (!(nt->parms.o_flags & TUNNEL_SEQ))
 | 
			
		||||
		dev->features |= NETIF_F_LLTX;
 | 
			
		||||
| 
						 | 
				
			
			@ -1303,7 +1304,6 @@ static void ip6gre_netlink_parms(struct nlattr *data[],
 | 
			
		|||
 | 
			
		||||
static int ip6gre_tap_init(struct net_device *dev)
 | 
			
		||||
{
 | 
			
		||||
	struct ip6_tnl *tunnel;
 | 
			
		||||
	int ret;
 | 
			
		||||
 | 
			
		||||
	ret = ip6gre_tunnel_init_common(dev);
 | 
			
		||||
| 
						 | 
				
			
			@ -1312,10 +1312,6 @@ static int ip6gre_tap_init(struct net_device *dev)
 | 
			
		|||
 | 
			
		||||
	dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
 | 
			
		||||
 | 
			
		||||
	tunnel = netdev_priv(dev);
 | 
			
		||||
 | 
			
		||||
	ip6gre_tnl_link_config(tunnel, 1);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1408,12 +1404,16 @@ static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
 | 
			
		|||
 | 
			
		||||
	nt->dev = dev;
 | 
			
		||||
	nt->net = dev_net(dev);
 | 
			
		||||
	ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
 | 
			
		||||
 | 
			
		||||
	err = register_netdevice(dev);
 | 
			
		||||
	if (err)
 | 
			
		||||
		goto out;
 | 
			
		||||
 | 
			
		||||
	ip6gre_tnl_link_config(nt, !tb[IFLA_MTU]);
 | 
			
		||||
 | 
			
		||||
	if (tb[IFLA_MTU])
 | 
			
		||||
		ip6_tnl_change_mtu(dev, nla_get_u32(tb[IFLA_MTU]));
 | 
			
		||||
 | 
			
		||||
	dev_hold(dev);
 | 
			
		||||
	ip6gre_tunnel_link(ign, nt);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue