Skip to content

[multicast] prevent VLAN translation via match key enforcement#195

Merged
zeeshanlakhani merged 9 commits intomainfrom
vlan-translation
Mar 10, 2026
Merged

[multicast] prevent VLAN translation via match key enforcement#195
zeeshanlakhani merged 9 commits intomainfrom
vlan-translation

Conversation

@zeeshanlakhani
Copy link
Contributor

@zeeshanlakhani zeeshanlakhani commented Jan 22, 2026

This adds VLAN-aware NAT ingress matching to prevent cross-VLAN translation. Previously, a packet arriving with VLAN 100 destined to a multicast group configured for VLAN 200 would be NAT encapsulated and forwarded, effectively translating the packet to the wrong customer's network.

NAT ingress table matching (mcast_nat.rs, mod.rs):

  • Add Ipv4VlanMatchKey and Ipv6VlanMatchKey that match on destination address, VLAN header validity, and VLAN ID
  • Each group installs a single NAT entry with an exact VLAN match key. Decapsulated Geneve packets never reach the NatIngress tables (guarded by !hdr.geneve.isValid()), so a separate untagged entry is unnecessary.
  • Packets with the wrong VLAN miss the entry and are not NAT encapsulated

Multicast router VLAN handling (sidecar.p4):

  • forward_vlan(vlan_id) action re-adds the group's configured VLAN on egress
  • Fix MulticastRouter4 using IPv6 ICMP error codes (ICMP6_DST_UNREACH) instead of IPv4 (ICMP_DEST_UNREACH)

Rollback changes:

  • Remove dead NAT rollback branches for internal groups (no NAT entries)
  • Add rollback support for VLAN changes in NAT and route tables

…tering

Underlay changes:
- Restrict internal multicast from admin/site/org scoped (ff04, ff05, ff08)
  to just Omicron's reserved subnet (ff04::/64). These underlay addresses are
  made unique in Omicron.
- Rename `AdminScopedIpv6` to `UnderlayMulticastIpv6`.
- Simplify P4 to only match ff04::/64.
- Use omicron-common multicast constants for validation.

Source filtering changes:
- Replace IpSrc::Subnet with IpSrc::Any for any-source matching.
- Change IPv6 source filter from exact to LPM match.
- Allow source filters on ASM groups (previously SSM-only).

API changes:
- API v5 adds IpSrc::Any for ASM source filtering.
- API v6 enforces strict underlay subnet validation.
Fixes #107.

Stacked on #189.

This adds VLAN-aware NAT ingress matching to prevent cross-VLAN translation.
Previously, a packet arriving with VLAN 100 destined to a multicast group
configured for VLAN 200 would be NAT encapsulated and forwarded, effectively
translating the packet to the wrong customer's network.

NAT ingress table matching (mcast_nat.rs, mod.rs):
- Add Ipv4VlanMatchKey and Ipv6VlanMatchKey that match on destination address,
  VLAN header validity, and VLAN ID
- For groups with VLAN, install two entries: untagged (for decapsulated Geneve
  from underlay) and correctly tagged (for customer packets)
- Packets with the wrong VLAN miss both entries and are not NAT encapsulated

Multicast router VLAN handling (sidecar.p4):
- Strip incoming VLAN tag before routing lookup in MulticastRouter4/6
- forward_vlan action re-adds the group's configured VLAN on egress
- Prevents unintended VLAN translation at the routing stage

Rollback changes:
- Remove dead NAT rollback branches for internal groups (no NAT entries)
- Add rollback support for VLAN changes in NAT and route tables

Counter fix:
- The underlay multicast counter condition was unreachable for packets tagged
  MULTICAST_TAG_UNDERLAY_EXTERNAL that were not decapped. The check for
  == MULTICAST_TAG_UNDERLAY excluded these packets, causing them to fall
  through to the external counter.

Pull Request: #194
@zeeshanlakhani zeeshanlakhani self-assigned this Feb 19, 2026
…ation_ids

This includes some cleanup as well.
Base automatically changed from zl/admin-scope-oxnet to main February 26, 2026 12:07
Decapsulated Geneve packets never reach the NatIngress tables due to the
outermost !hdr.geneve.isValid() check, so the dual-entry approach (untagged +
tagged) per VLAN group is unnecessary. Each group now installs a single NAT
entry with an exact VLAN match key.

This also contains a fix for MulticastRouter4 (in P4) using IPv6 ICMP error codes
(ICMP6_DST_UNREACH) instead of IPv4 ones (ICMP_DEST_UNREACH), and removes redundant
entry-count assertions from VLAN lifecycle tests.
@zeeshanlakhani
Copy link
Contributor Author

@FelixMcFelix updated.

Copy link
Contributor

@FelixMcFelix FelixMcFelix left a comment

Choose a reason for hiding this comment

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

I'm concerned about IPV4_LPM_SIZE, but I think I'm happy that this change is more correct. Thanks for acting on the earlier feedback!

…acity drop

- Adds EthHdr::hdr_len() to the packet crate to return the wire size of
  the L2 header including any 802.1Q tag, replacing duplicate inline ops.

- Add a TODO noting multicast reduces IPv4 LPM capacity from 8187 to
  7164.
@zeeshanlakhani zeeshanlakhani merged commit 375a0f2 into main Mar 10, 2026
6 checks passed
@zeeshanlakhani zeeshanlakhani deleted the vlan-translation branch March 10, 2026 01:14
zeeshanlakhani added a commit to oxidecomputer/omicron that referenced this pull request Mar 10, 2026
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.

Test flake in integration_tests::mcast::test_multicast_vlan_translation_not_possible

2 participants