From: Benedikt Gollatz <ben@differentialschokolade.org>
To: netdev@vger.kernel.org
Subject: Minor bug in "ip addr" output
Date: Wed, 10 Dec 2008 00:33:28 +0100 [thread overview]
Message-ID: <200812100033.28850.ben@differentialschokolade.org> (raw)
There is a minor problem in iproute2 regarding the output of "ip -6 addr".
Preferred lifetimes of IPv6 prefixes are printed as unsigned integers even
though they may become negative (for deprecated prefixes).
As I've argued in <http://bugzilla.kernel.org/show_bug.cgi?id=10880>, I think
this is partly because of an inconsistency in the kernel APIs, but since
nobody seemed interested, I guess it has to be dealt with by application
developers.
The following patch fixes the problem.
--- a/ip/ipaddress.c 2008-07-25 22:46:07.000000000 +0200
+++ b/ip/ipaddress.c 2008-12-08 03:29:27.000000000 +0100
@@ -360,4 +360,5 @@
struct ifaddrmsg *ifa = NLMSG_DATA(n);
int len = n->nlmsg_len;
+ int deprecated = 0;
struct rtattr * rta_tb[IFA_MAX+1];
char abuf[256];
@@ -489,4 +490,5 @@
if (ifa->ifa_flags&IFA_F_DEPRECATED) {
ifa->ifa_flags &= ~IFA_F_DEPRECATED;
+ deprecated = 1;
fprintf(fp, "deprecated ");
}
@@ -517,7 +519,12 @@
if (ci->ifa_prefered == INFINITY_LIFE_TIME)
sprintf(buf+strlen(buf), " preferred_lft forever");
- else
- sprintf(buf+strlen(buf), " preferred_lft %usec",
- ci->ifa_prefered);
+ else {
+ if (deprecated)
+ sprintf(buf+strlen(buf), " preferred_lft %dsec",
+ ci->ifa_prefered);
+ else
+ sprintf(buf+strlen(buf), " preferred_lft %usec",
+ ci->ifa_prefered);
+ }
fprintf(fp, " %s", buf);
}
reply other threads:[~2008-12-10 0:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200812100033.28850.ben@differentialschokolade.org \
--to=ben@differentialschokolade.org \
--cc=netdev@vger.kernel.org \
/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).