traceroute no timeout

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

traceroute no timeout

Gabriel Nieto
o: [hidden email]
Subject:
From: [hidden email]
Cc:
Reply-To: [hidden email]

>Synopsis:      <traceroute no timeout if there is a process ping ipv4
running>
>Category:      <user amd64 system>
>Environment:
        System      : OpenBSD 5.9
        Details     : OpenBSD 5.9 (GENERIC.MP) #8: Tue Sep 27 07:59:42 CEST
2016
                         xxx@xxxxxxx:/usr/src/sys/arch/amd64/compile/
GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
         if you are doing ping to one host and some one else use the
traceroute command, then traceroute command no timeout all the hops.
>How-To-Repeat:
        $ ping 10.39.62.49
PING 10.39.62.49 (10.39.62.49): 56 data bytes
64 bytes from 10.39.62.49: icmp_seq=0 ttl=251 time=6.718 ms
64 bytes from 10.39.62.49: icmp_seq=1 ttl=251 time=3.921 ms
64 bytes from 10.39.62.49: icmp_seq=2 ttl=251 time=3.814 ms
64 bytes from 10.39.62.49: icmp_seq=3 ttl=251 time=3.458 ms
64 bytes from 10.39.62.49: icmp_seq=4 ttl=251 time=3.484 ms
64 bytes from 10.39.62.49: icmp_seq=5 ttl=251 time=5.012 ms
64 bytes from 10.39.62.49: icmp_seq=6 ttl=251 time=3.517 ms
64 bytes from 10.39.62.49: icmp_seq=7 ttl=251 time=8.874 ms
64 bytes from 10.39.62.49: icmp_seq=8 ttl=251 time=3.776 ms
64 bytes from 10.39.62.49: icmp_seq=9 ttl=251 time=3.861 ms
64 bytes from 10.39.62.49: icmp_seq=10 ttl=251 time=3.905 ms
64 bytes from 10.39.62.49: icmp_seq=11 ttl=251 time=4.206 ms
64 bytes from 10.39.62.49: icmp_seq=12 ttl=251 time=3.919 ms
64 bytes from 10.39.62.49: icmp_seq=13 ttl=251 time=3.963 ms
64 bytes from 10.39.62.49: icmp_seq=14 ttl=251 time=4.361 ms
64 bytes from 10.39.62.49: icmp_seq=15 ttl=251 time=3.498 ms
64 bytes from 10.39.62.49: icmp_seq=16 ttl=251 time=3.467 ms
64 bytes from 10.39.62.49: icmp_seq=17 ttl=251 time=4.939 ms
64 bytes from 10.39.62.49: icmp_seq=18 ttl=251 time=3.777 ms

in another session run the command :
$ traceroute -I  openbsd.org
traceroute to powerbasic.com (209.217.33.58), 64 hops max, 60 byte packets
 1  192.168.134.91 (192.168.134.91)  2.928 ms  0.517 ms  0.346 ms
 2  RNMCIC3 (192.168.131.49)  1.132 ms  1.095 ms  1.065 ms

  then traceroute stop and doesn´t show more lines or hops.If you broke the
command ping (Ctrl C) in the first session, or ping is not running,
traceroute go on.
$ ping 10.39.62.49
PING 10.39.62.49 (10.39.62.49): 56 data bytes
64 bytes from 10.39.62.49: icmp_seq=0 ttl=251 time=6.211 ms
64 bytes from 10.39.62.49: icmp_seq=1 ttl=251 time=3.534 ms
64 bytes from 10.39.62.49: icmp_seq=2 ttl=251 time=3.658 ms
64 bytes from 10.39.62.49: icmp_seq=3 ttl=251 time=3.884 ms
64 bytes from 10.39.62.49: icmp_seq=4 ttl=251 time=3.472 ms
64 bytes from 10.39.62.49: icmp_seq=5 ttl=251 time=4.776 ms
64 bytes from 10.39.62.49: icmp_seq=6 ttl=251 time=3.425 ms
64 bytes from 10.39.62.49: icmp_seq=7 ttl=251 time=3.453 ms
64 bytes from 10.39.62.49: icmp_seq=8 ttl=251 time=3.565 ms
64 bytes from 10.39.62.49: icmp_seq=9 ttl=251 time=3.540 ms
64 bytes from 10.39.62.49: icmp_seq=10 ttl=251 time=4.102 ms
64 bytes from 10.39.62.49: icmp_seq=11 ttl=251 time=3.558 ms
64 bytes from 10.39.62.49: icmp_seq=12 ttl=251 time=3.792 ms

