diff options
| author | Mikio Hara <mikioh.mikioh@gmail.com> | 2016-12-20 17:39:54 +0900 |
|---|---|---|
| committer | Mikio Hara <mikioh.mikioh@gmail.com> | 2016-12-21 01:19:02 +0000 |
| commit | 86f2c5fe930b25ff69017002c36880c88157188e (patch) | |
| tree | 90c98002737d9c12f304c44d45285edc3ecbc48d /src/net/interface.go | |
| parent | 985a574991207a74ab45ce76ecf54228734ddffe (diff) | |
| download | go-86f2c5fe930b25ff69017002c36880c88157188e.tar.xz | |
net: make InterfaceByIndex return a consistent name on solaris
Also retightens test cases for Resolve{TCP,UDP,IP}Addr which are using
interface names for specifying IPv6 zone.
Updates #14037.
Fixes #18362.
Change-Id: I7444b6302e2847dfbdab8a0ad5b2e702bed1a3d6
Reviewed-on: https://go-review.googlesource.com/34670
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/interface.go')
| -rw-r--r-- | src/net/interface.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/net/interface.go b/src/net/interface.go index 301a5cfd22..b3297f249d 100644 --- a/src/net/interface.go +++ b/src/net/interface.go @@ -172,6 +172,9 @@ func InterfaceByName(name string) (*Interface, error) { // An ipv6ZoneCache represents a cache holding partial network // interface information. It is used for reducing the cost of IPv6 // addressing scope zone resolution. +// +// Multiple names sharing the index are managed by first-come +// first-served basis for consistency. type ipv6ZoneCache struct { sync.RWMutex // guard the following lastFetched time.Time // last time routing information was fetched @@ -202,7 +205,9 @@ func (zc *ipv6ZoneCache) update(ift []Interface) { zc.toName = make(map[int]string, len(ift)) for _, ifi := range ift { zc.toIndex[ifi.Name] = ifi.Index - zc.toName[ifi.Index] = ifi.Name + if _, ok := zc.toName[ifi.Index]; !ok { + zc.toName[ifi.Index] = ifi.Name + } } } |
