-
Notifications
You must be signed in to change notification settings - Fork 3.4k
policy: Add Port Range Support for Policies Part 2/3 #32675
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
policy: Add Port Range Support for Policies Part 2/3 #32675
Conversation
d65985c
to
bf32472
Compare
bf32472
to
d16e24a
Compare
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endpoint changes lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hubble changes LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API changes LGTM!
pkg/k8s/apis/cilium.io/client/crds/v2/ciliumclusterwidenetworkpolicies.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit question, otherwise LGTM! 🫰
8e8ff17
to
2ea1f3a
Compare
- Add PortMask to MapKey structure, to make "0" the default value. - Use PortRangeToMaskedPorts when creating keys for toMapState in L4 policies. - Update maps/policy to account for mask. - Introduce range logic into mapstate. - Fix minor IsSupersetOf test issues. - Add range unit tests to distillery tests. Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Deny insertion has, heretofore, handled duplicate deny entries by only checking for wildcard port protocol entries as a way to prevent duplicate deny entries or by ignoring them completely as duplicate deny entries did not cause any problems. This does not work with the more precise de-duplication logic required by port ranges, because overlapping ranges is a new dimension of de-duplication that has to be enforced. Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
Signed-off-by: Nate Sweet <nathanjsweet@pm.me>
2ea1f3a
to
665f290
Compare
/test |
This PR prepares the policy engine for adding port ranges
by enabling the underlying userspace cache to calculate
insertion, deletion, and lookups with port ranges, as well
as adding unit tests to ensure that the logic works. It does
not add support for adding policy port ranges at the API
level that will be addressed in the final PR.
The Policy CRD is modified by this PR without
supporting port ranges at the policy repository level
(this will be added in the final PR). This has to be done
because the "PortProtocol" struct is shared by both
the CRD (aka the API level) and the L4Filter struct
(aka the cache level).
See commits for details.