提交 24fc7979 编写于 作者: S Stefano Brivio 提交者: Steffen Klassert

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 b96f9afe
("ipv4/6: use core net MTU range checking").

Fixes: c5441932 ("GRE: Refactor GRE tunneling code.")
Signed-off-by: NStefano Brivio <sbrivio@redhat.com>
Acked-by: NSabrina Dubroca <sd@queasysnail.net>
Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
上级 dd1df247
...@@ -1108,8 +1108,14 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], ...@@ -1108,8 +1108,14 @@ int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
mtu = ip_tunnel_bind_dev(dev); mtu = ip_tunnel_bind_dev(dev);
if (!tb[IFLA_MTU]) 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 {
dev->mtu = mtu; dev->mtu = mtu;
}
ip_tunnel_add(itn, nt); ip_tunnel_add(itn, nt);
out: out:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册