feat: add additional application context into Connection #5637
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.
Goal
This PR changes the behavior of the
set_application_contextAPI to add multiple arbitrary application contexts which can be queried during handshakes. The definition of theapp_contextis changed from only accepting one application context to accept a map of application contexts.Why
We are trying to allow s2n-quic to query the remote address information about the client during the handshake. This PR in s2n-tls allows that addressing information to be added with the connection.
How
Change the definition of the Context for the connection to be a
HashMapof connection context. In this way, we can add as many application data as we want. Hence, we can add the remote address on top of context that were originally needed.I also added a
remove_application_contextAPI to help users managing memory usage.Callouts
I need to modify the
memory_test's memory usage in order for this PR to pass the CI. My change involves changing a variable in theContextstruct fromOptionto aHashMapwhich will definitely increase many usage by about 100 bytes per connection.Refers to https://github.com/aws/s2n-tls/pull/5637/files#diff-63ac16ef5c47eee35caf3e2bbf1909d5a3062a8343d888d399eaf960acf7326b for the change.
Testing
This PR has unit tests for all new APIs it introduced. Also, I have implemented relevant changes for s2n-quic which can be found in aws/s2n-quic@main...boquan-fang:s2n-quic:get-ip-from-connection. s2n-quic's
new_server_sessionAPI can now add the client's remote address into the connection.Related
N/A
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.