Skip to content

Socket.DontFragment can't be set on IPv6 DualMode sockets #102700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ public bool DontFragment
{
get
{
if (_addressFamily == AddressFamily.InterNetwork)
if (_addressFamily == AddressFamily.InterNetwork || (_addressFamily == AddressFamily.InterNetworkV6 && DualMode))
{
return (int)GetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment)! != 0 ? true : false;
}
Expand All @@ -648,7 +648,7 @@ public bool DontFragment

set
{
if (_addressFamily == AddressFamily.InterNetwork)
if (_addressFamily == AddressFamily.InterNetwork || (_addressFamily == AddressFamily.InterNetworkV6 && DualMode))
{
SetSocketOption(SocketOptionLevel.IP, SocketOptionName.DontFragment, value ? 1 : 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,5 +1157,16 @@ public void CancelConnectAsync_NullEventArgs_Throws_ArgumentNull()
{
Assert.Throws<ArgumentNullException>(() => Socket.CancelConnectAsync(null));
}

// MacOS And FreeBSD do not support setting don't-fragment (DF) bit on dual mode socket
[Fact]
[PlatformSpecific(TestPlatforms.Linux | TestPlatforms.Windows)]
public void CanSetDontFragment_OnIPV6Address_DualModeSocket()
{
using Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
socket.DualMode = true;
socket.DontFragment = true;
Assert.True(socket.DontFragment);
}
}
}