aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2012-10-09 16:35:53 -0400
committerDavid S. Miller <davem@davemloft.net>2012-10-10 22:41:22 -0400
commit34e02aa1fb0886d8e92ab00e3dc17d631487f92d (patch)
tree9cfd4f0f53c5b5aa6b3f1364f8549c1c88311303 /drivers/net
parentd97c00a32198f0d066556006cfcd409efb28f746 (diff)
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: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/vxlan.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 763061d97921..607976c00162 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1090,14 +1090,18 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
1090 if (data[IFLA_VXLAN_LOCAL]) 1090 if (data[IFLA_VXLAN_LOCAL])
1091 vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]); 1091 vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]);
1092 1092
1093 if (data[IFLA_VXLAN_LINK]) { 1093 if (data[IFLA_VXLAN_LINK] &&
1094 vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]); 1094 (vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]))) {
1095 struct net_device *lowerdev
1096 = __dev_get_by_index(net, vxlan->link);
1097
1098 if (!lowerdev) {
1099 pr_info("ifindex %d does not exist\n", vxlan->link);
1100 return -ENODEV;
1101 }
1095 1102
1096 if (!tb[IFLA_MTU]) { 1103 if (!tb[IFLA_MTU])
1097 struct net_device *lowerdev;
1098 lowerdev = __dev_get_by_index(net, vxlan->link);
1099 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM; 1104 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
1100 }
1101 } 1105 }
1102 1106
1103 if (data[IFLA_VXLAN_TOS]) 1107 if (data[IFLA_VXLAN_TOS])