ws2_32: Enable IP_DONTFRAGMENT by default for SOCK_STREAM sockets.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-05-10 11:30:10 +02:00 committed by Alexandre Julliard
parent 2538a74c80
commit 6d6b4bffb3
2 changed files with 60 additions and 2 deletions

View File

@ -7606,9 +7606,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)

View File

@ -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);
}
}