@@ -229,16 +229,12 @@ get_failed:
exit(-1);
}
} else if (!matches(*argv, "ttl") ||
- !matches(*argv, "hoplimit")) {
- unsigned int uval;
-
+ !matches(*argv, "hoplimit") ||
+ !matches(*argv, "hlim")) {
NEXT_ARG();
if (strcmp(*argv, "inherit") != 0) {
- if (get_unsigned(&uval, *argv, 0))
+ if (get_u8(&ttl, *argv, 0))
invarg("invalid TTL\n", *argv);
- if (uval > 255)
- invarg("TTL must be <= 255\n", *argv);
- ttl = uval;
} else
ttl = 0;
} else if (!matches(*argv, "tos") ||
@@ -238,13 +238,14 @@ get_failed:
exit(-1);
}
} else if (!matches(*argv, "ttl") ||
- !matches(*argv, "hoplimit")) {
- __u8 uval;
-
+ !matches(*argv, "hoplimit") ||
+ !matches(*argv, "hlim")) {
NEXT_ARG();
- if (get_u8(&uval, *argv, 0))
- invarg("invalid TTL", *argv);
- hop_limit = uval;
+ if (strcmp(*argv, "inherit") != 0) {
+ if (get_u8(&hop_limit, *argv, 0))
+ invarg("invalid HLIM\n", *argv);
+ } else
+ hop_limit = 0;
} else if (!matches(*argv, "tos") ||
!matches(*argv, "tclass") ||
!matches(*argv, "dsfield")) {
@@ -196,15 +196,15 @@ get_failed:
link = if_nametoindex(*argv);
if (link == 0)
invarg("\"dev\" is invalid", *argv);
- } else if (strcmp(*argv, "hoplimit") == 0 ||
- strcmp(*argv, "ttl") == 0 ||
+ } else if (strcmp(*argv, "ttl") == 0 ||
+ strcmp(*argv, "hoplimit") == 0 ||
strcmp(*argv, "hlim") == 0) {
- __u8 uval;
-
NEXT_ARG();
- if (get_u8(&uval, *argv, 0))
- invarg("invalid HLIM", *argv);
- hop_limit = uval;
+ if (strcmp(*argv, "inherit") != 0) {
+ if (get_u8(&hop_limit, *argv, 0))
+ invarg("invalid HLIM\n", *argv);
+ } else
+ hop_limit = 0;
} else if (strcmp(*argv, "encaplimit") == 0) {
NEXT_ARG();
if (strcmp(*argv, "none") == 0) {
@@ -204,7 +204,8 @@ get_failed:
if (link == 0)
invarg("\"dev\" is invalid", *argv);
} else if (strcmp(*argv, "ttl") == 0 ||
- strcmp(*argv, "hoplimit") == 0) {
+ strcmp(*argv, "hoplimit") == 0 ||
+ strcmp(*argv, "hlim") == 0) {
NEXT_ARG();
if (strcmp(*argv, "inherit") != 0) {
if (get_u8(&ttl, *argv, 0))
Handle "inherit" case properly for gre6 and ip6tnl. Use get_u8() in gre to parse ttl/hoplimit. Be consistent about "hlim" alias to ttl/hoplimit support. Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> --- ip/link_gre.c | 10 +++------- ip/link_gre6.c | 13 +++++++------ ip/link_ip6tnl.c | 14 +++++++------- ip/link_iptnl.c | 3 ++- 4 files changed, 19 insertions(+), 21 deletions(-)