Skip to content

[p4, sidecar] fix underlay/external mcast counter ops - #362

Open
zeeshanlakhani wants to merge 10 commits into
zl/mcast-ingress-vlanfrom
zl/mcast-p4-counters
Open

zeeshanlakhani wants to merge 10 commits into
zl/mcast-ingress-vlanfrom
zl/mcast-p4-counters

Conversation

@zeeshanlakhani

@zeeshanlakhani zeeshanlakhani commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

A replica still carrying a Geneve header at the egress counter block is bound for an underlay port, while external replicas are decapsulated earlier, at ingress, for external-only groups or in mcast_egress for bifurcated (external + underlay members) ones. Previously, we used a conditional:

else if (hdr.geneve.isValid()) {

... on Geneve hdr validity too early in the chain to determine an external- vs underlay-destined packet, and we didn't consider using the is_egress_rid_mcast check at all.

Now, we treat the three conditions for link-local, external mcast, and underlay mcast independently and more explicitly given the egress rid, which is 0 for link-local multicast packets and combines with Geneve hdr validity to determine the count for underlay vs external.

The underlay and external arms key on is_egress_rid_mcast and not the negation of is_link_local_ipv6_mcast: the compiler doesn't carry the negation into the later gateways of the pipeline, which meant that a link-local packet incremented external_mcast_ctr alongside its own counter. This is now handled because link-local replicas arrive with egress_rid of 0, and scope 2 is refused at group creation, so no replicated packet ever carries a link-local outer destination.

@zeeshanlakhani
zeeshanlakhani force-pushed the zl/mcast-p4-counters branch 5 times, most recently from ee83887 to 873c3d3 Compare September 3, 2026 05:25
@zeeshanlakhani zeeshanlakhani changed the title [p4, sidecar] attribute egress mcast counters by Geneve validity [p4, sidecar] fix underlay/external mcast counter ops Sep 3, 2026
@zeeshanlakhani zeeshanlakhani self-assigned this Sep 4, 2026
@zeeshanlakhani
zeeshanlakhani removed this pull request from stack #363 September 9, 2026 01:59
A replica still carrying a Geneve header at the egress counter block is bound
for an underlay port, while external replicas are decapsulated earlier, at
ingress, for external-only groups or in `mcast_egress` for bifurcated
(external + underlay members) ones. Previously, we used a conditional:

```p4
else if (hdr.geneve.isValid()) {
```

... on Geneve hdr validity too early in the chain to determine an
external- vs underlay-destined packet, and we didn't consider using the
`is_egress_rid_mcast` check at all.

## The Fix

Now, we treat the three conditions for link-local, external mcast, and
underlay mcast independently and more explicitly given the egress rid,
which is 0 for link-local multicast packets and combines with Geneve hdr
validity to determine the count for underlay vs external.

The underlay and external arms key on `is_egress_rid_mcast` and not the
negation of `is_link_local_ipv6_mcast`: the compiler doesn't carry the
negation into the later gateways of the pipeline, which meant that a
link-local packet incremented `external_mcast_ctr` alongside its own
counter. This is now handled because link-local replicas arrive with
`egress_rid` of 0, and scope 2 is refused at group creation, so no
replicated packet ever carries a link-local outer destination.
@zeeshanlakhani
zeeshanlakhani changed the base branch from zl/mcast-default-feature to zl/mcast-remove-feature September 9, 2026 14:54
@zeeshanlakhani
zeeshanlakhani added this pull request to stack #372 September 9, 2026 14:54

@cfzimmerman cfzimmerman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks reasonable, but again I'd like to defer final approval to someone with more knowledge of the sidecar program.

Comment thread dpd/p4/sidecar.p4 Outdated
Comment thread dpd/p4/sidecar.p4 Outdated
Comment thread dpd/p4/sidecar.p4 Outdated
@zeeshanlakhani
zeeshanlakhani removed this pull request from stack #372 September 23, 2026 18:38
@zeeshanlakhani
zeeshanlakhani added this pull request to stack #377 September 24, 2026 17:37
@zeeshanlakhani
zeeshanlakhani removed this pull request from stack #377 October 6, 2026 02:42
> IngressDeparser has the issue that writing it more cleanly uses too
> many checksum engines, because the compiler doesn't recognise the
> disjoint cases for some reason. Do we end up running out of stages if
> we do a sensible if...?

This reworks our counter logic per Kyle's comment (quoted above).
Nesting the per-type checks (and, separately, an else-if chain with
link-local checked first) dropped the underlay count to 0 during testing,
even though stage usage didn't change.

However, this led me to find an issue with:

```p4
bit<16> ipv6_prefix = (bit<16>)hdr.ipv6.dst_addr[127:112];
is_link_local_ipv6_mcast = (ipv6_prefix == IPV6_LINK_LOCAL_16);
```

This bool lands within a 16-bit container, and the conditionals on
it (e.g., `is_mcast` and link_local checks) are built with *-only match
rows, making them always true. So, every forwarded packet was counted
as `Multicast`, and `Unicast` remained at 0.

Now, the bool is set inside the `if` and the chain branches on
`egress_rid` first. We don't see any significant issues with the
added cycles, however.
@zeeshanlakhani
zeeshanlakhani added this pull request to stack #397 October 7, 2026 10:17
@zeeshanlakhani zeeshanlakhani added the multicast Multicast-related feature/impl label Oct 7, 2026
@zeeshanlakhani
zeeshanlakhani removed this pull request from stack #397 October 13, 2026 13:58
@zeeshanlakhani
zeeshanlakhani added this pull request to stack #401 October 13, 2026 13:59
Comment thread dpd-client/tests/integration_tests/common.rs Outdated
Comment thread dpd-client/tests/integration_tests/common.rs Outdated
Comment thread dpd-client/tests/integration_tests/common.rs Outdated
Comment thread dpd/p4/sidecar.p4
@zeeshanlakhani

Copy link
Copy Markdown
Contributor Author

@cfzimmerman updated, including the counter fix.

@zeeshanlakhani
zeeshanlakhani removed this pull request from stack #401 October 21, 2026 01:55
@zeeshanlakhani
zeeshanlakhani changed the base branch from zl/mcast-remove-feature to zl/mcast-ingress-vlan October 21, 2026 01:58
@zeeshanlakhani
zeeshanlakhani added this pull request to stack #410 October 21, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

multicast Multicast-related feature/impl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants