Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPV6_V6ONLY socket option should fail if the socket is bound #982

Closed
ericeil opened this issue Aug 24, 2016 · 6 comments
Closed

IPV6_V6ONLY socket option should fail if the socket is bound #982

ericeil opened this issue Aug 24, 2016 · 6 comments

Comments

@ericeil
Copy link

ericeil commented Aug 24, 2016

On build 14905:

Run the following C++ code:

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>

int main(void)
{
    printf("Creating socket\n");
    int s = socket(AF_INET6, SOCK_STREAM, 0);
    if (s < 0)
        err(1, "%d", errno);

    printf("Seting V6ONLY=false\n");
    int v6only = 0;
    if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only)) != 0)
        err(1, "%d", errno);

    printf("Binding socket\n");
    sockaddr_in6 addr;
    addr.sin6_family = AF_INET6;
    addr.sin6_addr = in6addr_any;
    addr.sin6_port = 0;
    addr.sin6_scope_id = 0;
    if (bind(s, (sockaddr*)&addr, sizeof(addr)) != 0)
        err(1, "%d", errno);

    printf("Setting V6ONLY=true.  We expect this to fail with EINVAL\n");
    v6only = 1;
    if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &v6only, sizeof(v6only)) == 0 || errno != EINVAL)
    {
        err(1, "Should have failed with EINVAL, but got %d", errno);
    }

    printf("Success!\n");
    return 0;
}

On Linux, attempting to change IPV6_V6ONLY after the socket is bound results in an EINVAL error. On Windows, this call returns success.

@sunilmut
Copy link
Member

@ericeil - Thanks for reporting the issue. In essence, this is a dupe of #393 . There are some limitations in the IPV6_V6ONLY WSL implementation and we are working with the networking team to resolve them.

@sunilmut
Copy link
Member

With the help of the Windows networking team, we were able to fully implement the IPV6_V6ONLY flag. That resolves this issue. The fix is still in our dev branch, but should soon hit the release branch.

@sunilmut
Copy link
Member

Just FYI that this is fixed in 14936 (see release notes)

@sunilmut sunilmut added fixed and removed fixinbound labels Sep 29, 2016
@ericeil
Copy link
Author

ericeil commented Sep 30, 2016

this is fixed in 14936

Great! I tried validating this with our tests, but running those tests on 14936 seems to result in a BSOD. I assume this is the same probablem as #1138 (and as mentioned in the release notes for this build). When that issue is resolved, I will try again.

@sunilmut
Copy link
Member

@ericeil Just a note that 14942 is now available.

@sunilmut
Copy link
Member

Closing this out since this should be now resolved in 14942+.

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

No branches or pull requests

3 participants