]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
When the preferred lifetime of a prefix assigned by IPv6 autoconfiguration
authorBenedikt Gollatz <ben@differentialschokolade.org>
Wed, 7 Jan 2009 03:36:56 +0000 (19:36 -0800)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Wed, 7 Jan 2009 03:36:56 +0000 (19:36 -0800)
(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
<if> connected to a link where that router advertises.
3. Run ip -6 show dev <if>.

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

index 51471e86d3006eddc0a509d892a51bc2a44ef0ac..a732d80cdc59c95eedf9a7ae01c070a94ccbf30f 100644 (file)
@@ -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");