-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Allow interface names in IPv6 link-local addresses #35278
Conversation
src/Common/src/Interop/Unix/System.Native/Interop.GetNativeIPInterfaceIndex.cs
Outdated
Show resolved
Hide resolved
src/Common/src/Interop/Windows/Interop.GetNativeIPInterfaceIndex.cs
Outdated
Show resolved
Hide resolved
{ | ||
internal static partial class Sys | ||
{ | ||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetNativeIPInterfaceIndex")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use SetLastError = true, since the method uses errno for errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a light-weight copy of https://github.com/dotnet/corefx/blob/master/src/Common/src/Interop/BSD/System.Native/Interop.ProtocolStatistics.cs#L159-L160 - should I add SetLastError there too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes, although it looks like the call sites don't currently pay attention to or incorporate errno in their thrown exceptions.
src/System.Net.Primitives/tests/FunctionalTests/IPAddressParsing.cs
Outdated
Show resolved
Hide resolved
5ee7b03
to
a013304
Compare
src/Common/src/Interop/Windows/IpHlpApi/Interop.if_nametoindex.cs
Outdated
Show resolved
Hide resolved
@@ -303,11 +298,14 @@ internal static unsafe void Parse(ReadOnlySpan<char> address, ushort* numbers, i | |||
numberIsValid = false; | |||
} | |||
|
|||
start = i; | |||
start = i + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EgorBo can you please take a look at the failures? |
/azp run corefx-ci |
Azure Pipelines successfully started running 1 pipeline(s). |
The relevant changes have been merged. @EgorBo, do you want to update this? |
@stephentoub oh, sure! |
internal static partial class IpHlpApi | ||
{ | ||
[DllImport(Interop.Libraries.IpHlpApi, SetLastError = true)] | ||
internal extern static uint if_nametoindex(string name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this isn't available in UWP, which is why a few of the legs are failing with a BCL0015 error. It'll need to be conditionally used when not building for that configuration.
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
lo is predictably ifindex 1 on linux if we want test for address with valid interface.
* Handle interface names in ipv6 addresses (link-local) * fix test projects * Address feedback * Add SetLastError to if_nametoindex * fix tests * fix tests * Add more tests * move native impl to pal_networking.c/h * add newlines to pal_networking * fix build * remove "Vista" comment from Interop.if_nametoindex.cs * test fix for Uri.cs * undo changes * Always return 0 for if_nametoindex on UAP Commit migrated from dotnet/corefx@fef0f81
Fixes https://github.com/dotnet/corefx/issues/27529
I tried to re-use
IPAddress
-related stuff in mono and ourDns
implementation doesn't hesitate to usefe80::e8b0:63ff:fee8:6b3b%awdl0
-like format.E.g. if I type
ipconfig |grep inet
in my terminal on OSX I get:So I expect
IPAddress.Parse("fe80::e8b0:63ff:fee8:6b3b%awdl0").ScopeId
to return0x7
instead of aFormatException
or at least0
(ignore that part).Java supports this format (
Inet6Address.getByName("fe80::e8b0:63ff:fee8:6b3b%awdl0")
) but throwsjava.net.UnknownHostException: no such interface fakei123
for unknown interfaces./cc @marek-safar
Also cc @MarcoRossignoli who worked on https://github.com/dotnet/corefx/issues/28863