[PATCH] ws2_32: Allow user to enable IP dual stack (v3)

Bruno Jesus 00cpxxx at gmail.com
Tue Jul 5 12:33:45 CDT 2016


On Tue, Jul 5, 2016 at 10:33 AM, Matthieu Nottale
<matthieu.nottale at infinit.io> wrote:
> IP dual stack (v4+v6) should be disabled by default, but previous code
> was setting IPV6_V6ONLY in bind() which prevented user to override it.
> This patch moves setting IPV6_V6ONLY to socket creation time.

It still looks like there is a formatting problem with the patch,
please attach it in a new attempt or use git send-email, also see the
comments below.

> Signed-off-by: Matthieu Nottale <matthieu.nottale at infinit.io>
> ---
>  dlls/ws2_32/socket.c     | 22 ++++++++-------------
>  dlls/ws2_32/tests/sock.c | 51
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 59 insertions(+), 14 deletions(-)
>

> +    enabled = 2;
> +    len = sizeof(enabled);
> +    ret = getsockopt(v6, IPPROTO_IPV6, IPV6_V6ONLY, &enabled, &len);
> +    if (ret) {
> +      ok(!ret, "Failed to check IPV6_V6ONLY ((LastError: %d).\n",
> WSAGetLastError());
> +      goto end;
> +    }

If the ok() is supposed to always fail use ok(0, ...). But according
to msdn this option is not present in 2003/XP, so you would end up
with an error. Better to use win_skip then to avoid this problem.

The testbot will test against many different Windows versions so we
need to ensure it works everywhere, before resending it would be
useful to do a manual run at https://testbot.winehq.org/ to check the
patch.

> +    ok(enabled == 1, "IPV6_V6ONLY is not enabled by default.\n");
> +    ret = setsockopt(v6, IPPROTO_IPV6, IPV6_V6ONLY, &enabled, len);
> +    if (ret) {
> +      ok(!ret, "Failed to disable IPV6_V6ONLY (LastError: %d).\n",
> WSAGetLastError());
> +      goto end;
> +    }

This should never fail as the previous test already took care of
checking for IPV6_V6ONLY support, so drop the if and goto.

> +    enabled = 2;
> +    len = sizeof(enabled);
> +    ret = getsockopt(v6, IPPROTO_IPV6, IPV6_V6ONLY, &enabled, &len);
> +    if (ret) {
> +      ok(!ret, "Failed to check IPV6_V6ONLY (LastError: %d).\n",
> WSAGetLastError());
> +      goto end;
> +    }

Again I think getsockopt must always work at this point.

> +    ok(!enabled, "IPV6_V6ONLY is enabled after bind.\n");
> +    v4 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
> +    if (v4 == INVALID_SOCKET) {
> +        skip("Could not create IPv4 socket (LastError: %d).\n",
> +            WSAGetLastError());
> +        goto end;
> +    }
> +    WSASetLastError(0xdeadbeef);
> +    ret = bind(v4, (struct sockaddr*)&sin4, sizeof(sin4));

Please also test ok(ret,...);

Best wishes,
Bruno



More information about the wine-devel mailing list