Ctrl C

--- 10.39.62.49 ping statistics ---
13 packets transmitted, 13 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 3.425/3.921/6.211/0.750 ms

 $ traceroute -I  openbsd.org
traceroute to openbsd.org (129.128.5.194), 64 hops max, 60 byte packets
 1  192.168.134.91 (192.168.134.91)  2.256 ms  0.417 ms  0.425 ms
 1  192.168.134.91 (192.168.134.91)  2.256 ms  0.417 ms  0.425 ms
 2  RNMCIC3 (192.168.131.49)  1.218 ms  1.126 ms  0.903 ms
 3  * * *
 4  * * *
 5  * * *
^C
$
The lines 4 and 5 show * (timeouts) this time .It is ok.

>Fix:
 In $OpenBSD: *traceroute.c,v 1.95* 2014/03/24 11:11:49  this problem
doesn't exist.


dmesg:
OpenBSD 5.9 (GENERIC.MP) #8: Tue Sep 27 07:59:42 CEST 2016
    xxx@xxxxx:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8573091840 <(857)%20309-1840> (8175MB)
avail mem = 8309071872 <(830)%20907-1872> (7924MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0010 (364 entries)
bios0: vendor Phoenix Technologies LTD version "6.00" date 07/30/2013
bios0: VMware, Inc. VMware Virtual Platform
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S4 S5
acpi0: tables DSDT FACP BOOT APIC MCFG SRAT HPET WAET
acpi0: wakeup devices PCI0(S3) USB_(S1) P2P0(S3) S1F0(S3) S2F0(S3) S3F0(S3)
S4F0(S3) S5F0(S3) S6F0(S3) S7F0(S3) S8F0(S3) S9F0(S3) S10F(S3) S11F(S3)
S12F(S3)
S13F(S3) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz, 1995.25 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,HTT,SSE3,
PCLMUL,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,
AES,XSAVE,AVX,HV,NXE,LONG,LAHF,PERF,ITSC,SENSOR,ARAT
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 65MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz, 1995.59 MHz
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,HTT,SSE3,
PCLMUL,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,
AES,XSAVE,AVX,HV,NXE,LONG,LAHF,PERF,ITSC,SENSOR,ARAT
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz, 1995.58 MHz
cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,HTT,SSE3,
PCLMUL,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,
AES,XSAVE,AVX,HV,NXE,LONG,LAHF,PERF,ITSC,SENSOR,ARAT
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 0, package 1
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz, 1995.58 MHz
cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,
CMOV,PAT,PSE36,CFLUSH,DS,MMX,FXSR,SSE,SSE2,SS,HTT,SSE3,
PCLMUL,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,
AES,XSAVE,AVX,HV,NXE,LONG,LAHF,PERF,ITSC,SENSOR,ARAT
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 0, core 1, package 1
ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 11, 24 pins
acpimcfg0 at acpi0 addr 0xf0000000, bus 0-127
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpicpu0 at acpi0: C1(@1 halt!)
acpicpu1 at acpi0: C1(@1 halt!)
acpicpu2 at acpi0: C1(@1 halt!)
acpicpu3 at acpi0: C1(@1 halt!)
acpibat0 at acpi0: BAT1 not present
acpibat1 at acpi0: BAT2 not present
acpiac0 at acpi0: AC unit online
acpibtn0 at acpi0: SLPB
acpibtn1 at acpi0: LID_
pvbus0 at mainbus0: VMware
vmt0 at pvbus0
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82443BX AGP" rev 0x01
ppb0 at pci0 dev 1 function 0 "Intel 82443BX AGP" rev 0x01
pci1 at ppb0 bus 1
pcib0 at pci0 dev 7 function 0 "Intel 82371AB PIIX4 ISA" rev 0x08
pciide0 at pci0 dev 7 function 1 "Intel 82371AB IDE" rev 0x01: DMA, channel
0 configured to compatibility, channel 1 configured to compatibility
pciide0: channel 0 disabled (no drives)
atapiscsi0 at pciide0 channel 1 drive 0
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0: <NECVMWar, VMware IDE CDR10, 1.00> ATAPI
5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
piixpm0 at pci0 dev 7 function 3 "Intel 82371AB Power" rev 0x08: SMBus
disabled
"VMware VMCI" rev 0x10 at pci0 dev 7 function 7 not configured
vga1 at pci0 dev 15 function 0 "VMware SVGA II" rev 0x00
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
mpi0 at pci0 dev 16 function 0 "Symbios Logic 53c1030" rev 0x01: apic 4 int
17
mpi0: 0, firmware 1.3.41.32
scsibus2 at mpi0: 16 targets, initiator 7
sd0 at scsibus2 targ 0 lun 0: <VMware, Virtual disk, 1.0> SCSI2 0/direct
fixed
sd0: 131072MB, 512 bytes/sector, 268435456 sectors
mpi0: target 0 Sync at 160MHz width 16bit offset 127 QAS 1 DT 1 IU 1
ppb1 at pci0 dev 17 function 0 "VMware PCI" rev 0x02
pci2 at ppb1 bus 2
ppb2 at pci0 dev 21 function 0 "VMware PCIE" rev 0x01
pci3 at ppb2 bus 3
vmx0 at pci3 dev 0 function 0 "VMware VMXNET3" rev 0x01: apic 4 int 18,
address 00:0c:29:8e:11:b4
ppb3 at pci0 dev 21 function 1 "VMware PCIE" rev 0x01
pci4 at ppb3 bus 4
ppb4 at pci0 dev 21 function 2 "VMware PCIE" rev 0x01
pci5 at ppb4 bus 5
ppb5 at pci0 dev 21 function 3 "VMware PCIE" rev 0x01
pci6 at ppb5 bus 6
.
.
.
.
Thank you.
Gabriel Nieto.
Reply | Threaded
Open this post in threaded view
|

Re: traceroute no timeout

Stuart Henderson
On 2017/01/09 16:43, Gabriel Nieto wrote:
>          if you are doing ping to one host and some one else use the
> traceroute command, then traceroute command no timeout all the hops.

I can't replicate this on -current.

>  In $OpenBSD: *traceroute.c,v 1.95* 2014/03/24 11:11:49  this problem
> doesn't exist.

Can you try the traceroute code from -current and see if it still
happens for you?

If it does still happen there, can you identify which commit introduced
the problem?

Reply | Threaded
Open this post in threaded view
|

Re: traceroute no timeout

Gabriel Nieto
OpenBSD 6.0 the problem go on. I think that the commit with the problem was
in traceroute.c, v.1.96 on OpenBSD 5.6.
Thanks.

2017-01-09 17:23 GMT+01:00 Stuart Henderson <[hidden email]>:

> On 2017/01/09 16:43, Gabriel Nieto wrote:
> >          if you are doing ping to one host and some one else use the
> > traceroute command, then traceroute command no timeout all the hops.
>
> I can't replicate this on -current.
>
> >  In $OpenBSD: *traceroute.c,v 1.95* 2014/03/24 11:11:49  this problem
> > doesn't exist.
>
> Can you try the traceroute code from -current and see if it still
> happens for you?
>
> If it does still happen there, can you identify which commit introduced
> the problem?
>
>
Reply | Threaded
Open this post in threaded view
|

Re: traceroute no timeout

Florian Obser-2
In reply to this post by Gabriel Nieto
On Mon, Jan 09, 2017 at 04:43:03PM +0100, Gabriel Nieto wrote:
>          if you are doing ping to one host and some one else use the
> traceroute command, then traceroute command no timeout all the hops.

indeed, the problem is that poll(2) returns because it sees a packet that
is not for us. and then poll(2) is called with the same timeout as before
without taking into account the time we already waited.

This should fix the problem (on -current):

diff --git traceroute.c traceroute.c
index 1444de11f9e..7c6f69c21c5 100644
--- traceroute.c
+++ traceroute.c
@@ -297,6 +297,7 @@ u_char proto = IPPROTO_UDP;
 
 int verbose;
 int waittime = 5; /* time to wait for response (in seconds) */
+int curwaittime; /* time left to wait for response */
 int nflag; /* print addresses numerically */
 int dump;
 int Aflag; /* lookup ASN */
@@ -838,13 +839,20 @@ main(int argc, char *argv[])
 
  gettime(&t1);
  send_probe(++seq, ttl, incflag, to);
+ curwaittime = waittime * 1000;
  while ((cc = wait_for_reply(rcvsock, &rcvmhdr))) {
  gettime(&t2);
  i = packet_ok(to->sa_family, &rcvmhdr, cc, seq,
     incflag);
- /* Skip short packet */
- if (i == 0)
+ /* Skip wrong packet */
+ if (i == 0) {
+ curwaittime = waittime * 1000 -
+    ((t2.tv_sec - t1.tv_sec) * 1000 +
+    (t2.tv_usec - t1.tv_usec) / 1000);
+ if (curwaittime < 0)
+ curwaittime = 0;
  continue;
+ }
  if (to->sa_family == AF_INET) {
  ip = (struct ip *)packet;
  if (from4.sin_addr.s_addr != lastaddr) {
diff --git traceroute.h traceroute.h
index 8b9e435c119..419168c2b4e 100644
--- traceroute.h
+++ traceroute.h
@@ -137,7 +137,7 @@ extern u_char proto;
 #define ICMP_CODE 0;
 
 extern int verbose;
-extern int waittime; /* time to wait for response (in seconds) */
+extern int curwaittime; /* time left to wait for response */
 extern int nflag; /* print addresses numerically */
 extern int dump;
 extern int Aflag; /* lookup ASN */
diff --git worker.c worker.c
index d27e82abd52..7d0ad0fe496 100644
--- worker.c
+++ worker.c
@@ -227,7 +227,7 @@ wait_for_reply(int sock, struct msghdr *mhdr)
  pfd[0].events = POLLIN;
  pfd[0].revents = 0;
 
- if (poll(pfd, 1, waittime * 1000) > 0)
+ if (poll(pfd, 1, curwaittime) > 0)
  cc = recvmsg(rcvsock, mhdr, 0);
 
  return (cc);


--
I'm not entirely sure you are real.

Reply | Threaded
Open this post in threaded view
|

Re: traceroute no timeout

Gabriel Nieto
In reply to this post by Gabriel Nieto

Thank you Florian.



-------- Mensaje original --------De: Florian Obser <[hidden email]> Fecha: 12/1/17  16:05  (GMT+01:00) Para: Gabriel Nieto <[hidden email]> Cc: [hidden email] Asunto: Re: traceroute no timeout
On Mon, Jan 09, 2017 at 04:43:03PM +0100, Gabriel Nieto wrote:
>          if you are doing ping to one host and some one else use the
> traceroute command, then traceroute command no timeout all the hops.

indeed, the problem is that poll(2) returns because it sees a packet that
is not for us. and then poll(2) is called with the same timeout as before
without taking into account the time we already waited.

This should fix the problem (on -current):

diff --git traceroute.c traceroute.c
index 1444de11f9e..7c6f69c21c5 100644
--- traceroute.c
+++ traceroute.c
@@ -297,6 +297,7 @@ u_char proto = IPPROTO_UDP;
 
 int verbose;
 int waittime = 5; /* time to wait for response (in seconds) */
+int curwaittime; /* time left to wait for response */
 int nflag; /* print addresses numerically */
 int dump;
 int Aflag; /* lookup ASN */
@@ -838,13 +839,20 @@ main(int argc, char *argv[])
 
  gettime(&t1);
  send_probe(++seq, ttl, incflag, to);
+ curwaittime = waittime * 1000;
  while ((cc = wait_for_reply(rcvsock, &rcvmhdr))) {
  gettime(&t2);
  i = packet_ok(to->sa_family, &rcvmhdr, cc, seq,
      incflag);
- /* Skip short packet */
- if (i == 0)
+ /* Skip wrong packet */
+ if (i == 0) {
+ curwaittime = waittime * 1000 -
+     ((t2.tv_sec - t1.tv_sec) * 1000 +
+     (t2.tv_usec - t1.tv_usec) / 1000);
+ if (curwaittime < 0)
+ curwaittime = 0;
  continue;
+ }
  if (to->sa_family == AF_INET) {
  ip = (struct ip *)packet;
  if (from4.sin_addr.s_addr != lastaddr) {
diff --git traceroute.h traceroute.h
index 8b9e435c119..419168c2b4e 100644
--- traceroute.h
+++ traceroute.h
@@ -137,7 +137,7 @@ extern u_char proto;
 #define ICMP_CODE 0;
 
 extern int verbose;
-extern int waittime; /* time to wait for response (in seconds) */
+extern int curwaittime; /* time left to wait for response */
 extern int nflag; /* print addresses numerically */
 extern int dump;
 extern int Aflag; /* lookup ASN */
diff --git worker.c worker.c
index d27e82abd52..7d0ad0fe496 100644
--- worker.c
+++ worker.c
@@ -227,7 +227,7 @@ wait_for_reply(int sock, struct msghdr *mhdr)
  pfd[0].events = POLLIN;
  pfd[0].revents = 0;
 
- if (poll(pfd, 1, waittime * 1000) > 0)
+ if (poll(pfd, 1, curwaittime) > 0)
  cc = recvmsg(rcvsock, mhdr, 0);
 
  return (cc);


--