Skip to content

Commit f98e1c1

Browse files
committed
pinger: read RX timestamp only upon receiving a valid ICMP Echo reply
1 parent 579482c commit f98e1c1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pinger/pinger.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,16 @@ func receive(conn *net.IPConn) (*net.IPAddr, *icmp.Echo, time.Time, error) {
176176
}
177177
return nil, nil, ts, err
178178
}
179-
180-
if ts, err = getTimestampFromOutOfBandData(oob, oobn); err != nil {
181-
return nil, nil, ts, fmt.Errorf("failed to get RX timestamp: %s", err)
182-
}
183-
184179
echo, err := extractEchoFromPacket(pktBuf, n)
185180
if err != nil {
186181
return nil, nil, ts, fmt.Errorf("failed to extract ICMP Echo from IPv4 packet %s: %s", ra, err)
187182
}
183+
if echo == nil {
184+
return nil, nil, ts, nil
185+
}
186+
if ts, err = getTimestampFromOutOfBandData(oob, oobn); err != nil {
187+
return nil, nil, ts, fmt.Errorf("failed to get RX timestamp: %s", err)
188+
}
188189
return ra, echo, ts, nil
189190
}
190191

0 commit comments

Comments
 (0)