diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/SockAddr.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/SockAddr.cs index 0f0210f91a..5386749623 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/SockAddr.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/SockAddr.cs @@ -93,7 +93,20 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin *((long*)(b + 8)) = _field2; } - return new IPEndPoint(new IPAddress(bytes, scopeid: _field3 & 0xFFFFFFFF), port); + return new IPEndPoint(new IPAddress(bytes, ScopeId), port); + } + } + + public uint ScopeId + { + get + { + return (uint)_field3; + } + set + { + _field3 &= unchecked ((long)0xFFFFFFFF00000000); + _field3 |= value; } } diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/UvTcpHandle.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/UvTcpHandle.cs index 260f04598e..1e3a1409cd 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/UvTcpHandle.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/UvTcpHandle.cs @@ -44,6 +44,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin { throw error1; } + + if (endPoint.Address.ScopeId != addr.ScopeId) + { + // IPAddress.ScopeId cannot be less than 0 or greater than 0xFFFFFFFF + // https://msdn.microsoft.com/en-us/library/system.net.ipaddress.scopeid(v=vs.110).aspx + addr.ScopeId = (uint)endPoint.Address.ScopeId; + } } _uv.tcp_bind(this, ref addr, 0); diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs index c658dbc540..9d717d3935 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs @@ -109,8 +109,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests [ConditionalTheory, MemberData(nameof(AddressRegistrationDataIPv6ScopeId))] [IPv6SupportedCondition] [IPv6ScopeIdPresentCondition] - [OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Causing test failures")] - [OSSkipCondition(OperatingSystems.Linux, SkipReason = "Causing test failures")] public async Task RegisterAddresses_IPv6ScopeId_Success(string addressInput, Func testUrls) { await RegisterAddresses_Success(addressInput, testUrls);