Skip to content

ra-receiver duplicates work per DynamicPrefix on same interface #17

Description

@jr42

Summary

When more than one DynamicPrefix references the same network interface, the operator processes each Router Advertisement / Neighbor Advertisement packet once per DynamicPrefix. With n DynamicPrefix CRs sharing an interface, every NDP message generates n log lines and n event-handler invocations.

Reproduction

Cluster with 2 DynamicPrefix CRs both bound to enp1s0.222:

  • dmz-ipv6 (full prefix mode)
  • dmz-ipv6-subnet (subnet mode)

Operator log on v0.0.2 (image 0.0.2):

2026-04-26T10:52:02Z  ra-receiver  Received Router Advertisement  from=fe80::d221:f9ff:fe8b:2d9b%enp1s0.222 optionCount=4
2026-04-26T10:52:02Z  ra-receiver  Found prefix option  prefix=2003:e6:b734:7202:: ...
2026-04-26T10:52:02Z  ra-receiver  Selected prefix  prefix=2003:e6:b734:7202::/64 ...
2026-04-26T10:52:02Z  ra-receiver  Updating prefix  ... eventType=renewed
2026-04-26T10:52:02Z  ra-receiver  Event sent successfully  eventType=renewed
2026-04-26T10:52:02Z  DEBUG ra-receiver  Received NDP message  type=*ndp.RouterAdvertisement
2026-04-26T10:52:02Z  ra-receiver  Received Router Advertisement  from=fe80::d221:f9ff:fe8b:2d9b%enp1s0.222 optionCount=4   ← second copy, same nanosecond
2026-04-26T10:52:02Z  ra-receiver  Found prefix option  prefix=2003:e6:b734:7202:: ...
2026-04-26T10:52:02Z  ra-receiver  Selected prefix  prefix=2003:e6:b734:7202::/64 ...
2026-04-26T10:52:02Z  ra-receiver  Updating prefix  ...
2026-04-26T10:52:02Z  ra-receiver  Event sent successfully  eventType=renewed

Same RA, same nanosecond timestamp, processed twice — once per DynamicPrefix.

Why it matters

Cosmetic at small n (log volume doubles, work doubles). Structural at scale: O(n) work per packet instead of O(1). Multiple ICMPv6 listeners on one socket also rack up extra kernel-side state.

Suggested fix

One ra-receiver per interface, not per DynamicPrefix. Fan out received events to all DynamicPrefixes that match. Receiver lives in a shared cache keyed by interface name with refcounted lifetime.

Spotted while running v0.0.2 in production after pinning away from main due to #16.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions