[PATCH linux-next] net: ip_tunnel: Call dev_set_mtu to set clamped MTU

From: Petr Machata
Date: Tue Mar 27 2018 - 09:00:38 EST


When adding a new IP tunnel link, MTU is clamped to sane bounds.
However, since the new MTU value is directly assigned to the netdevice,
instead of going through dev_set_mtu, the change is done without sending
the usual NETDEV_PRECHANGEMTU and NETDEV_CHANGEMTU events. Thus drivers
don't get to learn about the clamped MTU value.

Signed-off-by: Petr Machata <petrm@xxxxxxxxxxxx>
---
net/ipv4/ip_tunnel.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index a57cf0d..de6d944 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -1108,14 +1108,14 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
if (tb[IFLA_MTU]) {
unsigned int max = 0xfff8 - dev->hard_header_len - nt->hlen;

- dev->mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU,
- (unsigned int)(max - sizeof(struct iphdr)));
- } else {
- err = dev_set_mtu(dev, mtu);
- if (err)
- goto err_dev_set_mtu;
+ mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU,
+ (unsigned int)(max - sizeof(struct iphdr)));
}

+ err = dev_set_mtu(dev, mtu);
+ if (err)
+ goto err_dev_set_mtu;
+
ip_tunnel_add(itn, nt);
return 0;

--
2.4.11