Skip to content

match IPv4MappedToIPv6 address in IPv4 networks#103381

Merged
wfurt merged 4 commits into
dotnet:mainfrom
wfurt:ipnet
Jun 17, 2024
Merged

match IPv4MappedToIPv6 address in IPv4 networks#103381
wfurt merged 4 commits into
dotnet:mainfrom
wfurt:ipnet

Conversation

@wfurt

@wfurt wfurt commented Jun 12, 2024

Copy link
Copy Markdown
Member

fixes #98427.
This change does exactly what #98427 asked for. e.g. if there IPv4 IPNetwork Pv4-Mapped IPv6 Addresses address would function same as it's IPv4 equivalent. This prevents hassle and allocations from IPAddress.MapToIPv4 one would have to use.

Note that this is not symmetric. e.g. if somebody would create IPNetwork with ::ffff:192.168.0.0/24 IPv4 address would not match that at the moment. We can fix that if we want to @MihaZupan and @antonfirsov. But I;'m not sure if there is compelling use case. (I can see one for the address from DualMode Socket)

@wfurt wfurt added this to the 9.0.0 milestone Jun 12, 2024
@wfurt wfurt requested review from MihaZupan and antonfirsov June 12, 2024 22:31
@wfurt wfurt self-assigned this Jun 12, 2024

@MihuBot MihuBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I agree this should be the more common direction (IPv4 IPNetwork + DualMode addresses to test).

@MihaZupan MihaZupan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops :)

Comment thread src/libraries/System.Net.Primitives/src/System/Net/IPAddress.cs Outdated
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPNetwork.Contains for IPv4 networks should match IPv4-Mapped IPv6 Addresses

4 participants