-
Notifications
You must be signed in to change notification settings - Fork 7
Support for default exposes #1198
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
Conversation
Because the follow-up commits should be based on the changes from #1198, but we just need this tiny change to get the rest to compile.
cfe7896 to
e08e39b
Compare
Because the follow-up commits should be based on the changes from #1198, but we just need this tiny change to get the rest to compile.
e08e39b to
bfc4dfe
Compare
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Extends the conversion from CRD to internal type to allow the support of default exposes. A default expose cannot contain any ip/nots or nat configuration. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Since we keep at most one config, there's no need to clear intermediate collections. Also, reorganize the code so that adding validations is clearer. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
- Forbid prefixes 0/0 or ::/0 in ip/nat/nots/as-not's in exposes - Do not allow default exposes to have ip/nat/nots/not-as Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Reorganize code so that we validate the `Peering` objects collected in Vpcs instead of the undirected `VpcPeering` objects learnt from the CRD. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Adds a method to return the set of prefixes that should be advertised for an expose. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Adapt the logic to determine prefixes to be advertised for a given peering expose. Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
bfc4dfe to
a43d269
Compare
qmonnet
left a comment
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.
I took another look at the PR today and I've got a couple more comments on the validation - nothing really blocking, though
| if self.ips.iter().any(|p| p.prefix().is_root()) { | ||
| return Err(ConfigError::Forbidden( | ||
| "Expose: root prefix as 'ip' forbidden", | ||
| )); | ||
| } | ||
| if self.nots.iter().any(|p| p.prefix().is_root()) { | ||
| return Err(ConfigError::Forbidden( | ||
| "Expose: root prefix as 'not' is forbidden", | ||
| )); | ||
| } | ||
| if let Some(nat) = &self.nat { | ||
| if nat.as_range.iter().any(|p| p.prefix().is_root()) { | ||
| return Err(ConfigError::Forbidden( | ||
| "Expose: root prefix as NAT 'as' is forbidden", | ||
| )); | ||
| } | ||
| if nat.not_as.iter().any(|p| p.prefix().is_root()) { | ||
| return Err(ConfigError::Forbidden( | ||
| "Expose: root prefix as NAT 'as-not' is forbidden", | ||
| )); | ||
| } | ||
| } |
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.
Nit: these are not for validating the default expose, should they be in a separate function named differently? (Probably doesn't matter much though)
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.
yeah, the name is not ideal. Let me think of a better one...
The type doesn't seem necessary at this time, let's remove it to help
with clarity.
[ Quentin:
Remove VpcdLookupResult from comments in flow-filter/src/tables.rs ]
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Quentin Monnet <qmo@qmon.net>
Make sure that we account for "default" VpcExpose when we retrieve the destination VPC discriminant for the packet. Internally, we don't add a prefix for the default destination into the tables, because we'd have to handle overlap to some extent. Instead, we add a per-source-prefix value to use as a fallback when no other destination prefix match. At the moment, the code assumes that each VPC accepts at most one "default" destination. Signed-off-by: Quentin Monnet <qmo@qmon.net>
Add unit test cases to validate the behaviour in the case of
default-destination VpcExpose objects. In such case, NAT must use the
relevant default destination to find what transformation rules it should
apply.
As it turns out, there is no change required in the code for NAT:
- For stateful NAT:
- We don't currently support destination NAT with stateful NAT. So
when a packet is sent to a default-destination VPC, we may apply
stateful NAT for the source as usual, and won't apply destination
NAT in the case of the default.
- When the packet comes back, we have an entry in the session table
so there's no need to look at the context from the config anyway.
- For stateless NAT, the stage does not enforce any validation on
whether packets match existing local and remote prefixes (this is the
role of the flow-filter stage instead). When we reaching the stateless
NAT stage we already know the destination VPC (also from the
flow-filter stage): if we find no matching prefix for destination NAT,
we do not NAT. Given that default-destination VPCs don't support NAT,
we're good.
Signed-off-by: Quentin Monnet <qmo@qmon.net>
Be more explicit in the stateless NAT lookups, especially if those do not provide a value. Signed-off-by: Fredi Raspall <fredi@githedgehog.com> Signed-off-by: Quentin Monnet <qmo@qmon.net>
Make sure that we do not expose overlapping prefixes to a given VPC. The only supported exception is when one of the expose is a `default` expose destination. Note: The implementation is currently rather inefficient as we have seven nested loops (counting the loop on VPCs for validation). We should look into some structure where to insert prefixes as we encounter them, like for check_peering_count(), but it's not trivial to identify overlapping prefixes (accounting for both IP prefixes and port ranges) in a structure without looping on them anyway, so we stick to the naive implementation for now. Signed-off-by: Quentin Monnet <qmo@qmon.net>
We decided to reject, for now at least, configurations where multiple "default" VpcExpose objects are exposed to a single VPC. This commit adjusts validation accordingly, and add the related unit tests. Also reject the configuration if a peering (not a VPC) contains multiple "default" expose blocks. Signed-off-by: Quentin Monnet <qmo@qmon.net>
defaultflag fabricator#1313 gets merged (?)