-
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: InterfaceAddrs, Interface.{Addrs,MulticastAddrs} can return addresses on administratively or operational down interface #12812
Comments
/cc @alexbrainman |
If the interface is up but it has an address, is it incorrect to return that address? Serious question. Most down interfaces have no addresses. |
On Windows, down interfaces do have addresses. The *IPAdaperAddresses has a field called OperStatus. On Windows the interface is only considered up if OperStatus==1. If you don't put in this constrain you will get all the down or dormant connections like Wifi, VPN, and virtual host interfaces. Ideally, it would be better to just provide the OperStatus in the return and let the caller decide.
To: golang/go go@noreply.github.com If the interface is up but it has an address, is it incorrect to return that address? Serious question.Most down interfaces have no addresses.— |
OK, I guess we need to decide what InterfaceAddrs does. Does it return only "up" interfaces? I guess it does on other systems? So then maybe it should on Windows too? |
This is not a Windows-specific inconsistency. IIRC, there are two types of implementation on routing information. One is that simply adds and drops connected routes (and interface addresses) on link-layer events such as physical-port/{physical/logical}-link/logical-interface arrivals and departures. The other is that just keeps interface addresses and notifies each status of addresses. The former example would be BSD variants and the latter example would be Linux (and Windows probably.) |
So: should we return addresses for down interfaces or not? @mikioh, what do you think? |
I think it's fine as it is. The document on InterfaceAddrs now suggests using Interfaces and Interface.Addrs instead, and each Interface tells us its operational status. Applications have a choice dealing with the returned interface addresses; for example, a customer traffic transport application ignores addresses belong to operational down interfaces, an infrastructure control/management application treats them as a part of configuration. |
OK, working as intended. |
I found another issue in interface_windows.go: The
interfaceAddrTable
returns Interfaces that are not active. Need to implement the follow code afterfor ; paddr != nil; paddr = paddr.Next { ...
(line 156):if paddr.OperStatus == windows.IfOperStatusUp {
...
}
This will exclude inactive interfaces.
The text was updated successfully, but these errors were encountered: