Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/ws2_32/socket.c | 9 ++++++-- dlls/ws2_32/tests/sock.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 25ec72a212..d69902c2d1 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -7532,9 +7532,14 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol, if (ipxptype > 0) set_ipx_packettype(ret, ipxptype);
- /* ensure IP_DONTFRAGMENT is disabled, in Linux the global default can be enabled */ if (unixaf == AF_INET || unixaf == AF_INET6) - set_dont_fragment(ret, unixaf == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP, FALSE); + { + /* ensure IP_DONTFRAGMENT is disabled for SOCK_DGRAM and SOCK_RAW, enabled for SOCK_STREAM */ + if (unixtype == SOCK_DGRAM || unixtype == SOCK_RAW) /* in Linux the global default can be enabled */ + set_dont_fragment(ret, unixaf == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP, FALSE); + else if (unixtype == SOCK_STREAM) + set_dont_fragment(ret, unixaf == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP, TRUE); + }
#ifdef IPV6_V6ONLY if (unixaf == AF_INET6) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 05495b4d39..6dd1491bc0 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -1908,6 +1908,59 @@ todo_wine ok(value == 1, "Expected 1, got %d\n", value);
closesocket(s); + + s = socket(family, SOCK_STREAM, 0); + if (s == INVALID_SOCKET && i) + { + skip("IPv6 is not supported\n"); + break; + } + ok(s != INVALID_SOCKET, "socket failed with error %d\n", GetLastError()); + + size = sizeof(value); + value = 0xdead; + err = getsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, &size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + ok(value == 1 || broken(value == 0) /* < vista */, "Expected 1, got %d\n", value); + + size = sizeof(value); + value = 0; + err = setsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + + value = 0xdead; + err = getsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, &size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + ok(value == 0, "Expected 0, got %d\n", value); + + closesocket(s); + + s = socket(family, SOCK_RAW, 0); + if (s == INVALID_SOCKET) + { + if (WSAGetLastError() == WSAEACCES) skip("SOCK_RAW is not available\n"); + else if (i) skip("IPv6 is not supported\n"); + break; + } + ok(s != INVALID_SOCKET, "socket failed with error %d\n", GetLastError()); + + size = sizeof(value); + value = 0xdead; + err = getsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, &size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + ok(value == 0, "Expected 0, got %d\n", value); + + size = sizeof(value); + value = 1; + err = setsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + + value = 0xdead; + err = getsockopt(s, level, IP_DONTFRAGMENT, (char *) &value, &size); + ok(!err, "Expected 0, got %d with error %d\n", err, GetLastError()); + ok(value == 1, "Expected 1, got %d\n", value); + + closesocket(s); } }