Skip to content

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

@harendra-kumar

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

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