Skip to content

ICMP code/type firewall filters #759

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

FelixMcFelix
Copy link
Collaborator

@FelixMcFelix FelixMcFelix commented May 19, 2025

This PR changes how Oxide VPC firewall protocol matches are specified, such that we can now filter on (ranges of) ICMP types/codes. This allows Nexus and instances to allow limited inbound ICMP traffic where needed to enable correct operation of Path MTU discovery.

One of the main pieces which needed to be accounted for here was the shape of an InnerFlowId when handling ICMP traffic. Before, both the source_port and destination_port would be used to pull double-duty as storage for ICMP echo IDs. Having this information in the flowkey in some form is necessary to enable outbound ping in a SNAT context. This works great in a world where we treat all ICMP homogenously. However, this would enable situations where we create an pathway for all subsequent ICMP flavours from the remote host.

  • InnerFlowId now contains a [u16; 2] which is reinterpreted based on the protocol. For TCP/UDP, these are just the ports as before. In ICMP, we have the type/code/echo_id.
  • mirrored flow IDs now behave a bit more carefully in this regard. ICMP(v6) echo request/reply change the expected type value at this step and keep the same echo_id in place.

While I've been in this code, I've taken the opportunity to summarise port matches for more typical firewall rules, since that was an O(n_values) operation in the slowpath.

Closes #730.
Closes #468.

@FelixMcFelix FelixMcFelix marked this pull request as draft May 19, 2025 14:10
@FelixMcFelix FelixMcFelix added this to the 16 milestone May 27, 2025
@FelixMcFelix FelixMcFelix changed the title WIP: ICMP code/type firewall filters ICMP code/type firewall filters May 27, 2025
@FelixMcFelix FelixMcFelix marked this pull request as ready for review May 27, 2025 19:29
Base automatically changed from optehdl-cleanup to master May 29, 2025 12:49
This is encoded using the same `Match` type as before, which captures
ranges a bit more succintly.

Also applies the same range matches to normal ports, which should
greatly simplify huge ranges added in the control plane...
One of the side effects of wanting to filter on ICMP type is that flow
IDs need to match that level of specificity. With the old FlowId design,
we get *ICMP* and that's it, with the inner ID of an echo paylad added
in occasionally. This can lead to fun cases like an allowed ICMP DU
opening the door for *all* ICMP packets from that remote host.

What we're doing now is providing access to the same two `u16`s in
different contexts via `l4_info`/`_mut`, which lets us store the
type/code in the source port field (cast as two `u8`s). This does need
us to formalise some things we'd taken for granted, e.g., the `mirror`
flow for an ICMP echo/request reply needs to also change out the
expected type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant