Skip to content

network-3.2.8 is broken on Windows: fails with WSAENOPROTOOPT due to DontFragment socket option #608

Closed

Description

@harendra-kumar

We are seeing this error in the CI:

In the test streamly/test/Streamly/Test/Network/Socket.hs (https://ci.appveyor.com/project/harendra-kumar/streamly/builds/53663341):

Network.Socket
    Read/Write
  Network.Socket.exe: Network.Socket.setSockOpt: failed (Bad protocol option (WSAENOPROTOOPT))
  HasCallStack backtrace:
    collectBacktraces, called at libraries\ghc-internal\src\GHC\Internal\Exception.hs:169:13 in ghc-internal:GHC.Internal.Exception
    toExceptionWithBacktrace, called at libraries\ghc-internal\src\GHC\Internal\IO.hs:260:11 in ghc-internal:GHC.Internal.IO
    throwIO, called at libraries\ghc-internal\src\GHC\Internal\Control\Exception\Base.hs:195:43 in ghc-internal:GHC.Internal.Control.Exception.Base . The relevant

We are not setting any socket option in the test, so it has to be some code inside network package.

I think the culprit is this change #603 :

Version 3.2.8.0

    sockopt: add IP_DONTFRAG/IP_MTU_DISCOVER option. https://github.com/haskell/network/pull/603

The following code is unguarded for windows:

    setDontFragment s = when (family == AF_INET) $
#if HAVE_DECL_IP_DONTFRAG || HAVE_DECL_IP_MTU_DISCOVER
      setSocketOption s DontFragment 1
#else
      -- do nothing
      return ()
#endif

What I see in the configure step in the failing build:

configure output in failing build:

[00:06:49] checking whether IP_DONTFRAG is declared... no
[00:06:50] checking whether IP_MTU_DISCOVER is declared... yes

IP_MTU_DISCOVER is causing the DontFragment option to be set which at runtime the OS is not allowing. A potential fix could be:

#if HAVE_DECL_IP_DONTFRAG
    setSocketOption s DontFragment 1
#elif HAVE_DECL_IP_MTU_DISCOVER && !defined(mingw32_HOST_OS)
    setSocketOption s DontFragment 1
#endif

Activity

  1. kazu-yamamoto commented on Mar 11, 2026

    @kazu-yamamoto
    Collaborator

    @harendra-kumar Thank you for this report. Could you send a PR by yourself?
    Cc: @thehajime

  2. harendra-kumar commented on Mar 12, 2026

    @harendra-kumar
    ContributorAuthor

    If anyone else can't take it up I will try in some time.

  3. harendra-kumar commented on May 28, 2026

    @harendra-kumar
    ContributorAuthor

    @kazu-yamamoto please approve the CI run in PR #615

  4. harendra-kumar commented on May 30, 2026

    @harendra-kumar
    ContributorAuthor

    I enabled network 3.2.8 in streamly and noticed that windows build on github succeeds but on appveryor it fails:

    Appveyor: OS: Windows (MSYS_NT-6.3-9600) -- this corresponds to Windows 8.1 / Windows Server 2012 R2
    Github: OS: Windows (MINGW64_NT-10.0-26100) -- this corresponds to Windows 11 24H2

    Looks like it fails on older windows systems but succeeds on newer ones.

  5. kazu-yamamoto commented on Nov 13, 2026

    @kazu-yamamoto
    Collaborator

    Fixed by #605: socket now ignores a failure to set DontFragment, as it already did for IPv6Only. It is on master and has been backported to v3.2, so it will be in the next release of both. Thank you for the report and the investigation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions