-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Windows] Cache v6only option when we create ipv6 socket #11793
[Windows] Cache v6only option when we create ipv6 socket #11793
Conversation
@florincoras can you please take a look since you have been tinkering with the socket interface :) |
source/common/network/socket_impl.cc
Outdated
@@ -122,5 +127,22 @@ absl::optional<Address::IpVersion> SocketImpl::ipVersion() const { | |||
return absl::nullopt; | |||
} | |||
|
|||
bool SocketImpl::isSocketV6Only(const Network::Address::InstanceConstSharedPtr address) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved to address_impl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it depends on io_handle_
, I'm not sure we can do the move. As per my general comment, this is needed because we "forget" what we set on the Socket
/IoHandle
at creation time. We could potentially improve that.
@davinci26 thanks for the heads up! This looks okay but it got me thinking that we are explicitly setting v6only when we create the socket, so we should probably store upfront the value in the @ggreenway what do you think? And a more naive question: do we ever want IPV6_V6ONLY to be false in practice? |
Awesome, your comment makes sense. I was thinking about this but then I wasnt sure if there is any scenario that we set to IPV6_V6ONLY implicitly ( maybe from a user configuration). If there is no such scenario it makes sense to store this info at construction and remove that call entirely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the CI failure.
Should there be any tests added for this case? Or is this fixing a race condition, and so no new coverage is needed?
/wait
@ggreenway I will fix the CI. I think since the race condition was found from an existing (on Windows which will be soon be part of the CI) we dont need additional test coverage. What do you think? @florincoras I think that we need to do the query unfortunately because the default value is set by the system. According to man/ipv6:
The way I interpret this is that there might be a case for a system/environment is ipv6_only due to a different system configuration and it is not Envoy that sets the property. In that case we should be aware and query the socket to get the option. |
We are currently explicitly setting |
The build is broken. Please add a release note about the bug being fixed. @florincoras thanks for your input on this PR. Since you've had the most experience recently in this area, can I assign this PR to you for review? /wait |
@ggreenway sure! |
This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
Apologies for letting this get stale last week was crazy. I am working on the changes now. |
Signed-off-by: davinci26 <sotirisnan@gmail.com>
Signed-off-by: davinci26 <sotirisnan@gmail.com>
de8400c
to
f988dc5
Compare
@florincoras I opted for the implementation that you proposed since its way cleaner ( I get to delete code instead of writing 😄 ) I am getting the CI to be fully green and I will ping you when I am ready for a review |
Sounds good! ;-) |
Signed-off-by: davinci26 <sotirisnan@gmail.com>
Signed-off-by: davinci26 <sotirisnan@gmail.com>
Signed-off-by: davinci26 <sotirisnan@gmail.com>
@florincoras ready for review the CI is clean minus |
@ggreenway I am ready for your review as well! |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall, just one thing to fix.
/wait
Signed-off-by: davinci26 <sotirisnan@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ggreenway can we q tsan again and see what the process it to merge it in. I want to add it to #12172 and see if it makes the tests there less flaky |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
I merged master and pushed again and hopefully it will help with the flaky tests |
On Windows, getsockopt fails if the socket driver is performing another non-blocking operation. For example if we query for a specific socket option while the socket is connecting then the getsockopt is going to fail with error (10022). When we create an ipv6 socket we set it to be ipv6 only. Now we cache this configuration and we query it before we connect to the socket This fixes IpVersions/TcpClientConnectionImplTest.BadConnectConnRefused/IPv6 test on Windows. Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com> Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
On Windows, getsockopt fails if the socket driver is performing another non-blocking operation. For example if we query for a specific socket option while the socket is connecting then the getsockopt is going to fail with error (10022). When we create an ipv6 socket we set it to be ipv6 only. Now we cache this configuration and we query it before we connect to the socket This fixes IpVersions/TcpClientConnectionImplTest.BadConnectConnRefused/IPv6 test on Windows. Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com>
On Windows, getsockopt fails if the socket driver is performing another non-blocking operation. For example if we query for a specific socket option while the socket is connecting then the getsockopt is going to fail with error (10022). When we create an ipv6 socket we set it to be ipv6 only. Now we cache this configuration and we query it before we connect to the socket This fixes IpVersions/TcpClientConnectionImplTest.BadConnectConnRefused/IPv6 test on Windows. Signed-off-by: Sotiris Nanopoulos <sonanopo@microsoft.com> Signed-off-by: chaoqinli <chaoqinli@google.com>
On Windows, getsockopt fails if the socket driver is performing another
non-blocking operation. For example if we query for a specific socket
option while the socket is connecting then the getsockopt is going to
fail with error (10022).
When we create an ipv6 socket we set it to be ipv6 only. Now we cache
this configuration and we query it before we connect to the socket
Signed-off-by: Sotiris Nanopoulos sonanopo@microsoft.com
Additional Description:
This fixes
IpVersions/TcpClientConnectionImplTest.BadConnectConnRefused/IPv6
test on Windows.Risk Level: Low
Testing: Existing test cover this scenario.
Docs Changes:
Release Notes: Fixes an issue on Windows that get socket option returns invalid parameters when Envoy is asynchronously connecting to it. The resolution was to cache the socket option (v6only) option when the socket is created.
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]