libos-nuse / linux-libos-tools

userspace tools for linux libos
GNU General Public License v2.0
95 stars 19 forks source link

ping: Warning: time of day goes back (-1429997080930663us), taking countermeasures #16

Open xlz opened 9 years ago

xlz commented 9 years ago
xlz@zotac-zboxei750:~/src/net-next-nuse/arch/lib/tools$ sudo NUSECONF=nuse.conf ./nuse ping www.google.com
<5>Linux version 4.0.0+ (xlz@zotac-zboxei750) (gcc version 4.9.2 (Debian 4.9.2-10) ) #0 Thu May 7 02:03:30 EDT 2015
...
create vif eth0
  address = 192.168.1.10
  netmask = 255.255.255.0
  macaddr = 00:00:00:00:00:00
  type    = 0
mac address for eth0 is randomized 02:00:6f:d0:5d:3c
nuse syscall proxy start at unix:///tmp/rump-server-nuse.18368
PING www.google.com (74.125.196.147) 56(84) bytes of data.
Warning: time of day goes back (-1429997080928533us), taking countermeasures.
64 bytes from yk-in-f147.1e100.net (74.125.196.147): icmp_seq=1 ttl=46 time=44.5 ms
...

The cause is that timestamps obtained with SO_TIMESTAMP are from CLOCK_MONOTONIC (~986000 second) and are then compared with CLOCK_REALTIME timestamps from gettimeofday.

Changing CLOCK_MONOTONIC in nuse.c to CLOCK_REALTIME seems to suppress this warning, but it might not be the correct fix.

thehajime commented 9 years ago

great catch.

since nuse_current_ns() is the source of jiffies, used by Linux kernel part, I intended to use CLOCK_MONOTONIC to avoid discontinuous time jump.

I would really like to see how this issue can be solved transparently but didn't come up with the idea.