Skip to content

Commit f26c31c

Browse files
authored
Fix scope id test failures on mac and linux (#1754)
1 parent 3904763 commit f26c31c

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/SockAddr.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,20 @@ public unsafe IPEndPoint GetIPEndPoint()
9393
*((long*)(b + 8)) = _field2;
9494
}
9595

96-
return new IPEndPoint(new IPAddress(bytes, scopeid: _field3 & 0xFFFFFFFF), port);
96+
return new IPEndPoint(new IPAddress(bytes, ScopeId), port);
97+
}
98+
}
99+
100+
public uint ScopeId
101+
{
102+
get
103+
{
104+
return (uint)_field3;
105+
}
106+
set
107+
{
108+
_field3 &= unchecked ((long)0xFFFFFFFF00000000);
109+
_field3 |= value;
97110
}
98111
}
99112

src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/Networking/UvTcpHandle.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public void Bind(IPEndPoint endPoint)
4444
{
4545
throw error1;
4646
}
47+
48+
if (endPoint.Address.ScopeId != addr.ScopeId)
49+
{
50+
// IPAddress.ScopeId cannot be less than 0 or greater than 0xFFFFFFFF
51+
// https://msdn.microsoft.com/en-us/library/system.net.ipaddress.scopeid(v=vs.110).aspx
52+
addr.ScopeId = (uint)endPoint.Address.ScopeId;
53+
}
4754
}
4855

4956
_uv.tcp_bind(this, ref addr, 0);

test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public async Task RegisterAddresses_IPv6Port80_Success(string addressInput, Func
109109
[ConditionalTheory, MemberData(nameof(AddressRegistrationDataIPv6ScopeId))]
110110
[IPv6SupportedCondition]
111111
[IPv6ScopeIdPresentCondition]
112-
[OSSkipCondition(OperatingSystems.MacOSX, SkipReason = "Causing test failures")]
113-
[OSSkipCondition(OperatingSystems.Linux, SkipReason = "Causing test failures")]
114112
public async Task RegisterAddresses_IPv6ScopeId_Success(string addressInput, Func<IServerAddressesFeature, string[]> testUrls)
115113
{
116114
await RegisterAddresses_Success(addressInput, testUrls);

0 commit comments

Comments
 (0)