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

cf-socket: turn off IPV6_V6ONLY on Windows if it is supported #10975

Closed
wants to merge 2 commits into from

Conversation

@bagder
Copy link
Member

bagder commented Apr 16, 2023

Quoting section 5.3 of RFC 3493:

Note - This option has no effect on the use of IPv4 Mapped addresses

Which sounds like the opposite to the reason for this PR?

@lifenjoiner
Copy link
Contributor Author

lifenjoiner commented Apr 17, 2023

The whole note in section 5.3 of RFC 3493:

Note - This option has no effect on the use of IPv4 Mapped addresses
which enter a node as a valid IPv6 addresses for IPv6 communications
as defined by Stateless IP/ICMP Translation Algorithm (SIIT) [5].

That is confusing. I guess it means in separate translator "boxes" by the SIIT (rfc2765) abstract section:

The algorithm
translates between IPv4 and IPv6 packet headers (including ICMP
headers) in separate translator "boxes" in the network without
requiring any per-connection state in those "boxes".

Some facts on IPv4-mapped IPv6 addresses support:

  • Turning off IPV6_V6ONLY does make it work on IPv4-mapped IPv6 addresses with dual-stack socket.
  • Most OSes works on it by default. while Windows don't.
  • Browsers like Chrome can visit them, while IE and Firefox don't, on Windows.
  • Windows, ping works, while nslookup doesn't. dig does.

Edit: I had a golang compiled proxy for Firefox. Golang runtime has the capability by default.

@lifenjoiner
Copy link
Contributor Author

The problem is Windows doesn't follow the RFC to set IPV6_V6ONLY off by default, but requires users to do it when they want to create dual-stack socket for IPv4-mapped IPv6 addresses support.
Search IPV6_V6ONLY in the options table.

@jay
Copy link
Member

jay commented Apr 19, 2023

Does it really need a separate function?

#if defined(IPV6_V6ONLY) && defined(WIN32)
  /* Allow IPv4 with AF_INET6 sockets on Windows. Other OSes allow this by default. */
  {
    int on = 0;
    setsockopt(ctx->sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on));
  }
#endif

@lifenjoiner
Copy link
Contributor Author

Does it really need a separate function?

Not really.

A function is for other place to reuse it. And, if not, the line is longer than 79 chars with (void) return. Compilers would optimize it for binaries :p

@lifenjoiner
Copy link
Contributor Author

Does it really need a separate function?

Not really.

A function is for other place to reuse it. And, if not, the line is longer than 79 chars with (void) return. Compilers would optimize it for binaries :p

The real reason is, I saw "we write C89 code", just recalled.

Since we write C89 code, **//** comments are not allowed. They were not

@bagder bagder added the Windows Windows-specific label Apr 26, 2023
@bagder bagder closed this in ca3f6de Apr 26, 2023
@bagder
Copy link
Member

bagder commented Apr 26, 2023

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants