From 86f2c5fe930b25ff69017002c36880c88157188e Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Tue, 20 Dec 2016 17:39:54 +0900 Subject: 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/net/interface.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/net/interface.go') 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 + } } } -- cgit v1.3-6-g1900