-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: missing interfaces on Windows #12301
Comments
Strangely, |
Please take a look at https://github.com/golang/go/blob/master/CONTRIBUTING.md and let us know your environment information. Also can you show us the output of "go test -v -run=Interface at $GOROOT/src/net" and "ipconfig? ifconfig? netsh interfaces show?" on the node? (Please anonymize IDs in the output if necessary) |
I edited my original post. |
Thanks. Just skimmed interface_windows.go and looks like the code is broken. At least about the following:
|
Re 1, it does, because of In my case: |
@mikioh feel free to change. I know nothing about these. Happy to test / review if you need my help. Alex |
Feel free to send a fix if you have a spare time. Unfortunately I'm not a windows user, have no windows box. |
Ah... @AudriusButkevicius, after you. |
Well the win32 api is not clear to me, why it would return only info for a single interface, hence I am not sure what the right answer here is, hence pinging @mattn in hopes for comments. |
I can reproduce. I'll look into it in later. But I don't have the old environment windowns XP 32bit that I made the change.no longer. Currently, I'm on windows 64bit. |
Well for me I can reproduce on win8.1 x64, so shouldn't be a problem. |
Hmm, I'm trying this on another 64bit windows. But test are passed. I'm confusing. |
Why did this change from 1.4? |
So tests are passing on my machine too, but they are not testing against ipconfig for example. So the output the tests produce is just wrong. As you can see in my case it only returns loopback addresses, though I have an 192 ip address too. |
I don't understand most details. We just tried to make tests pass. Alex |
If you have no spare time for now, I'll take a look a bit this weekend.
Old windows APIs used in the previous versions don't support IPv6 entirely. |
Yes, And some APIs doesn't support wide character set.
Do it please. But I'll look if it possible. |
The function getInterfaceInfos() in "src/net/interface_windows.go" return a incorrect slice, return iia[:iilen-1], nil This line code should be return iia[:iilen], nil |
CL https://golang.org/cl/14574 mentions this issue. |
I'll test this later tonight. |
👍 this fixes it. |
❤️ Thank you. |
@AudriusButkevicius sorry and sad :( |
CL https://golang.org/cl/14747 mentions this issue. |
I see this hasn't been closed yet, though the changeset looked complete. Any issues along the way? I really hope this makes it for 1.5.2. |
CL https://golang.org/cl/14747 needs a test that won't let us break that code again. Also @mikioh proposed an alternative solution https://go-review.googlesource.com/#/c/14747/ Alex |
CL https://golang.org/cl/16751 mentions this issue. |
OK for Go 1.5.2. |
CL https://golang.org/cl/16984 mentions this issue. |
…faces on windows Fixes #12301 Change-Id: I8d01ec9551c6cff7e6129e06a7deb36a3be9de41 Reviewed-on: https://go-review.googlesource.com/16751 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-on: https://go-review.googlesource.com/16984 Run-TryBot: Austin Clements <[email protected]> Reviewed-by: Alex Brainman <[email protected]> Reviewed-by: Russ Cox <[email protected]>
CL https://golang.org/cl/17412 mentions this issue. |
…on on windows The current implementation including Go 1.5 through 1.5.2 misuses Windows API and mishandles the returned values from GetAdapterAddresses on Windows. This change fixes various issues related to network facility information by readjusting interface and interface address parsers. Updates #5395. Updates #10530. Updates #12301. Updates #12551. Updates #13542. Fixes #12691. Fixes #12811. Fixes #13476. Fixes #13544. Also fixes fragile screen scraping test cases in net_windows_test.go. Additional information for reviewers: It seems like almost all the issues above have the same root cause and it is misunderstanding of Windows API. If my interpretation of the information on MSDN is correctly, current implementation contains the following bugs: - SIO_GET_INTERFACE_LIST should not be used for IPv6. The behavior of SIO_GET_INTERFACE_LIST is different on kernels and probably it doesn't work correctly for IPv6 on old kernels such as Windows XP w/ SP2. Unfortunately MSDN doesn't describe the detail of SIO_GET_INTERFACE_LIST, but information on the net suggests so. - Fetching IP_ADAPTER_ADDRESSES structures with fixed size area may not work when using IPv6. IPv6 generates ton of interface addresses for various addressing scopes. We need to adjust the area appropriately. - PhysicalAddress field of IP_ADAPTER_ADDRESSES structure may have extra space. We cannot ignore PhysicalAddressLength field of IP_ADAPTER_ADDRESS structure. - Flags field of IP_ADAPTER_ADDRESSES structure doesn't represent any of administratively and operatinal statuses. It just represents settings for windows network adapter. - MTU field of IP_ADAPTER_ADDRESSES structure may have a uint32(-1) on 64-bit platform. We need to convert the value to interger appropriately. - IfType field of IP_ADAPTER_ADDRESSES structure is not a bit field. Bitwire operation for the field is completely wrong. - OperStatus field of IP_ADAPTER_ADDRESSES structure is not a bit field. Bitwire operation for the field is completely wrong. - IPv6IfIndex field of IP_ADAPTER_ADDRESSES structure is just a substitute for IfIndex field. We cannot prefer IPv6IfIndex to IfIndex. - Windows XP, 2003 server and below don't set OnLinkPrefixLength field of IP_ADAPTER_UNICAST_ADDRESS structure. We cannot rely on the field on old kernels. We can use FirstPrefix field of IP_ADAPTER_ADDRESSES structure and IP_ADAPTER_PREFIX structure instead. - Length field of IP_ADAPTER_{UNICAST,ANYCAST,MULTICAST}_ADDRESS sturecures doesn't represent an address prefix length. It just represents a socket address length. Change-Id: Icabdaf7bd1d41360a981d2dad0b830b02b584528 Reviewed-on: https://go-review.googlesource.com/17412 Reviewed-by: Alex Brainman <[email protected]>
In 1.4.1 returns:
In 1.5 returns:
Any code relying on net.Interfaces() breaks (for example making multicasts to all interfaces, since Windows by default multicasts to some single interface)
What version of Go are you using (go version)?
go version go1.5 windows/amd64
What operating system and processor architecture are you using?
Windows 8.1 x64
What did you do?
Called net.Interfaces()
What did you expect to see?
My one external interface
What did you see instead?
My one loopback interface
ipconfig /all
netsh interface show interface
Test output:
The text was updated successfully, but these errors were encountered: