Skip to content

matchers: add server name xds matcher#20652

Closed
kyessenov wants to merge 11 commits into
envoyproxy:mainfrom
kyessenov:server_name_xds_matcher
Closed

matchers: add server name xds matcher#20652
kyessenov wants to merge 11 commits into
envoyproxy:mainfrom
kyessenov:server_name_xds_matcher

Conversation

@kyessenov

Copy link
Copy Markdown
Contributor

Commit Message: Implements server name matcher in Envoy, as needed by the listener unified matcher for matching SNI.
Additional Description:
Risk Level: low
Testing: unit
Docs Changes: yes
Release Notes: no

@kyessenov kyessenov requested a review from mattklein123 as a code owner April 4, 2022 16:26
@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Apr 4, 2022
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @phlax

🐱

Caused by: #20652 was opened by kyessenov.

see: more, trace.

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
namespace Common {
namespace Matcher {

class NetworkTrieMatcherFactory : public TrieMatcherFactoryBase<Network::MatchingData> {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why should these class definitions be moved to .cc?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For consistency. It doesn't seem to be useful to export these in a header.

@lambdai lambdai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally LGTM. I didn't look into the scary match...

Comment on lines +75 to +77
.. _extension_envoy.matching.custom_matchers.domain_matcher:

* :ref:`Server name matcher <envoy_v3_api_msg_.xds.type.matcher.v3.ServerNameMatcher>`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you clarify that this matcher is supposed to match SNI?
Particularly, the wildcard matcher does not apply to wildcard cert "*.example.com"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is not only SNI, it would work for virtual host as well. I'll make it clear that it matches domains, not wildcards.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aha, yes, virtual host can reuse this matcher!

typed_config:
"@type": type.googleapis.com/google.protobuf.StringValue
custom_match:
name: ip_matcher

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

server_name_matcher and below :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

using ::Envoy::Matcher::OnMatch;

/**
* A "compressed" trie node with domain parts as edge values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does compress mean? Can two parts be compressed in a single node?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Compressed as in it's not a regular trie with letters as alphabet. It doesn't compress two domain parts. Added a little diagram.

Comment thread source/extensions/common/matcher/domain_matcher.h
Comment thread source/extensions/common/matcher/domain_matcher.cc Outdated
Signed-off-by: Kuat Yessenov <kuat@google.com>
Comment thread source/extensions/common/matcher/domain_matcher.cc Outdated
Comment on lines +75 to +77
.. _extension_envoy.matching.custom_matchers.domain_matcher:

* :ref:`Server name matcher <envoy_v3_api_msg_.xds.type.matcher.v3.ServerNameMatcher>`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Aha, yes, virtual host can reuse this matcher!

}
if (matched.match_state_ == MatchState::MatchComplete && matched.result_) {
return {MatchState::MatchComplete, OnMatch<DataType>{matched.result_, nullptr}};
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to escape the if (on_match) { block w/o return ?
In which case?

If the answer is yes, should on_match degrade from exact_on_match to prefix_on_match ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it can have nested matchers so the match can complete without a result.
It does degrade, because it traverses the parent_prefix_ edges. E.g. it'll try wider and wider patters by going from the node to the root.

Signed-off-by: Kuat Yessenov <kuat@google.com>
Signed-off-by: Kuat Yessenov <kuat@google.com>
@phlax

phlax commented Apr 7, 2022

Copy link
Copy Markdown
Member

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #20652 (comment) was created by @phlax.

see: more, trace.

@zuercher

Copy link
Copy Markdown
Member

ping @phlax

@phlax phlax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this lgtm, but its a bit outside my competence to land

@mattklein123 can i pass this over to you as a CODEOWNER

@mattklein123 mattklein123 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks at a high level LGTM to ship and iterate. A few small doc comments:

  1. Please add a release note
  2. Can you add an example somewhere so people have something to crib from?

Thank you!

/wait

@phlax phlax removed their assignment May 2, 2022
@github-actions

github-actions Bot commented Jun 1, 2022

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 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!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Jun 1, 2022
@github-actions

github-actions Bot commented Jun 8, 2022

Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Jun 8, 2022
@kyessenov kyessenov reopened this Jun 8, 2022
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Jun 15, 2022
@kyessenov

Copy link
Copy Markdown
Contributor Author

Still want to get this done...

@kyessenov kyessenov reopened this Jun 15, 2022
@github-actions github-actions Bot removed the stale stalebot believes this issue/PR has not been touched recently label Jun 16, 2022
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had activity in the last 30 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!

@github-actions github-actions Bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 16, 2022
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions Bot closed this Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies stale stalebot believes this issue/PR has not been touched recently waiting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants