netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [IPROUTE]: A workaround to make larger rto_min printed correctly
@ 2007-12-20  3:31 Satoru SATOH
  2007-12-20  8:35 ` YOSHIFUJI Hideaki / 吉藤英明
  2007-12-20  9:12 ` Jarek Poplawski
  0 siblings, 2 replies; 13+ messages in thread
From: Satoru SATOH @ 2007-12-20  3:31 UTC (permalink / raw)
  To: netdev

"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
[root test]#


Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com>

 ip/iproute.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index f4200ae..fa722c6 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -510,16 +510,16 @@ int print_route(const struct sockaddr_nl *who,
struct nlmsghdr *n, void *arg)
                                fprintf(fp, " %u",
*(unsigned*)RTA_DATA(mxrta[i]));
                        else {
                                unsigned val = *(unsigned*)RTA_DATA(mxrta[i]);
+                               unsigned hz1 = hz / 1000;

-                               val *= 1000;
                                if (i == RTAX_RTT)
                                        val /= 8;
                                else if (i == RTAX_RTTVAR)
                                        val /= 4;
-                               if (val >= hz)
-                                       fprintf(fp, " %ums", val/hz);
+                               if (val >= hz1)
+                                       fprintf(fp, " %ums", val/hz1);
                                else
-                                       fprintf(fp, " %.2fms", (float)val/hz);
+                                       fprintf(fp, " %.2fms", (float)val/hz1);
                        }
                }
        }

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2007-12-21 17:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-20  3:31 [PATCH] [IPROUTE]: A workaround to make larger rto_min printed correctly Satoru SATOH
2007-12-20  8:35 ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-20  9:12 ` Jarek Poplawski
2007-12-20 16:21   ` Satoru SATOH
2007-12-20 20:24     ` Jarek Poplawski
2007-12-20 20:31       ` Jarek Poplawski
2007-12-21  2:24         ` Satoru SATOH
2007-12-21  8:34           ` Jarek Poplawski
2007-12-21  8:53           ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-21 11:18             ` Bill Fink
2007-12-21 13:49             ` Satoru SATOH
2007-12-21 13:58               ` YOSHIFUJI Hideaki / 吉藤英明
2007-12-21 17:14                 ` Stephen Hemminger

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).