From e9c1b5f32fd39ee8a29035fd49e4aea8daa59cf3 Mon Sep 17 00:00:00 2001
From: Jakub Sitnicki <jkbs@redhat.com>
Date: Wed, 27 Jul 2016 15:56:15 +0200
Subject: [PATCH] ip: check for missing dev arg when doing VF rate
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1340914
Upstream Status: iproute2.git commit 9a02651
Conflicts:
* context in iplink_parse() because we already have
ccdcbf35f120 ("iplink: add support of IFLA_LINK_NETNSID attribute")
commit 9a02651a87d0fd56e2e7eedd63921a050a42b3ec
Author: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon Jul 14 12:08:05 2014 -0700
ip: check for missing dev arg when doing VF rate
New VF rate code was not handling case where device not specified.
Caught by GCC warning about uninitialized variable.
---
ip/iplink.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index bce5ba0..7ee015c 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -381,6 +381,7 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
if (new_rate_api) {
int tmin, tmax;
+
if (tivt.min_tx_rate == -1 || tivt.max_tx_rate == -1) {
ipaddr_get_vf_rate(tivt.vf, &tmin, &tmax, dev_index);
if (tivt.min_tx_rate == -1)
@@ -413,7 +414,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
int vf = -1;
int numtxqueues = -1;
int numrxqueues = -1;
- int dev_index;
+ int dev_index = 0;
int link_netnsid = -1;
*group = -1;
@@ -524,6 +525,9 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
}
vflist = addattr_nest(&req->n, sizeof(*req),
IFLA_VFINFO_LIST);
+ if (dev_index == 0)
+ missarg("dev");
+
len = iplink_parse_vf(vf, &argc, &argv, req, dev_index);
if (len < 0)
return -1;
@@ -627,6 +631,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
duparg2("dev", *argv);
*dev = *argv;
dev_index = ll_name_to_index(*dev);
+ if (dev_index == 0)
+ invarg("Unknown device", *argv);
}
argc--; argv++;
}
--
1.8.3.1