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

fix(meshpassthrough): disable tls and http inspector for mysql protocol #12839

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lukidzi
Copy link
Contributor

@lukidzi lukidzi commented Feb 12, 2025

Motivation

When trying to communicate with MySQL, the user wants to enable communication with the database. Unfortunately, the MySQL protocol is slightly different, and the usual method of configuring filter chains does not work when using MeshPassthrough.

Implementation information

  • Added original_dst listener filter
  • Added a protocol mysql which works only with CIDR/IP and requires port since we need to disable tls_inspector and http_inspector listener filters for the port
  • Mysql protocol creates a tcp_proxy but with with disabled listener filters
  • Added test

Why added mysql protocol and not just disable on ports with TCP protocol?

The user may have rules with HTTP traffic and TCP traffic on the same port matching different IP. example: tls matching on port 8080(IP: 192.168.1.1) and TCP matching on 8080 (IP: 172.1.1.1), that would disable TLS inspector on the port 8080 and wouldn't match

Supporting documentation

https://dev.mysql.com/doc/dev/mysql-server/8.4.3/page_protocol_connection_phase_packets.html
envoyproxy/envoy#21044

@lukidzi lukidzi requested a review from a team as a code owner February 12, 2025 16:40
Copy link
Contributor

Reviewer Checklist

🔍 Each of these sections need to be checked by the reviewer of the PR 🔍:
If something doesn't apply please check the box and add a justification if the reason is non obvious.

  • Is the PR title satisfactory? Is this part of a larger feature and should be grouped using > Changelog?
  • PR description is clear and complete. It Links to relevant issue as well as docs and UI issues
  • This will not break child repos: it doesn't hardcode values (.e.g "kumahq" as an image registry)
  • IPv6 is taken into account (.e.g: no string concatenation of host port)
  • Tests (Unit test, E2E tests, manual test on universal and k8s)
    • Don't forget ci/ labels to run additional/fewer tests
  • Does this contain a change that needs to be notified to users? In this case, UPGRADE.md should be updated.
  • Does it need to be backported according to the backporting policy? (this GH action will add "backport" label based on these file globs, if you want to prevent it from adding the "backport" label use no-backport-autolabel label)

Signed-off-by: Lukasz Dziedziak <[email protected]>
@lukidzi lukidzi added this to the 2.10.x milestone Feb 12, 2025
@lukidzi lukidzi changed the title fix(meshpassthrough): communicate with mysql fix(meshpassthrough): disable tls and http inspector for TCP protocol Feb 12, 2025
@lukidzi lukidzi changed the title fix(meshpassthrough): disable tls and http inspector for TCP protocol fix(meshpassthrough): disable tls and http inspector for mysql protocol Feb 12, 2025
@jijiechen jijiechen self-requested a review February 13, 2025 03:41
Copy link
Contributor

@slonka slonka left a comment

Choose a reason for hiding this comment

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

One Q

@@ -52,6 +52,9 @@ func validateDefault(conf Conf) validators.ValidationError {
}
uniqueDomains := map[portProtocol]map[string]bool{}
for i, match := range conf.AppendMatch {
if match.Protocol == MysqlProtocol && match.Port == nil {
verr.AddViolationAt(validators.RootedAt("appendMatch").Index(i).Field("port"), "port must be defined for Mysql protocol")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: usual spelling is MySQL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We lowercase each protocol so we should not make an exception for MySQL https://github.com/kumahq/kuma/blob/master/pkg/core/resources/apis/mesh/dataplane_helpers.go#L23.

@@ -370,6 +370,9 @@ resources:
statPrefix: meshpassthrough_http_80
name: meshpassthrough_http_80
listenerFilters:
- name: envoy.filters.listener.original_dst
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this original dest filter required always?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://www.envoyproxy.io/docs/envoy/latest/configuration/listeners/listener_filters/original_dst_filter#linux. Previously, I overlooked this filter because our TLS and HTTP inspectors were handling everything correctly. However, after disabling the TLS/HTTP filters, matching stopped working, so I realized that the original_dst_filter was missing. I don’t think we need to disable it in other scenarios.

@lukidzi lukidzi requested a review from slonka February 17, 2025 10:58
@lukidzi lukidzi self-assigned this Feb 17, 2025
@jijiechen
Copy link
Member

jijiechen commented Feb 18, 2025

Looks good to me, and I think this needs to be discussed/reviewed by extended members as it introduces a new protocol and touches many files.

Signed-off-by: Lukasz Dziedziak <[email protected]>
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.

3 participants