aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2015-12-02 13:50:22 +0100
committerStephen Hemminger <shemming@brocade.com>2015-12-10 08:45:11 -0800
commit0f7543322c5fd64d70672578979cf74226f54b64 (patch)
treeb792606a9a36bb5b94dfa17278784b0804c4b514
parenta96a5d94c6bd58cb455c66a38cff6077841e7aab (diff)
downloadandroid_external_iproute2-0f7543322c5fd64d70672578979cf74226f54b64.tar.gz
android_external_iproute2-0f7543322c5fd64d70672578979cf74226f54b64.tar.bz2
android_external_iproute2-0f7543322c5fd64d70672578979cf74226f54b64.zip
route: ignore RTAX_HOPLIMIT of value -1
Older kernels use -1 internally as indicator to use the sysctl default, but they still export the setting. Newer kernels use 0 to indicate that (which is why the conversion from -1 to 0 was done here), but they also stopped exporting the value. Since the meaning of -1 is clear, treat it equally like default on newer kernels (which is to not print anything). Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--ip/iproute.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/ip/iproute.c b/ip/iproute.c
index aed1038..c42ea0b 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -577,24 +577,23 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (mxrta[i] == NULL)
continue;
- if (i < sizeof(mx_names)/sizeof(char*) && mx_names[i])
- fprintf(fp, " %s", mx_names[i]);
- else
- fprintf(fp, " metric %d", i);
-
if (mxlock & (1<<i))
fprintf(fp, " lock");
if (i != RTAX_CC_ALGO)
val = rta_getattr_u32(mxrta[i]);
+ if (i == RTAX_HOPLIMIT && (int)val == -1)
+ continue;
+
+ if (i < sizeof(mx_names)/sizeof(char*) && mx_names[i])
+ fprintf(fp, " %s", mx_names[i]);
+ else
+ fprintf(fp, " metric %d", i);
+
switch (i) {
case RTAX_FEATURES:
print_rtax_features(fp, val);
break;
- case RTAX_HOPLIMIT:
- if ((int)val == -1)
- val = 0;
- /* fall through */
default:
fprintf(fp, " %u", val);
break;