-
Notifications
You must be signed in to change notification settings - Fork 707
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
fix: fix open AF_INET sockets in s2n_self_talk_ktls_test.c #4852
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boquan-fang
force-pushed
the
open-fds-af-inet-clean
branch
from
October 18, 2024 00:33
e4f5379
to
aab629b
Compare
goatgoose
reviewed
Oct 21, 2024
boquan-fang
force-pushed
the
open-fds-af-inet-clean
branch
from
October 23, 2024 00:09
1b30fb6
to
33f9a89
Compare
* do open and close `file` whenever that is needed
boquan-fang
force-pushed
the
open-fds-af-inet-clean
branch
from
October 23, 2024 00:10
33f9a89
to
53b9365
Compare
lrstewart
reviewed
Oct 23, 2024
* move file open down to Test: s2n_sendfile and close it immediately after that test. * Hence we will only need to open the file once
* there should be a line to separate close file and the for loop test
goatgoose
reviewed
Oct 31, 2024
* move file related open and close into a scope
goatgoose
approved these changes
Nov 1, 2024
lrstewart
approved these changes
Nov 8, 2024
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolved issues:
Partially solve #4005. Detected opened AF_INET sockets in
s2n_self_talk_ktls_test.c
.Description of changes:
fork
ins2n_new_inet_socket_pair
, and doconnect
andaccept
in the same process.file
fd, that was left opened.Call-outs:
Removing fork doesn't change the test behavior.
Logical Explanations: Given that our sockets are initialized as blocking sockets,
accept
will be blocked and wait for its first connection request if no connection is previously requested. This behavior is specified in the man page foraccept
. With fork, ifaccept
is called beforeconnect
, the parent process will be blocked and switch to child process whereconnect
will be called. We can move theconnect
function call into the main process beforeaccept
to make sure the test will not be blocked.connect
function doesn't expectaccept
to be called before it, so it won't block the process.The purpose of
s2n_new_inet_socket_pair
is to set up io_pair's client and server with AF_INET sockets, so that io_pair can be used in the test for KTLS communications. The test behaviors won't be changed, as long ass2n_new_inet_socket_pair
fulfills that purpose.Concerns if the function failed: If such change makes
s2n_new_inet_socket_pair
failed, then unit tests running in CI will fail the test. Local test might still passes, since I didn't set theS2N_KTLS_TESTING_EXPECTED
environment variable locally. Because of the check, the test might just ends if thes2n_new_inet_socket_pair
fails.s2n-tls/tests/unit/s2n_self_talk_ktls_test.c
Lines 168 to 175 in c58f23c
However, that would leads to a very small number of tests passed, since this check is located at the beginning of the test. I checked the number of tests that passed after the change which is 682, that means the function didn't failed and the test is fully executed.
Testing:
s2n_self_talk_ktls_test.c
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.