From: YOSHIFUJI Hideaki / 吉藤英明 Date: Fri, 21 Dec 2007 13:58:04 +0000 (+0900) Subject: rto_min value display overflow X-Git-Tag: v2.6.24-rc6~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c73e1bd21bc54b20b2d4ad0fc1a94ca0b76c285;p=thirdparty%2Fiproute2.git rto_min value display overflow Reported by: Satoru SATOH "ip route show" does not print correct value when larger rto_min is set (e.g. 3sec). This problem is because of overflow in print_route() and the patch below is a workaround fix for that. [root test]# ./iproute2.git.org/ip/ip route show dev eth1 192.168.140.0/24 proto kernel scope link src 192.168.140.130 169.254.0.0/16 scope link [root test]# ./iproute2.git.org/ip/ip route change 192.168.140.0/24 dev eth1 rto_min 3s [root test]# ./iproute2.git.org/ip/ip route show dev eth1 192.168.140.0/24 scope link rto_min lock 2ms <-- wrong 169.254.0.0/16 scope link [root test]# ./iproute2.git/ip/ip route show dev eth1 # patched version 192.168.140.0/24 scope link rto_min lock 3000ms <-- correct 169.254.0.0/16 scope link This is a simpler fix. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: Stephen Hemminger --- diff --git a/ip/iproute.c b/ip/iproute.c index f4200aeff..7a885b0ce 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -509,7 +509,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) i != RTAX_RTO_MIN) fprintf(fp, " %u", *(unsigned*)RTA_DATA(mxrta[i])); else { - unsigned val = *(unsigned*)RTA_DATA(mxrta[i]); + unsigned long long val = *(unsigned*)RTA_DATA(mxrta[i]); val *= 1000; if (i == RTAX_RTT) @@ -517,7 +517,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) else if (i == RTAX_RTTVAR) val /= 4; if (val >= hz) - fprintf(fp, " %ums", val/hz); + fprintf(fp, " %llums", val/hz); else fprintf(fp, " %.2fms", (float)val/hz); }