From 2fcca60a7bf084a28e878941d9dcb47e11268cbd Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Mon, 9 Nov 2020 13:55:28 -0800 Subject: net: connect to the ipv4 localhost returns ENETUNREACH if the address isn't set cl/340002915 modified the code to return EADDRNOTAVAIL if connect is called for a localhost address which isn't set. But actually, Linux returns EADDRNOTAVAIL for ipv6 addresses and ENETUNREACH for ipv4 addresses. Updates #4735 PiperOrigin-RevId: 341479129 --- pkg/tcpip/stack/stack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go index a23fb97ff..0fe157128 100644 --- a/pkg/tcpip/stack/stack.go +++ b/pkg/tcpip/stack/stack.go @@ -1418,7 +1418,7 @@ func (s *Stack) FindRoute(id tcpip.NICID, localAddr, remoteAddr tcpip.Address, n if needRoute { return Route{}, tcpip.ErrNoRoute } - if isLoopback { + if header.IsV6LoopbackAddress(remoteAddr) { return Route{}, tcpip.ErrBadLocalAddress } return Route{}, tcpip.ErrNetworkUnreachable -- cgit v1.2.3