Description
While DontFragment doesn't make much sense on IPv6 itself, it is still useful for dual-stack sockets (an IPv6 socket that can handle IPv4 traffic too, through ::FFFF:x.x.x.x IPv6 addresses).
Manually setting it via SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, true) does work. The problem appears to be a rough top-level check in the DontFragment property itself, nothing lower-level:
|
if (_addressFamily == AddressFamily.InterNetwork) |
On both Windows and Linux, the flags are correctly respected when sending IPv4 traffic out of the IPv6 socket (at least, if my Wireshark isn't lying).
Reproduction Steps
using var s = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
s.DualMode = true;
s.Bind(IPEndPoint.Parse("[::]:1212"));
s.DontFragment = true;
Expected behavior
Don't fragment to be set on IPv4 sockets sent from the dual-stack socket.
Actual behavior
Unhandled exception. System.NotSupportedException: This protocol version is not supported.
Regression?
No response
Known Workarounds
SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, true); works great.
Configuration
No response
Other information
No response
Description
While
DontFragmentdoesn't make much sense on IPv6 itself, it is still useful for dual-stack sockets (an IPv6 socket that can handle IPv4 traffic too, through::FFFF:x.x.x.xIPv6 addresses).Manually setting it via
SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, true)does work. The problem appears to be a rough top-level check in theDontFragmentproperty itself, nothing lower-level:runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
Line 652 in 8ff1bd0
On both Windows and Linux, the flags are correctly respected when sending IPv4 traffic out of the IPv6 socket (at least, if my Wireshark isn't lying).
Reproduction Steps
Expected behavior
Don't fragment to be set on IPv4 sockets sent from the dual-stack socket.
Actual behavior
Regression?
No response
Known Workarounds
SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, true);works great.Configuration
No response
Other information
No response