New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: IPNet missing network mask on Windows #12811
Comments
/cc @alexbrainman |
I found another issue: The
This will exclude inactive interfaces. |
@akevinbailey please review https://go-review.googlesource.com/16854. I just followed your advice. I really don't know much about the subject. Thank you. Alex |
CL https://golang.org/cl/16854 mentions this issue. |
Is this a regression from Go 1.4? If not, I think it should be released in Go 1.6, not Go 1.5.2. |
The network mask code looks good, but I don't have a Windows XP image to test the first prefix code. However, you left out a way to filter out the non active interfaces. See #12812 I think it would be best to merge the fix for this issue (12811) with 12812. Then test and release them together as part of Go 1.6. |
It is not regression from go1.4. It was introduced by CL 3024, which is part of go1.5.
I have Windows XP computer. I visually checked my new netmasks looks good.
CL 16854 fixes issue #12811. It has nothing to do with issue #12812. One thing at a time. Do you have a suggestion for a test I can use for issue #12812?
I disagee. These bugs are not related in any ways. It will be much easier (and quicker) to have 2 simple fixes approved, then 1 combined - bigger and more complicated. Both fixes can go into go1.6 (if they make deadline). Alex |
Several months ago I combined the two "fixes" in my code to get the desired functionality for my application. However, since you are the Go expert, you would know better than I what is the best way to bring this to general availability. I found issue 12812 because my laptop has WiFi, 1000base-T, and several VPN connections as shown in the image below. All of the interfaces that have an X are not active but show up in I can send you the code for my "fix" if you like, but if you are separating the solutions, it might not do you much good. Regards, Kevin |
CL https://golang.org/cl/17412 mentions this issue. |
CL https://golang.org/cl/17478 mentions this issue. |
Use windows netsh command to verify interface addresses and netmasks net package returns. The test is to be enabled once issue #12811 is fixed. Updates #12811 Change-Id: I191e350a1403e5133791d4ec59561fefa24f5c61 Reviewed-on: https://go-review.googlesource.com/17478 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Go 1.5.1 on Windows the
IPNet
structure retuned bynet.Interfaces().Addrs()
does not return the actual network mask of the IP address.The current code uses the
puni.Address.SockaddrLength
, but this only returns the default mast of the network and NOT the actual mask! Instead you need to usepuni.OnLinkPrefixLength
Fix:
In the
interfaceAddrTable
function in interface_windows.go change:puni.Address.SockaddrLength
topuni.OnLinkPrefixLength
in lines 167, 171, 182, 196
example:
ifa := &net.IPNet{IP: make(net.IP, net.IPv4len), Mask: net.CIDRMask(int(puni.Address.SockaddrLength), 8 * net.IPv4len)}
change to
ifa := &net.IPNet{IP: make(net.IP, net.IPv4len), Mask: net.CIDRMask(int(puni.OnLinkPrefixLength), 8 * net.IPv4len)}
This will only work on Widows Vista/Windows2008 and above. For Windows XP/Windows 2003 you need to implement the following C code in Go to get the correct prefix length (network mask):
/\* Prior to Windows Vista the FirstPrefix pointed to the list with single prefix for each IP address assigned to the adapter. Order of FirstPrefix does not match order of FirstUnicastAddress, so we need to find corresponding prefix */
I'll leave this exercise up to the Go guys.
The text was updated successfully, but these errors were encountered: