From 3e9264c9ae781a2cd28127deaed6ae26f84b4b15 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Sun, 28 Feb 2016 09:37:36 +0900 Subject: net: add support for Zone of IPNet This change adds Zone field to IPNet structure for making it possible to determine which network interface is associated with IPv6 link-local address. Also makes ParseCIDR and IPNet.String capable handling literal IPv6 address prefixes with zone identifier. Fixes #14518. Change-Id: I8f8a40d3b4f500ffef25728d4995651379d8408a Reviewed-on: https://go-review.googlesource.com/19946 Reviewed-by: Ian Lance Taylor --- src/net/interface_linux.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/net/interface_linux.go') diff --git a/src/net/interface_linux.go b/src/net/interface_linux.go index 5e391b28b0..b8f57fd7db 100644 --- a/src/net/interface_linux.go +++ b/src/net/interface_linux.go @@ -193,6 +193,9 @@ func newAddr(ifi *Interface, ifam *syscall.IfAddrmsg, attrs []syscall.NetlinkRou case syscall.AF_INET6: ifa := &IPNet{IP: make(IP, IPv6len), Mask: CIDRMask(int(ifam.Prefixlen), 8*IPv6len)} copy(ifa.IP, a.Value[:]) + if ifa.IP.IsLinkLocalUnicast() { + ifa.Zone = ifi.Name + } return ifa } } -- cgit v1.3