From 037d950bceed6d5053758dea601e0d018f5f22d7 Mon Sep 17 00:00:00 2001 From: Benedikt Gollatz Date: Tue, 6 Jan 2009 19:36:56 -0800 Subject: [PATCH] When the preferred lifetime of a prefix assigned by IPv6 autoconfiguration (router solicitation) becomes negative How reproducible: Always. Steps to Reproduce: 1. Configure an IPv6 router to advertise a prefix with a short preferred lifetime, e.g. 0. 2. Wait for the IPv6 autoconfiguration process to complete for an interface connected to a link where that router advertises. 3. Run ip -6 show dev . Actual results: The preferred lifetime will have become negative, but it is printed as an unsigned integer. The preferred lifetime to be displayed will therefore be close to UINT_MAX. --- ip/ipaddress.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 51471e86d..a732d80cd 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -359,6 +359,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, FILE *fp = (FILE*)arg; struct ifaddrmsg *ifa = NLMSG_DATA(n); int len = n->nlmsg_len; + int deprecated = 0; struct rtattr * rta_tb[IFA_MAX+1]; char abuf[256]; SPRINT_BUF(b1); @@ -488,6 +489,7 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, } if (ifa->ifa_flags&IFA_F_DEPRECATED) { ifa->ifa_flags &= ~IFA_F_DEPRECATED; + deprecated = 1; fprintf(fp, "deprecated "); } if (ifa->ifa_flags&IFA_F_HOMEADDRESS) { @@ -516,9 +518,14 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n, sprintf(buf, "valid_lft %usec", ci->ifa_valid); 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); } fprintf(fp, "\n"); -- 2.47.2