Commit 51055be8 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[RTNETLINK]: ifindex 0 does not exist

ifindex == 0 does not exist and implies we should do a lookup by name if
one was given.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ef7c79ed
...@@ -580,7 +580,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -580,7 +580,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
err = -EINVAL; err = -EINVAL;
ifm = nlmsg_data(nlh); ifm = nlmsg_data(nlh);
if (ifm->ifi_index >= 0) if (ifm->ifi_index > 0)
dev = dev_get_by_index(ifm->ifi_index); dev = dev_get_by_index(ifm->ifi_index);
else if (tb[IFLA_IFNAME]) else if (tb[IFLA_IFNAME])
dev = dev_get_by_name(ifname); dev = dev_get_by_name(ifname);
...@@ -672,7 +672,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -672,7 +672,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
* name provided implies that a name change has been * name provided implies that a name change has been
* requested. * requested.
*/ */
if (ifm->ifi_index >= 0 && ifname[0]) { if (ifm->ifi_index > 0 && ifname[0]) {
err = dev_change_name(dev, ifname); err = dev_change_name(dev, ifname);
if (err < 0) if (err < 0)
goto errout_dev; goto errout_dev;
...@@ -740,7 +740,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) ...@@ -740,7 +740,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
return err; return err;
ifm = nlmsg_data(nlh); ifm = nlmsg_data(nlh);
if (ifm->ifi_index >= 0) { if (ifm->ifi_index > 0) {
dev = dev_get_by_index(ifm->ifi_index); dev = dev_get_by_index(ifm->ifi_index);
if (dev == NULL) if (dev == NULL)
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment