From 0cb6bb51b4eb9bd08e152342b95dcae13287dafd Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 3 Jun 2014 16:06:45 -0700 Subject: [PATCH] do not exit silently when link is not found When we create a tunnel on top of a link and the link specified in cmdline doesn't exist, an error message should be shown. Cc: Stephen Hemminger Signed-off-by: Cong Wang --- ip/iplink_vxlan.c | 5 ++++- ip/iptunnel.c | 5 ++++- ip/link_gre.c | 5 ++++- ip/link_gre6.c | 5 ++++- ip/link_vti.c | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c index b9a516e1e..53c50accd 100644 --- a/ip/iplink_vxlan.c +++ b/ip/iplink_vxlan.c @@ -99,8 +99,11 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, } else if (!matches(*argv, "dev")) { NEXT_ARG(); link = if_nametoindex(*argv); - if (link == 0) + if (link == 0) { + fprintf(stderr, "Cannot find device \"%s\"\n", + *argv); exit(-1); + } } else if (!matches(*argv, "ttl") || !matches(*argv, "hoplimit")) { unsigned uval; diff --git a/ip/iptunnel.c b/ip/iptunnel.c index 9ae8847dc..f96ce4582 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -250,8 +250,11 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) if (medium[0]) { p->link = if_nametoindex(medium); - if (p->link == 0) + if (p->link == 0) { + fprintf(stderr, "Cannot find device \"%s\"\n", + medium); return -1; + } } if (p->i_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) { diff --git a/ip/link_gre.c b/ip/link_gre.c index 17478868e..fda84d832 100644 --- a/ip/link_gre.c +++ b/ip/link_gre.c @@ -207,8 +207,11 @@ get_failed: } else if (!matches(*argv, "dev")) { NEXT_ARG(); link = if_nametoindex(*argv); - if (link == 0) + if (link == 0) { + fprintf(stderr, "Cannot find device \"%s\"\n", + *argv); exit(-1); + } } else if (!matches(*argv, "ttl") || !matches(*argv, "hoplimit")) { unsigned uval; diff --git a/ip/link_gre6.c b/ip/link_gre6.c index 4c9c53653..c7183e2fd 100644 --- a/ip/link_gre6.c +++ b/ip/link_gre6.c @@ -225,8 +225,11 @@ get_failed: } else if (!matches(*argv, "dev")) { NEXT_ARG(); link = if_nametoindex(*argv); - if (link == 0) + if (link == 0) { + fprintf(stderr, "Cannot find device \"%s\"\n", + *argv); exit(-1); + } } else if (!matches(*argv, "ttl") || !matches(*argv, "hoplimit")) { __u8 uval; diff --git a/ip/link_vti.c b/ip/link_vti.c index 77a7482cc..6274c836c 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -171,8 +171,11 @@ get_failed: } else if (!matches(*argv, "dev")) { NEXT_ARG(); link = if_nametoindex(*argv); - if (link == 0) + if (link == 0) { + fprintf(stderr, "Cannot find device \"%s\"\n", + *argv); exit(-1); + } } else usage(); argc--; argv++; -- 2.47.2