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

feat(tls-route): add TLS route matching crate #3192

Merged
merged 3 commits into from
Sep 23, 2024
Merged

Conversation

zaharidichev
Copy link
Member

This PR includes a nonfunctional change that adds a TLS route-matching library.
The library works similarly to the http-route one but instead of relying on HTTP concepts
such as paths, headers, etc is specific to TLS ones (i.e. SNI).

At the moment the library is capable of matching routes based on SNIs.

Signed-off-by: Zahari Dichev <[email protected]>
@zaharidichev zaharidichev requested a review from a team as a code owner September 10, 2024 07:40
Comment on lines 11 to 14
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct SessionInfo {
pub sni: ServerName,
}
Copy link
Member

Choose a reason for hiding this comment

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

This should be moved down below the mods with the other structs. I would probably move it to directly about the find impl, so that it's defined nearest where it is used.

It would also be good to include a comment a brief comment describing that this is intended to capture the routing metadata of a proxied/unterminated server-side TLS connection.

/// A list of session matchers, *any* of which may apply.
///
/// The "best" match is used when comparing rules.
pub matches: Vec<r#match::MatchSession>,
Copy link
Member

Choose a reason for hiding this comment

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

So it seems that we have both SNI matching at the Route level and also the Rule level. If we're going to include MatchSni at the Route level, then we probably want MatchSession to be empty for now. Otherwise, we probably want to omit the sni matching at the Route level.

I don't have enough information to suggest one or the other. I don't really see any harm in it being defined at the Route level (since this matches the gateway spec). Given that the spec does not include any rule based matches currently, I'm not sure of a good reason to include SNI matches in rules.

use linkerd_tls::ServerName;

#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub enum MatchSni {
Copy link
Member

Choose a reason for hiding this comment

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

It's probably worth documenting SNI matching semantics with some of the Gateway API's verbiage.

Signed-off-by: Zahari Dichev <[email protected]>
Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

This is looking pretty good to me!

It would probably be good to have some tests cases for sessions that do not match any routes. For example, it would be good to explore the corner cases like a suffix match like *.test.example.com and a session for test.example.com. What other subtleties should we consider?

Signed-off-by: Zahari Dichev <[email protected]>
@olix0r olix0r changed the title policy: add TLS route matching crate feat(tls-route): add TLS route matching crate Sep 13, 2024
@olix0r
Copy link
Member

olix0r commented Sep 13, 2024

When merging, please ensure that the commit message includes an accurate summary of the change like that in the PR description.

@zaharidichev zaharidichev merged commit 7cb7467 into main Sep 23, 2024
15 checks passed
@zaharidichev zaharidichev deleted the zd/tls-routes branch September 23, 2024 05:58
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