prober: icmp: Initialize ID and sequence to random values (#412)
authorBenoît Knecht <benoit.knecht@fsfe.org>
Wed, 30 Jan 2019 10:57:57 +0000 (11:57 +0100)
committerBrian Brazil <brian.brazil@robustperception.io>
Wed, 30 Jan 2019 10:57:57 +0000 (10:57 +0000)
commit6958e6f3245455cdd9618bef80185fd50c989ec1
treebde31b60a22bf5e7f20220d4796e1947630b4255
parent844641a4704570c718fb96d990255a34290236d6
prober: icmp: Initialize ID and sequence to random values (#412)

This should help preventing issues with some network devices that have
trouble NATing ICMP packets with the same ID and sequence nubmer but a
different source IP address.

Currently, this can happen if the blackbox_exporter runs in a container
(the ID is set to the PID, which is typically 1 in a container), and
serveral blackbox_exporters are restarted at the same time (the sequence
numbers are reset to zero and stay in sync).

This commit sets the ICMP echo ID to a random value if the PID is 1, and
initializes the sequence number at a random offset.

See #411 for details.

Signed-off-by: Benoît Knecht <benoit.knecht@fsfe.org>
prober/icmp.go