aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vxlan.c
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2012-10-09 20:35:53 +0000
committerDavid S. Miller <davem@davemloft.net>2012-10-10 22:41:22 -0400
commit34e02aa1fb0886d8e92ab00e3dc17d631487f92d (patch)
tree9cfd4f0f53c5b5aa6b3f1364f8549c1c88311303 /drivers/net/vxlan.c
parentvxlan: fix receive checksum handling (diff)
downloadlinux-dev-34e02aa1fb0886d8e92ab00e3dc17d631487f92d.tar.xz
linux-dev-34e02aa1fb0886d8e92ab00e3dc17d631487f92d.zip
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/vxlan.c')
-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,
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])