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(kuma-dp): fix conntrack collisions #3459

Merged
merged 5 commits into from
Jan 20, 2022

Conversation

johnharris85
Copy link
Contributor

Summary

When there are a lot of DNS queries and a smaller set of ephemeral ports, conntrack collisions could cause DNS traffic to bypass the mesh. The original fix is in Istio's transparentproxy but came in after we vendored that code.

Original fix here: (istio/istio#33572).

I also pulled across the Istio package's test changes but it looks like we skip tests for this vendored package anyway? Should we bring these back in?

Should probably also backport this.

Full changelog

Implement conntrack zones in the iptables rules based on a fix in Istio

Issues resolved

N / A

Documentation

N / A

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

  • Update UPGRADE.md with any steps users will need to take
    when upgrading.
  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

Signed-off-by: John Harris john.harris@konghq.com

@johnharris85 johnharris85 requested a review from a team as a code owner December 9, 2021 15:32
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2021

Codecov Report

Merging #3459 (8770c29) into master (1e83dae) will increase coverage by 0.03%.
The diff coverage is 76.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3459      +/-   ##
==========================================
+ Coverage   50.72%   50.76%   +0.03%     
==========================================
  Files         920      920              
  Lines       56610    56691      +81     
==========================================
+ Hits        28717    28778      +61     
- Misses      25594    25612      +18     
- Partials     2299     2301       +2     
Impacted Files Coverage Δ
...entproxy/istio/tools/istio-iptables/pkg/cmd/run.go 54.42% <76.54%> (+4.18%) ⬆️
pkg/mads/v1/client/client.go 41.25% <0.00%> (-2.50%) ⬇️
api/observability/v1/mads.pb.go 34.53% <0.00%> (-1.04%) ⬇️
pkg/plugins/runtime/gateway/route/sorter.go 66.66% <0.00%> (ø)
pkg/plugins/leader/postgres/leader_elector.go 100.00% <0.00%> (+6.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e83dae...8770c29. Read the comment docs.

Vendors this fix (istio/istio#33572) from Istio

Signed-off-by: John Harris <john.harris@konghq.com>
@johnharris85 johnharris85 changed the title Fix conntrack collisions fix(kuma-dp): fix conntrack collisions Dec 9, 2021
@lahabana
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Dec 16, 2021

update

✅ Branch has been successfully updated

@lahabana
Copy link
Contributor

@johnharris85 thanks! Do you want to look at reenabling the tests?

@bartsmykla
Copy link
Contributor

@johnharris85 Hi John, as we discussed yesterday I want to help with finishing this PR. Would you be able to allow me to contribute to your fork please?

@bartsmykla
Copy link
Contributor

As our e2e tests for universal are done from inside of a docker
container, to make the networking work, we are bridging docker
network to the host, which results in additional iptables rules
inside every container within this network. Problem with these
rules is that it's doing some NAT'ing for DNS udp datagrams with
addition of randomly picked (during the container startup) port.
It's problematic for this conntrack change as it works inside
the raw table and among others PREROUTING chain and expects
the datagrams from known port (53), which the earlier described
NAT'ing is changing. This probably could be fixed by rethinking
some of the rules, but as it's an edge case, after consultation
with the team I decided it's not worth the time needed to properly
solve it and instead I introduced to a --skip-dns-conntrack-zone-split
flag for kumactl install transparent-proxy, which allows us to
skip attaching the conntrack-collision iptables rules. This change
was necessary for making some of the tests to work (univeral).

I also fixed the code to include our flag for capturing all dns
traffic and instead of hardcoding port 15053, to use the one
from the configuration.

As our e2e tests for universal are done from inside of a docker
container, to make the networking work, we are bridging docker
network to the host, which results in additional iptables rules
inside every container within this network. Problem with these
rules is that it's doing some NAT'ing for DNS udp datagrams with
addition of randomly picked (during the container startup) port.
It's problematic for this conntrack change as it works inside
the `raw` table and among others `PREROUTING` chain and expects
the datagrams from known port (53), which the earlier described
NAT'ing is changing. This probably could be fixed by rethinking
some of the rules, but as it's an edge case, after consultation
with the team I decided it's not worth the time needed to properly
solve it and instead I introduced to a `--skip-dns-conntrack-zone-split`
flag for `kumactl install transparent-proxy`, which allows us to
skip attaching the conntrack-collision iptables rules. This change
was necessary for making some of the tests to work (univeral).

I also fixed the code to include our flag for capturing all dns
traffic and instead of hardcoding port `15053`, to use the one
from the configuration.

Signed-off-by: Bart Smykla <bartek@smykla.com>
@bartsmykla bartsmykla merged commit 45a6d5a into kumahq:master Jan 20, 2022
@bartsmykla bartsmykla deleted the fix/conntrack-zones branch January 20, 2022 06:08
mergify bot pushed a commit that referenced this pull request Jan 20, 2022
* fix(kuma-dp): fix conntrack collisions

Vendors this fix (istio/istio#33572) from Istio

Signed-off-by: John Harris <john.harris@konghq.com>

* chore(*): adjust changes to kuma environment

As our e2e tests for universal are done from inside of a docker
container, to make the networking work, we are bridging docker
network to the host, which results in additional iptables rules
inside every container within this network. Problem with these
rules is that it's doing some NAT'ing for DNS udp datagrams with
addition of randomly picked (during the container startup) port.
It's problematic for this conntrack change as it works inside
the `raw` table and among others `PREROUTING` chain and expects
the datagrams from known port (53), which the earlier described
NAT'ing is changing. This probably could be fixed by rethinking
some of the rules, but as it's an edge case, after consultation
with the team I decided it's not worth the time needed to properly
solve it and instead I introduced to a `--skip-dns-conntrack-zone-split`
flag for `kumactl install transparent-proxy`, which allows us to
skip attaching the conntrack-collision iptables rules. This change
was necessary for making some of the tests to work (univeral).

I also fixed the code to include our flag for capturing all dns
traffic and instead of hardcoding port `15053`, to use the one
from the configuration.

Signed-off-by: Bart Smykla <bartek@smykla.com>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Bart Smykla <bartek@smykla.com>
(cherry picked from commit 45a6d5a)
bartsmykla pushed a commit that referenced this pull request Jan 20, 2022
* fix(kuma-dp): fix conntrack collisions

Vendors this fix (istio/istio#33572) from Istio

Signed-off-by: John Harris <john.harris@konghq.com>

* chore(*): adjust changes to kuma environment

As our e2e tests for universal are done from inside of a docker
container, to make the networking work, we are bridging docker
network to the host, which results in additional iptables rules
inside every container within this network. Problem with these
rules is that it's doing some NAT'ing for DNS udp datagrams with
addition of randomly picked (during the container startup) port.
It's problematic for this conntrack change as it works inside
the `raw` table and among others `PREROUTING` chain and expects
the datagrams from known port (53), which the earlier described
NAT'ing is changing. This probably could be fixed by rethinking
some of the rules, but as it's an edge case, after consultation
with the team I decided it's not worth the time needed to properly
solve it and instead I introduced to a `--skip-dns-conntrack-zone-split`
flag for `kumactl install transparent-proxy`, which allows us to
skip attaching the conntrack-collision iptables rules. This change
was necessary for making some of the tests to work (univeral).

I also fixed the code to include our flag for capturing all dns
traffic and instead of hardcoding port `15053`, to use the one
from the configuration.

Signed-off-by: Bart Smykla <bartek@smykla.com>

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Bart Smykla <bartek@smykla.com>
(cherry picked from commit 45a6d5a)

Co-authored-by: John Harris <johnharris85@users.noreply.github.com>
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.

4 participants