提交 34e02aa1 编写于 作者: S stephen hemminger 提交者: David S. Miller

vxlan: fix oops when give unknown ifindex

If vxlan is created and the ifindex is passed; there are two cases which
are incorrectly handled by the existing code. The ifindex could be zero
(i.e. no device) or there could be no device with that ifindex.
Signed-off-by: NStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d97c00a3
......@@ -1090,14 +1090,18 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
if (data[IFLA_VXLAN_LOCAL])
vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]);
if (data[IFLA_VXLAN_LINK]) {
vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]);
if (data[IFLA_VXLAN_LINK] &&
(vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]))) {
struct net_device *lowerdev
= __dev_get_by_index(net, vxlan->link);
if (!lowerdev) {
pr_info("ifindex %d does not exist\n", vxlan->link);
return -ENODEV;
}
if (!tb[IFLA_MTU]) {
struct net_device *lowerdev;
lowerdev = __dev_get_by_index(net, vxlan->link);
if (!tb[IFLA_MTU])
dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
}
}
if (data[IFLA_VXLAN_TOS])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册