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

FQDN L3 aware DNS proxy #9587

Merged
merged 2 commits into from
Nov 19, 2019
Merged

Conversation

raybejjani
Copy link
Contributor

@raybejjani raybejjani commented Nov 11, 2019

The DNS proxy now accounts for the target L3 selector, only allowing
requests whilelisted for that L3 selector. L4 dependencies are still
left to BPF redirection.

Backporters
I have this backported in #9616.


This change is Reviewable

@raybejjani raybejjani added kind/bug This is a bug in the Cilium logic. wip area/proxy Impacts proxy components, including DNS, Kafka, Envoy and/or XDS servers. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. labels Nov 11, 2019
@raybejjani raybejjani requested a review from a team November 11, 2019 15:43
@raybejjani raybejjani requested a review from a team as a code owner November 11, 2019 15:43
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

For a bugfix, I'm curious about whether you consider a full LPM to be a requirement or whether it's reasonable to get away with only iterating the set of prefixes currently in use (would handle most use cases like only FQDN policies, no CIDR policies).

A few other minor comments/suggestions below. In particular it would be good to see some form of reproducer in unit-test form.

pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/dns.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
@raybejjani raybejjani force-pushed the fqdn-l3-aware-proxy branch 2 times, most recently from c2bc661 to bb3c293 Compare November 13, 2019 11:30
@raybejjani raybejjani requested a review from a team as a code owner November 13, 2019 11:30
@coveralls
Copy link

coveralls commented Nov 14, 2019

Coverage Status

Coverage decreased (-0.1%) to 45.91% when pulling 09b6426 on raybejjani:fqdn-l3-aware-proxy into 5bc434d on cilium:master.

@joestringer joestringer added the release-note/bug This PR fixes an issue in a previous release of Cilium. label Nov 14, 2019
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
@raybejjani
Copy link
Contributor Author

test-me-please

@raybejjani raybejjani changed the title [wip] FQDN L3 aware DNS proxy FQDN L3 aware DNS proxy Nov 15, 2019
Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

Nice work. There's just a couple of inconsistencies in the unit testing that are confusing, could you take a fresh look at those?

I left some other minor comments as well but I don't think any of them are consequential. Assuming you fix up the unit tests (or describe what I missed), LGTM.

pkg/fqdn/dnsproxy/proxy.go Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy.go Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
pkg/fqdn/dnsproxy/proxy_test.go Outdated Show resolved Hide resolved
@raybejjani
Copy link
Contributor Author

test-me-please

Copy link
Member

@joestringer joestringer left a comment

Choose a reason for hiding this comment

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

The defer is clearly masking over an input problem, and I'm hoping that my pointer in the related comment here will resolve it.

pkg/fqdn/dnsproxy/proxy.go Outdated Show resolved Hide resolved
@raybejjani
Copy link
Contributor Author

raybejjani commented Nov 17, 2019

test-me-please (flakes)

@raybejjani
Copy link
Contributor Author

raybejjani commented Nov 17, 2019

test-me-please (passed)

@raybejjani
Copy link
Contributor Author

test-me-please

@raybejjani raybejjani requested review from joestringer and a team November 18, 2019 10:21
@raybejjani
Copy link
Contributor Author

Oops, I didn't meant to ask for another review, joestringer. Ignore me!

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.

One suggestion for a follow-up: Maybe compute selector-based rules when the policy is first injected, so that the rules would be natively shared by all the Endpoints applying the selector policy in question?

The other comment is just a nit about unused return error value, removal of which would also remove some dead code for checking the error return.

pkg/fqdn/dnsproxy/proxy.go Show resolved Hide resolved

// rejectReply is the OPCode send from the DNS-proxy to the endpoint if the
// DNS request is invalid
rejectReply int
}

// perEPAllow maps EndpointIDs to ports + selectors + rules
type perEPAllow map[uint64]portToSelectorAllow
Copy link
Member

Choose a reason for hiding this comment

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

Maybe consider tracking ports, selectors, and rules by a SecurityID instead of by EndpointID? Seems we could share the state between endpoints that have the same SecurityID here. There would be some additional complexity though due to policies being created per EP. policy.L4Filter.L7RulesPerEp might be a proper place to keep this information. Note that there is an another (wip) PR (#9486) that generalizes L7RulesPerEp a little, allowing for computed state being stored there, not just the api.L7Rules.

Visibility policies are generated specifically for the DNS proxy as
allow-all policies. The L3 selector is also setup to be a select-all,
but would crash when .Selects was invoked on it. The selector is now
safer to use, particularly as it self-identities as a wildcard selector
and skips the panicking line.

Signed-off-by: Ray Bejjani <ray@isovalent.com>
The DNS proxy now accounts for the target L3 selector and destination
port, only allowing requests whilelisted specifically for that L3/L4
pair. ipcache lookups iterate over in-use prefix lengths, which will
likely be bounded in most scenarios.
Regexpmap is also removed as the proxy was the final user.

Signed-off-by: Ray Bejjani <ray@isovalent.com>
@raybejjani
Copy link
Contributor Author

test-me-please

@raybejjani raybejjani merged commit 1121202 into cilium:master Nov 19, 2019
@raybejjani raybejjani deleted the fqdn-l3-aware-proxy branch November 19, 2019 15:02
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. kind/bug This is a bug in the Cilium logic. release-note/bug This PR fixes an issue in a previous release of Cilium. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants