aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2018-03-15 12:16:28 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2018-03-19 03:45:50 -0400
commit24fc79798b8ddfd46f2dd363a8d29072c083b977 (patch)
tree8c037f94e733a5a9d1f312c59b7c2c0a1697ac39
parentdd1df24737727e119c263acf1be2a92763938297 (diff)
ip_tunnel: Clamp MTU to bounds on new link
Otherwise, it's possible to specify invalid MTU values directly on creation of a link (via 'ip link add'). This is already prevented on subsequent MTU changes by commit b96f9afee4eb ("ipv4/6: use core net MTU range checking"). Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.") Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Acked-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
-rw-r--r--net/ipv4/ip_tunnel.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 6d21068f9b55..7c76dd17b6b9 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -1108,8 +1108,14 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
1108 eth_hw_addr_random(dev); 1108 eth_hw_addr_random(dev);
1109 1109
1110 mtu = ip_tunnel_bind_dev(dev); 1110 mtu = ip_tunnel_bind_dev(dev);
1111 if (!tb[IFLA_MTU]) 1111 if (tb[IFLA_MTU]) {
1112 unsigned int max = 0xfff8 - dev->hard_header_len - nt->hlen;
1113
1114 dev->mtu = clamp(dev->mtu, (unsigned int)ETH_MIN_MTU,
1115 (unsigned int)(max - sizeof(struct iphdr)));
1116 } else {
1112 dev->mtu = mtu; 1117 dev->mtu = mtu;
1118 }
1113 1119
1114 ip_tunnel_add(itn, nt); 1120 ip_tunnel_add(itn, nt);
1115out: 1121out: