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

Make private Envoy sockets localhost only #24011

Merged
merged 3 commits into from Mar 22, 2023

Conversation

meyskens
Copy link
Member

@meyskens meyskens commented Feb 24, 2023

This change makes parts of Envoy that do not need public access bind to
localhost only. This was previously not possible as it could not bind
on both ipv4 and v6. In Envoy 1.24 multi listeners were added making
this improvement possible.

Depends on #23940 (merged)

Fixes a part of #23353 (there are more cilium agent ports which are not managed by envoy)

Make Envoy sockets for tproxy and the xDS API and bind to localhost only 

@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 Feb 24, 2023
Copy link
Member

@jrajahalme jrajahalme left a comment

Choose a reason for hiding this comment

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

Nice, some early comments below.

pkg/envoy/server.go Outdated Show resolved Hide resolved
pkg/envoy/server.go Outdated Show resolved Hide resolved
@meyskens meyskens added kind/cleanup This includes no functional changes. release-note/minor This PR changes functionality that users may find relevant to operating Cilium. labels Feb 24, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 24, 2023
@meyskens meyskens force-pushed the meyskens/envoy-listen-local branch 4 times, most recently from 0ebe11b to 5f5852e Compare February 27, 2023 17:15
@meyskens meyskens marked this pull request as ready for review February 28, 2023 06:19
@meyskens meyskens requested review from a team as code owners February 28, 2023 06:19
@meyskens
Copy link
Member Author

/test

@meyskens meyskens added the area/servicemesh GH issues or PRs regarding servicemesh label Mar 1, 2023
Copy link
Member

@jrajahalme jrajahalme left a comment

Choose a reason for hiding this comment

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

Small nits only. Use of local only ports on DNS proxy may warrant further discussion, though.

bpf/lib/proxy.h Outdated Show resolved Hide resolved
bpf/lib/proxy.h Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Show resolved Hide resolved
pkg/proxy/proxy_test.go Show resolved Hide resolved
@@ -361,7 +361,7 @@ func ParseResources(cecNamespace string, cecName string, anySlice []cilium_v2.XD
// Do this only after all other possible error cases.
for _, listener := range resources.Listeners {
if listener.GetAddress() == nil {
port, err := portAllocator.AllocateProxyPort(listener.Name, false)
port, err := portAllocator.AllocateProxyPort(listener.Name, false, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this meant to ever be configurable?

Copy link
Member

Choose a reason for hiding this comment

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

It kind of is already, you can specify an address and port in the Listener spec. This path is only executed when there is no address in the Listener spec, meaning that "let each Cilium Agent pick a local port". With this change that now includes the fact the locally allocated port is listened only on localhost interfaces. The locally allocated port is essentially random, so it is different on each node and is not exposed in any user facing API. Given this it would be hard to send traffic to that port from the outside of the node anyway, so listening on localhost only does not change much. Other than have one less open port on external interfaces potentially vulnerable for port scanning.

@meyskens meyskens force-pushed the meyskens/envoy-listen-local branch from 879026c to 6bf753b Compare March 20, 2023 09:05
This change makes parts of Envoy that do not need public access bind to
localhost only. This was previously not possible as it could not bind
on both ipv4 and v6. In Envoy 1.24 multi listeners were added making
this improvement possible.

Signed-off-by: Maartje Eyskens <maartje.eyskens@isovalent.com>
This change adds the ability to make proxy rules run over the local interface.
To do this it adds the underlying IP to the iptable ruleset for --on-ip
instead ot it defaulting to any ip.

Signed-off-by: Maartje Eyskens <maartje.eyskens@isovalent.com>
This change adds a lookup to the localhost IP in the tproxy
code. It will first look for a localhost socket, failing that
it will fall back to the previous behaviour of 0.0.0.0/::

Co-authored-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Maartje Eyskens <maartje.eyskens@isovalent.com>
@meyskens meyskens force-pushed the meyskens/envoy-listen-local branch from 6bf753b to e180093 Compare March 20, 2023 13:41
@jrajahalme jrajahalme added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 20, 2023
@jrajahalme
Copy link
Member

The loader area change is a trivial interface function prototype change, no point asking a review from the loader area, so marking this as ready-to-merge.

@jrajahalme jrajahalme removed the request for review from rgo3 March 20, 2023 15:56
@jrajahalme jrajahalme removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 20, 2023
@jrajahalme
Copy link
Member

jrajahalme commented Mar 20, 2023

/test

Job 'Cilium-PR-K8s-1.25-kernel-4.19' failed:

Click to show.

Test Name

K8sAgentChaosTest Connectivity demo application Endpoint can still connect while Cilium is not running

Failure Output

FAIL: Timed out after 240.000s.

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.25-kernel-4.19 so I can create one.

Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed:

Click to show.

Test Name

K8sDatapathServicesTest Checks N/S loadbalancing Tests with XDP, direct routing, Hybrid and Maglev

Failure Output

FAIL: Timed out after 240.000s.

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.26-kernel-net-next so I can create one.

@jrajahalme
Copy link
Member

Noticed ginkgo tests had not run after recent force pushes, running the tests now.

@meyskens meyskens added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Mar 22, 2023
@jrajahalme
Copy link
Member

The two test fails are for unrelated image pulling errors. Images exist but Cilium pods as in image-pull-backoff.

@borkmann borkmann merged commit e3af70e into cilium:master Mar 22, 2023
41 checks passed
@meyskens meyskens deleted the meyskens/envoy-listen-local branch March 27, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/servicemesh GH issues or PRs regarding servicemesh kind/cleanup This includes no functional changes. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants