Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Dec 11, 2025

Fixes regression from Net9, where you can set DualMode = true even when the OS doesn't support IPv6.
This PR makes it permissive again.

Contributes to #122435

@pavelsavara pavelsavara added this to the 11.0.0 milestone Dec 11, 2025
@pavelsavara pavelsavara self-assigned this Dec 11, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@pavelsavara pavelsavara requested a review from liveans December 11, 2025 13:05
@pavelsavara
Copy link
Member Author

image

@pavelsavara pavelsavara marked this pull request as ready for review December 11, 2025 14:57
Copilot AI review requested due to automatic review settings December 11, 2025 14:57
@pavelsavara
Copy link
Member Author

/backport to release/10.0

@github-actions
Copy link
Contributor

Started backporting to release/10.0 (link to workflow run)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a regression from .NET 9 that prevented setting Socket.DualMode = true when the OS doesn't report IPv6 support. The changes make the DualMode property more permissive by only restricting it on WASI platform instead of checking for full dual-mode support.

Key changes:

  • Modified Socket constructor to create IPv6 sockets based on OS IPv6 support rather than dual-mode support
  • Relaxed DualMode property getter/setter to only restrict on WASI platform
  • Added test coverage for setting DualMode when IPv6 is disabled via environment variable

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs Changed constructor to use OSSupportsIPv6 instead of OSSupportsIPv6DualMode for address family selection; updated DualMode getter and setter to only check IsWasi() instead of OSSupportsIPv6DualMode
src/libraries/System.Net.Sockets/tests/FunctionalTests/OSSupport.cs Added test verifying that DualMode can be set to true and sockets can bind/listen even when IPv6 is disabled via DOTNET_SYSTEM_NET_DISABLEIPV6 environment variable

@pavelsavara pavelsavara merged commit 8a730b5 into dotnet:main Dec 11, 2025
93 of 97 checks passed
@pavelsavara pavelsavara deleted the dualmode_fix branch December 11, 2025 19:07
lewing pushed a commit that referenced this pull request Dec 11, 2025
Fixes regression from Net9, where you can set `DualMode = true` even
when the OS doesn't support IPv6.
This PR makes it permissive again.

Contributes to #122435

Backport of #122448 to release/10.0

/cc @pavelsavara

## Customer Impact

- [x] Customer reported #122435
- [ ] Found internally

[Select one or both of the boxes. Describe how this issue impacts
customers, citing the expected and actual behaviors and scope of the
issue. If customer-reported, provide the issue number.]

## Regression

- [x] Yes #106977
- [ ] No

## Testing

Automated testing

## Risk

Low. This PR reverts to previous behavior for all but WASI OS.

Co-authored-by: Pavel Savara <[email protected]>
@wfurt
Copy link
Member

wfurt commented Dec 11, 2025

I don't think this make sense - we cannot function in DualMode and this only makes it less visible. I feel the correct fix is for caller (e.g. asn.net) to check if DualMode is available instead of blindly assuming so.

@liveans
Copy link
Member

liveans commented Dec 12, 2025

I don't think this make sense - we cannot function in DualMode and this only makes it less visible. I feel the correct fix is for caller (e.g. asn.net) to check if DualMode is available instead of blindly assuming so.

I agree, however we were behaving this way until .NET 10 and only .NET 10 changed this behavior.

@pavelsavara
Copy link
Member Author

we cannot function in DualMode and this only makes it less visible.

As Ahmet said, this PR is compatibility improvement. The use of IPAddress.IPv6Any would be widespread.
And we even promote it's use via Roslyn analyzer

I feel the correct fix is for caller (e.g. asn.net) to check if DualMode is available instead of blindly assuming so.

I also drafted the fix for ASP dotnet/aspnetcore#64734
I think we should merge that one too.

@wfurt
Copy link
Member

wfurt commented Dec 12, 2025

perhaps we should document it as breaking change. It seems like so far it is really just the asp.net using the '*' - and that is fully in our control. It seems like this was done as part of #102700 e.g. it feels like this was not fully intentional. Being able to set 'DontFragment' and apply it to IPv4 also make sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants