Commit 0cb6bb51 authored by Cong Wang's avatar Cong Wang Committed by Stephen Hemminger

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 <stephen@networkplumber.org>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
parent eb6028b2
......@@ -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;
......
......@@ -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))) {
......
......@@ -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;
......
......@@ -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;
......
......@@ -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++;
......
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