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

Resolve named ports for DNS policies #29023

Merged

Conversation

jrajahalme
Copy link
Member

@jrajahalme jrajahalme commented Nov 7, 2023

Implement l4Policy wrapper with resolved named port so that proxy package can get the actual resolved named port number when calling GetPort. Previously, if policy used a named port, GetPort returned 0.

GetPort is only used for DNS proxy function UpdateAllowed. This means that using a named port for a DNS policy destination port likely has not functioned as intended. Since DNS port is typically 53, it seems likely that named ports would not be used in DNS policies in practice.

Fixes: #11092

Named ports in DNS policies are now resolved correctly.

@jrajahalme jrajahalme requested a review from a team as a code owner November 7, 2023 10:08
@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 Nov 7, 2023
@jrajahalme jrajahalme self-assigned this Nov 7, 2023
@jrajahalme jrajahalme added release-note/minor This PR changes functionality that users may find relevant to operating Cilium. sig/policy Impacts whether traffic is allowed or denied based on user-defined policies. and removed dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Nov 7, 2023
@jrajahalme
Copy link
Member Author

/test

@jrajahalme
Copy link
Member Author

/test

@jrajahalme jrajahalme force-pushed the endpoint-resolve-named-ports-for-redirects branch from 8bb76fd to 0e1e44c Compare November 9, 2023 01:58
@jrajahalme
Copy link
Member Author

rebased for CI fixes

@jrajahalme
Copy link
Member Author

/test

@jrajahalme jrajahalme added the kind/bug This is a bug in the Cilium logic. label Nov 13, 2023
@jrajahalme jrajahalme force-pushed the endpoint-resolve-named-ports-for-redirects branch from 0e1e44c to 6f603da Compare November 14, 2023 10:33
@jrajahalme
Copy link
Member Author

Added comments suggested by @squeed here.

@jrajahalme jrajahalme force-pushed the endpoint-resolve-named-ports-for-redirects branch from 6f603da to 19c78bc Compare November 14, 2023 10:38
@jrajahalme
Copy link
Member Author

/test

Copy link
Member

@aditighag aditighag left a comment

Choose a reason for hiding this comment

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

I don't have much context. Perhaps it's best reviewed by someone from the policy team. /cc @cilium/sig-policy

Since DNS port is typically 53, it seems likely that named ports would not be used in DNS policies in practice.

I don't quite follow this. K8s mandates named ports when there are more than one port defined in a pod spec.

@jrajahalme jrajahalme changed the title Endpoint resolve named ports for redirects Resolve named ports for DNS policies Nov 17, 2023
@jrajahalme
Copy link
Member Author

Since DNS port is typically 53, it seems likely that named ports would not be used in DNS policies in practice.

I don't quite follow this. K8s mandates named ports when there are more than one port defined in a pod spec.

I was referring to use in CNPs, which for a long time did not support named ports at all, so all examples of DNS policies use the port number 53.

@jrajahalme jrajahalme requested a review from aanm November 17, 2023 12:59
Copy link
Member

@aanm aanm left a comment

Choose a reason for hiding this comment

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

Just one tiny suggestion, I'm fine either case.

pkg/endpoint/bpf.go Outdated Show resolved Hide resolved
@maintainer-s-little-helper maintainer-s-little-helper bot added ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Nov 18, 2023
@aanm aanm removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 18, 2023
Copy link
Member

@christarazi christarazi left a comment

Choose a reason for hiding this comment

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

LGTM, I agree with @aanm's suggestion which simplifies the code.

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 20, 2023
@christarazi christarazi removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 20, 2023
@jrajahalme jrajahalme force-pushed the endpoint-resolve-named-ports-for-redirects branch from 19c78bc to c9c6a16 Compare November 21, 2023 10:30
Adding more tests fails due to missing selector cache notifier mock and
leaking of endpoint identities in a global manager between tests. Address
these and also remove unnecessary logging.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Implement l4Policy wrapper with resolved named port so that proxy package
can get the actual resolved named port number when calling
GetPort(). Previously, if policy used a named port, GetPort returned 0.

GetPort() is only used for DNS proxy function UpdateAllowed(). This means
that using a named port for a DNS policy destination port likely has not
functioned as intended. Since DNS port is typically 53, it seems likely
that named ports are not used in DNS policies.

Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
@jrajahalme jrajahalme force-pushed the endpoint-resolve-named-ports-for-redirects branch from c9c6a16 to fdbca05 Compare November 21, 2023 10:31
@jrajahalme
Copy link
Member Author

/test

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Nov 21, 2023
@christarazi christarazi merged commit 10f04fd into cilium:main Nov 21, 2023
61 checks passed
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 1, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 4, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 5, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 6, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 12, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
jrajahalme added a commit to jrajahalme/cilium that referenced this pull request Dec 12, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
github-merge-queue bot pushed a commit that referenced this pull request Dec 19, 2023
Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: #29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
pippolo84 pushed a commit to pippolo84/cilium that referenced this pull request Jan 2, 2024
[ upstream commit a573bb4 ]

Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: cilium#29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
dylandreimerink pushed a commit that referenced this pull request Jan 12, 2024
[ upstream commit a573bb4 ]

Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: #29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
@jrajahalme jrajahalme added the needs-backport/1.15 This PR / issue needs backporting to the v1.15 branch label Jan 24, 2024
@joamaki joamaki mentioned this pull request Jan 30, 2024
28 tasks
@joamaki joamaki added backport-pending/1.15 The backport for Cilium 1.15.x for this PR is in progress. and removed needs-backport/1.15 This PR / issue needs backporting to the v1.15 branch backport-pending/1.15 The backport for Cilium 1.15.x for this PR is in progress. labels Jan 30, 2024
sayboras pushed a commit that referenced this pull request Jun 10, 2024
[ upstream commit a573bb4 ]

Commit 10f04fd (endpoint: Resolve named
ports for redirects) fixed redirect creation for L7 policies using a
named port, but failed to use the resolved destination port also in proxy
stats. This commit does that.

Fixes: #29023
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
Signed-off-by: Gilberto Bertin <jibi@cilium.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. 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. 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