fix permissive Socket.DualMode#122448
Conversation
|
Tagging subscribers to this area: @dotnet/ncl |
|
/backport to release/10.0 |
|
Started backporting to |
There was a problem hiding this comment.
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 |
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]>
|
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. |
As Ahmet said, this PR is compatibility improvement. The use of
I also drafted the fix for ASP dotnet/aspnetcore#64734 |
|
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. |

Fixes regression from Net9, where you can set
DualMode = trueeven when the OS doesn't support IPv6.This PR makes it permissive again.
Contributes to #122435