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

Correctly report TLS handshake when TCP Fast Open is enabled #1970

Merged
merged 3 commits into from
Dec 2, 2021

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Nov 29, 2021

Motivation:

When TCP Fast Open socket option is enabled and available by the OS,
client sends ClientHello message with the initial TCP handshake. We
should trigger onSecurityHandshake() earlier in this case and give
users another callback to see when the TCP handshake completes.

Modifications:

  • Add ConnectionObserver#onTransportHandshakeComplete();
  • Improve tests to verity new callback;
  • Adjust ConnectionObserverInitializer to trigger
    onSecurityHandshake() earlier when TCP Fast Open is enabled and
    available;

Result:

Users can observe TCP and TLS handshake behavior correctly when
Fast Open is used.

Motivation:

When TCP Fast Open socket option is enabled and available by the OS,
client sends `ClientHello` message with the initial TCP handshake. We
should trigger `onSecurityHandshake()` earlier in this case and give
users another callback to see when the TCP handshake completes.

Modifications:

- Add `ConnectionObserver#onTcpHandshakeComplete()`;
- Improve tests to verity new callback;
- Adjust `ConnectionObserverInitializer` to trigger
`onSecurityHandshake()` earlier when TCP Fast Open is enabled and
available;

Result:

Users can observe TCP and TLS handshake behavior correctly when
Fast Open is used.
/**
* Callback when a TCP handshake completes.
*/
default void onTcpHandshakeComplete() {
Copy link
Member

@Scottmitch Scottmitch Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend avoid using tcp at this level bcz we could use the same abstractions for other protocols (udp, ..). Netty uses channelActive terminology and we could use something similar here (e.g. onActive, onConnectionActive, ..)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, changed it to onTransportHandshakeComplete(). Debated with myself if this callback really necessary or not. Discussed with @tkountis and he convinced me that it's a lot easier to understand API and events sequencing of the ConnectionObserver if we have it. Thanks for discussion!

@idelpivnitskiy idelpivnitskiy merged commit 2e8b4a4 into apple:main Dec 2, 2021
@idelpivnitskiy idelpivnitskiy deleted the fast-open branch December 2, 2021 16:21
idelpivnitskiy added a commit that referenced this pull request Dec 2, 2021
Motivation:

When TCP Fast Open socket option is enabled and available by the OS,
client sends `ClientHello` message with the initial TCP handshake. We
should trigger `onSecurityHandshake()` earlier in this case and give
users another callback to see when the TCP handshake completes.

Modifications:

- Add `ConnectionObserver#onTransportHandshakeComplete()`;
- Improve tests to verity new callback;
- Adjust `ConnectionObserverInitializer` to trigger
`onSecurityHandshake()` earlier when TCP Fast Open is enabled and
available;

Result:

Users can observe TCP and TLS handshake behavior correctly when
Fast Open is used.
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Dec 3, 2021
Motivation:

apple#1969 and apple#1970 introduced two new callbacks for `ConnectionObserver`
and added default impl for backward compatibility. We can clean up API
in 0.42.

Modifications:

- Remove default impl for `onTransportHandshakeComplete()` and
`streamIdAssigned`;

Result:

No default callback impls.
idelpivnitskiy added a commit that referenced this pull request Dec 3, 2021
Motivation:

#1969 and #1970 introduced two new callbacks for `ConnectionObserver`
and added default impl for backward compatibility. We can clean up API
in 0.42.

Modifications:

- Remove default impl for `onTransportHandshakeComplete()` and
`streamIdAssigned`;

Result:

No default callback impls.
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Dec 14, 2021
Motivation:

apple#1970 removed a public ctor from `ConnectionObserverInitializer`. We
should revert it back to make the class backward compatible.

Modifications:

- Revert `ConnectionObserverInitializer(ConnectionObserver, boolean)`;

Result:

`ConnectionObserverInitializer` is backward compatible.
bondolo pushed a commit that referenced this pull request Dec 14, 2021
Motivation:

#1970 removed a public ctor from `ConnectionObserverInitializer`. We
should revert it back to make the class backward compatible.

Modifications:

- Revert `ConnectionObserverInitializer(ConnectionObserver, boolean)`;

Result:

`ConnectionObserverInitializer` is backward compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants