Skip to content
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

Closed
akevinbailey opened this issue Oct 1, 2015 · 8 comments

Comments

@akevinbailey
Copy link

I found another issue in interface_windows.go: The interfaceAddrTable returns Interfaces that are not active. Need to implement the follow code after for ; paddr != nil; paddr = paddr.Next { ... (line 156):

if paddr.OperStatus == windows.IfOperStatusUp {
...
}

This will exclude inactive interfaces.

@rakyll rakyll changed the title Go 1.5.1 Windows -- The interfaceAddrTable retuns inactive interfaces net: the interfaceAddrTable returns inactive interfaces on windows Oct 1, 2015
@rakyll
Copy link
Contributor

rakyll commented Oct 1, 2015

/cc @alexbrainman

@rakyll rakyll changed the title net: the interfaceAddrTable returns inactive interfaces on windows net: interfaceAddrTable returns inactive interfaces on windows Oct 1, 2015
@rsc
Copy link
Contributor

rsc commented Oct 23, 2015

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.

@rsc rsc added this to the Go1.6 milestone Oct 23, 2015
@akevinbailey
Copy link
Author

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.
-- Kevin  

 From: Russ Cox <notifications@github.com>

To: golang/go go@noreply.github.com
Cc: A. Kevin Bailey akevinbailey@yahoo.com
Sent: Friday, October 23, 2015 12:49 PM
Subject: Re: [go] net: interfaceAddrTable returns inactive interfaces on windows (#12812)

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.—
Reply to this email directly or view it on GitHub.

@rsc
Copy link
Contributor

rsc commented Nov 5, 2015

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?

@mikioh mikioh changed the title net: interfaceAddrTable returns inactive interfaces on windows net: InterfaceAddrs, Interface.{Addrs,MulticastAddrs} can return addresses on administratively or operational down interface Dec 8, 2015
@mikioh mikioh removed the OS-Windows label Dec 8, 2015
@mikioh
Copy link
Contributor

mikioh commented Dec 8, 2015

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.)

@rsc rsc modified the milestones: Go1.7, Go1.6, Go1.7Early Jan 14, 2016
@bradfitz bradfitz modified the milestones: Go1.8Maybe, Go1.7Early May 5, 2016
@quentinmit quentinmit added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 10, 2016
@rsc
Copy link
Contributor

rsc commented Oct 20, 2016

So: should we return addresses for down interfaces or not? @mikioh, what do you think?

@mikioh
Copy link
Contributor

mikioh commented Oct 21, 2016

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.

@rsc
Copy link
Contributor

rsc commented Nov 2, 2016

OK, working as intended.

@rsc rsc closed this as completed Nov 2, 2016
@rsc rsc removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Nov 2, 2016
@golang golang locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants