netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Stephen Hemminger <shemming@brocade.com>
Cc: netdev@vger.kernel.org
Subject: [iproute PATCH] route: ignore RTAX_HOPLIMIT of value -1
Date: Wed,  2 Dec 2015 13:50:22 +0100	[thread overview]
Message-ID: <1449060622-22898-1-git-send-email-phil@nwl.cc> (raw)

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>
---
 ip/iproute.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index aed1038e515b6..c42ea0b9ecb8e 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;
-- 
2.5.0

             reply	other threads:[~2015-12-02 12:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 12:50 Phil Sutter [this message]
     [not found] <564c2ede04884ee5905825d6363107a2@HQ1WP-EXMB11.corp.brocade.com>
2015-12-10 16:48 ` [iproute PATCH] route: ignore RTAX_HOPLIMIT of value -1 Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449060622-22898-1-git-send-email-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netdev@vger.kernel.org \
    --cc=shemming@brocade.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).