* [Patch iproute2] iplink: forbid negative ifindex and modifying ifindex
@ 2014-09-05 23:36 Cong Wang
2014-09-28 23:04 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2014-09-05 23:36 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Stephen Hemminger
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
ip/iplink.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index ea06871..a8a19dd 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -400,6 +400,8 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
} else if (strcmp(*argv, "index") == 0) {
NEXT_ARG();
*index = atoi(*argv);
+ if (*index < 0)
+ invarg("Invalid \"index\" value", *argv);
} else if (matches(*argv, "link") == 0) {
NEXT_ARG();
*link = *argv;
@@ -607,7 +609,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
char *name = NULL;
char *link = NULL;
char *type = NULL;
- int index = 0;
+ int index = -1;
int group;
struct link_util *lu = NULL;
struct iplink_req req;
@@ -658,6 +660,11 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
"argument is required.\n");
exit(-1);
}
+ if (cmd == RTM_NEWLINK && index != -1) {
+ fprintf(stderr, "index can be used only when "
+ "creating devices.\n");
+ exit(-1);
+ }
req.i.ifi_index = ll_name_to_index(dev);
if (req.i.ifi_index == 0) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch iproute2] iplink: forbid negative ifindex and modifying ifindex
2014-09-05 23:36 [Patch iproute2] iplink: forbid negative ifindex and modifying ifindex Cong Wang
@ 2014-09-28 23:04 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2014-09-28 23:04 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev
On Fri, 5 Sep 2014 16:36:14 -0700
Cong Wang <xiyou.wangcong@gmail.com> wrote:
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Applied
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-28 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-05 23:36 [Patch iproute2] iplink: forbid negative ifindex and modifying ifindex Cong Wang
2014-09-28 23:04 ` Stephen Hemminger
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).