Skip to content

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

Closed
@PJB3005

Description

@PJB3005

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Net.Socketsbughelp wanted[up-for-grabs] Good issue for external contributorsin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions