From: Stephen Hemminger <shemminger@vyatta.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCHv2 8/8] vxlan: fix oops when give unknown ifindex
Date: Tue, 09 Oct 2012 23:35:53 -0700 [thread overview]
Message-ID: <20121010063623.935671507@vyatta.com> (raw)
In-Reply-To: 20121010063545.453368147@vyatta.com
[-- Attachment #1: vxlan-baddev.patch --]
[-- Type: text/plain, Size: 1163 bytes --]
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>
--- a/drivers/net/vxlan.c 2012-10-09 22:07:41.417308505 -0700
+++ b/drivers/net/vxlan.c 2012-10-09 22:09:56.715949703 -0700
@@ -1090,14 +1090,18 @@ static int vxlan_newlink(struct net *net
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 (!tb[IFLA_MTU]) {
- struct net_device *lowerdev;
- lowerdev = __dev_get_by_index(net, vxlan->link);
- dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
+ if (!lowerdev) {
+ pr_info("ifindex %d does not exist\n", vxlan->link);
+ return -ENODEV;
}
+
+ if (!tb[IFLA_MTU])
+ dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
}
if (data[IFLA_VXLAN_TOS])
next prev parent reply other threads:[~2012-10-10 6:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-10 6:35 [PATCHv2 0/8] vxlan: bug fixes Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 1/8] vxlan: minor output refactoring Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 2/8] vxlan: fix byte order in hash function Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 3/8] vxlan: use ip_route_output Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 4/8] vxlan: associate with tunnel socket on transmit Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 5/8] vxlan: allow configuring port range Stephen Hemminger
2012-10-10 6:41 ` [PATCH] iproute2: allow configuring vxlan " Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 6/8] vxlan: add additional headroom Stephen Hemminger
2012-10-10 6:35 ` [PATCHv2 7/8] vxlan: fix receive checksum handling Stephen Hemminger
2012-10-10 6:35 ` Stephen Hemminger [this message]
2012-10-11 2:42 ` [PATCHv2 0/8] vxlan: bug fixes David Miller
2012-10-11 14:59 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121010063623.935671507@vyatta.com \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).