iproute2: improved error messages
This patch improves many error messages as follows:
- For incorrect parameters, show the value of the offending parameter, rather than just say that it is incorrect
- Rephrased messages for clarity
- Rephrased to more `mainstream' english
Signed-off-by: Kees van Reeuwijk <reeuwijk@few.vu.nl>
diff --git a/ip/iptunnel.c b/ip/iptunnel.c
index f8b91ba..4275f26 100644
--- a/ip/iptunnel.c
+++ b/ip/iptunnel.c
@@ -102,7 +102,7 @@
p->iph.protocol = IPPROTO_IPIP;
p->i_flags |= VTI_ISVTI;
} else {
- fprintf(stderr,"Cannot guess tunnel mode.\n");
+ fprintf(stderr,"Unknown tunnel mode \"%s\"\n", *argv);
exit(-1);
}
} else if (strcmp(*argv, "key") == 0) {
@@ -114,7 +114,7 @@
p->i_key = p->o_key = get_addr32(*argv);
else {
if (get_unsigned(&uval, *argv, 0)<0) {
- fprintf(stderr, "invalid value of \"key\"\n");
+ fprintf(stderr, "invalid value for \"key\": \"%s\"; it should be an unsigned integer\n", *argv);
exit(-1);
}
p->i_key = p->o_key = htonl(uval);
@@ -127,7 +127,7 @@
p->i_key = get_addr32(*argv);
else {
if (get_unsigned(&uval, *argv, 0)<0) {
- fprintf(stderr, "invalid value of \"ikey\"\n");
+ fprintf(stderr, "invalid value for \"ikey\": \"%s\"; it should be an unsigned integer\n", *argv);
exit(-1);
}
p->i_key = htonl(uval);
@@ -140,7 +140,7 @@
p->o_key = get_addr32(*argv);
else {
if (get_unsigned(&uval, *argv, 0)<0) {
- fprintf(stderr, "invalid value of \"okey\"\n");
+ fprintf(stderr, "invalid value for \"okey\": \"%s\"; it should be an unsigned integer\n", *argv);
exit(-1);
}
p->o_key = htonl(uval);
@@ -242,7 +242,7 @@
if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
- fprintf(stderr, "Keys are not allowed with ipip and sit.\n");
+ fprintf(stderr, "Keys are not allowed with ipip and sit tunnels\n");
return -1;
}
}
@@ -262,7 +262,7 @@
p->o_flags |= GRE_KEY;
}
if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) {
- fprintf(stderr, "Broadcast tunnel requires a source address.\n");
+ fprintf(stderr, "A broadcast tunnel requires a source address\n");
return -1;
}
if (isatap)
@@ -444,7 +444,7 @@
buf[sizeof(buf) - 1] = 0;
if ((ptr = strchr(buf, ':')) == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
- fprintf(stderr, "Wrong format of /proc/net/dev. Sorry.\n");
+ fprintf(stderr, "Wrong format for /proc/net/dev. Giving up.\n");
fclose(fp);
return -1;
}
@@ -461,7 +461,7 @@
continue;
type = ll_index_to_type(index);
if (type == -1) {
- fprintf(stderr, "Failed to get type of [%s]\n", name);
+ fprintf(stderr, "Failed to get type of \"%s\"\n", name);
continue;
}
if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT)
@@ -558,17 +558,17 @@
strncpy(medium, *argv, IFNAMSIZ-1);
devname++;
} else {
- fprintf(stderr,"%s: Invalid PRL parameter.\n", *argv);
+ fprintf(stderr,"Invalid PRL parameter \"%s\"\n", *argv);
exit(-1);
}
if (count > 1) {
- fprintf(stderr,"One PRL entry at a time.\n");
+ fprintf(stderr,"One PRL entry at a time\n");
exit(-1);
}
argc--; argv++;
}
if (devname == 0) {
- fprintf(stderr, "Must specify dev.\n");
+ fprintf(stderr, "Must specify device\n");
exit(-1);
}
@@ -608,13 +608,13 @@
strncpy(medium, *argv, IFNAMSIZ-1);
devname++;
} else {
- fprintf(stderr,"%s: Invalid 6RD parameter.\n", *argv);
+ fprintf(stderr,"Invalid 6RD parameter \"%s\"\n", *argv);
exit(-1);
}
argc--; argv++;
}
if (devname == 0) {
- fprintf(stderr, "Must specify dev.\n");
+ fprintf(stderr, "Must specify device\n");
exit(-1);
}
@@ -637,7 +637,7 @@
case AF_INET6:
return do_ip6tunnel(argc, argv);
default:
- fprintf(stderr, "Unsupported family:%d\n", preferred_family);
+ fprintf(stderr, "Unsupported protocol family: %d\n", preferred_family);
exit(-1);
}
@@ -661,6 +661,6 @@
} else
return do_show(0, NULL);
- fprintf(stderr, "Command \"%s\" is unknown, try \"ip tunnel help\".\n", *argv);
+ fprintf(stderr, "Command \"%s\" is unknown, try \"ip tunnel help\"\n", *argv);
exit(-1);
}