lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 10 Aug 2016 13:14:50 +0200
From:	Phil Sutter <phil@....cc>
To:	Stephen Hemminger <shemming@...cade.com>
Cc:	netdev@...r.kernel.org
Subject: [iproute PATCH] ip-route: Pretty-print expired routes

Instead of printing 'expires -23sec' for expired (but not yet garbage
collected) routes, print 'expired 23sec' instead.

Signed-off-by: Phil Sutter <phil@....cc>
---
 ip/iproute.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index c52294d298210..a89a26d68be0f 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -305,6 +305,14 @@ static void print_rtax_features(FILE *fp, unsigned int features)
 		fprintf(fp, " 0x%x", of);
 }
 
+static void print_expires(FILE *fp, __s32 expires, int hz)
+{
+	if (expires > 0)
+		fprintf(fp, " expires %dsec", expires/hz);
+	else
+		fprintf(fp, " expired %dsec", -expires/hz);
+}
+
 int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 {
 	FILE *fp = (FILE *)arg;
@@ -502,7 +510,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 			if (!hz)
 				hz = get_user_hz();
 			if (ci->rta_expires != 0)
-				fprintf(fp, " expires %dsec", ci->rta_expires/hz);
+				print_expires(fp, ci->rta_expires, hz);
 			if (ci->rta_error != 0)
 				fprintf(fp, " error %d", ci->rta_error);
 			if (show_stats) {
@@ -530,7 +538,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 			if (r->rtm_flags & RTM_F_CLONED)
 				fprintf(fp, "%s    cache ", _SL_);
 			if (ci->rta_expires)
-				fprintf(fp, " expires %dsec", ci->rta_expires/hz);
+				print_expires(fp, ci->rta_expires, hz);
 			if (ci->rta_error != 0)
 				fprintf(fp, " error %d", ci->rta_error);
 			if (show_stats) {
-- 
2.8.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