You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two goroutines each create a connection using net.Dial and periodically send ICMP Ping
request packets to two unique host IP addresses. Sometimes a goroutine will read an ICMP
Ping response initiated by the other goroutine. The attached example demonstrates the
behavior.
1. In the attached file 'bug.go', set the variables 'host0' and 'host1' to two unique IP
addresses that are up and that will respond to ICMP Ping request packets.
2. Build the program.
3. Run the program as root. (Max OS X, OpenBSD)
4. The program will send ping packets to the two hosts specified. When a ICMP Ping
response packet is received by a goroutine that did not initiate the request, a 'X' will
be displayed to standard output.
What is the expected output?
The expected output is a never ending stream of dots and no 'X's. (See below)
> sudo ./gonetworkbug
Password:
Pinging 192.168.1.4...
Pinging 192.168.1.8...
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
What do you see instead?
> sudo ./gonetworkbug
Password:
Pinging 192.168.1.4...
Pinging 192.168.1.8...
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................X....
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
Darwin Kernel Version 10.8.0
Which version are you using? (run 'go version')
go version go1.2 darwin/amd64
Please provide any additional information below.
Bug also present on OpenBSD 5.1
That's the nature of socket and/or raw IP stuff. net.Dial doesn't specify the near end
identifier and such configuration installs a tuple like [protocol: ICMP for IPv4, src:
<wildcard IP address>, dst: <specified IP address>] into the protocol stack
inside the kernel. If you want to have a socket that works as not only an endpoint on
top of the ICMP for IPv4 but kinda filter, you need to use either net.Dialer or
net.DialIP.
For example,
var laddr net.Addr
var err error
switch host {
case "192.168.1.4":
laddr, err = net.ResolveAddr("ip4", "a specified address #1 on your node under the test to prevent a crosstalk using wildcard")
case "192.168.1.8":
laddr, err = net.ResolveAddr("ip4", "a specified address #2 on your node under the test to prevent a crosstalk using wildcard")
}
if err != nil {
// error handling
}
d := &net.Dialer{LocalAddr: laddr}
c, err := d.Dial("ip4:icmp", host)
by jleimon:
Attachments:
The text was updated successfully, but these errors were encountered: