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

iptables: Keep old rules while adding new ones #16391

Conversation

jrajahalme
Copy link
Member

@jrajahalme jrajahalme commented Jun 2, 2021

Keep old iptables rules by renaming Cilium chains so that new rules
can be added while old are still in use. Copy old TPROXY rules from
the renamed old rules. Remove the backups only after new rules have
been successfully added, but keep the copied TPROXY rules, as the
new ones may be installed considerably later.

On first initialization only copy over the DNS proxy TPROXY rules, as
other proxies can't reuse old proxy ports across restarts.

Pick the last applicable proxy port from iptables, if multiple are
present.

Remove stale TPROXY rules once the current port is known and allow
for the case where the TPROXY rule already exists (e.g., from the copy
done from old rules).

This change makes it possible to keep old rules in effect while adding
new ones without special consideration for transient rules.

Fixes: #16364

DNS proxy is now more available during Cilium restarts, including upgrades.

@jrajahalme jrajahalme requested review from a team June 2, 2021 01:26
@jrajahalme jrajahalme requested review from a team as code owners June 2, 2021 01:26
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 2, 2021
@jrajahalme jrajahalme marked this pull request as draft June 2, 2021 01:26
@jrajahalme jrajahalme force-pushed the pr/jrajahalme/datapath-retain-tproxy-iptables-rules branch from 0e2a5ea to e3d2dcd Compare June 2, 2021 03:12
@jrajahalme jrajahalme added area/proxy Impacts proxy components, including DNS, Kafka, Envoy and/or XDS servers. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Jun 2, 2021
@jrajahalme jrajahalme force-pushed the pr/jrajahalme/datapath-retain-tproxy-iptables-rules branch from e3d2dcd to a1beeaa Compare June 2, 2021 03:28
@jrajahalme jrajahalme changed the title Pr/jrajahalme/datapath retain tproxy iptables rules iptables: Keep old rules while adding new ones Jun 2, 2021
@jrajahalme jrajahalme marked this pull request as ready for review June 2, 2021 03:29
@jrajahalme jrajahalme requested a review from a team as a code owner June 2, 2021 03:29
@jrajahalme
Copy link
Member Author

test-me-please

@jrajahalme jrajahalme force-pushed the pr/jrajahalme/datapath-retain-tproxy-iptables-rules branch from a1beeaa to 447f705 Compare June 2, 2021 03:44
@jrajahalme
Copy link
Member Author

test-me-please

@jrajahalme
Copy link
Member Author

test-1.21-4.9

@jrajahalme
Copy link
Member Author

@borkmann Do you know how atomic the iptables chain rename operation is? Is there still a chance for a significant window where only some of the rules in the table have been updated with a renamed chain while others are maybe still referring to a non-existing chain? This could happen if rules internally refer to chains by name only. If the internal reference is something like a pointer to the chain then there should not be any chance for any connectivity gaps because of this?

@jrajahalme
Copy link
Member Author

test-1.21-4.9 hit by known flake #14959

@jrajahalme jrajahalme force-pushed the pr/jrajahalme/datapath-retain-tproxy-iptables-rules branch from 447f705 to 5d7cd0a Compare June 4, 2021 21:31
@jrajahalme
Copy link
Member Author

Rebased to hopefully avoid test flakes fixed in master

@jrajahalme jrajahalme force-pushed the pr/jrajahalme/datapath-retain-tproxy-iptables-rules branch from 5d7cd0a to 9ffce50 Compare June 4, 2021 21:33
@joestringer
Copy link
Member

Confirmed that the issue we're hitting in CI here is present on master, so cannot be caused purely by these changes. Let's 🚢

@joestringer joestringer merged commit 28e7e39 into cilium:master Jun 29, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot added this to Backport pending to v1.10 in 1.10.2 Jun 29, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.9 in 1.9.9 Jul 1, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.8 in 1.8.11 Jul 1, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Needs backport from master to Backport pending to v1.8 in 1.8.11 Jul 1, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.10 to Backport done to v1.10 in 1.10.2 Jul 2, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.9 to Backport done to v1.9 in 1.9.9 Jul 15, 2021
@maintainer-s-little-helper maintainer-s-little-helper bot moved this from Backport pending to v1.8 to Backport done to v1.8 in 1.8.11 Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/proxy Impacts proxy components, including DNS, Kafka, Envoy and/or XDS servers. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
No open projects
1.10.2
Backport done to v1.10
1.8.11
Backport done to v1.8
1.9.9
Backport done to v1.9
Development

Successfully merging this pull request may close these issues.

iptables TPROXY rules are removed during agent restart
8 participants