Skip to content

Comments

client: prune mcast group immediately on disconnect#555

Merged
packethog merged 4 commits intomainfrom
fix/pim_prune
Jun 11, 2025
Merged

client: prune mcast group immediately on disconnect#555
packethog merged 4 commits intomainfrom
fix/pim_prune

Conversation

@packethog
Copy link
Contributor

Summary

When a client is subscribed to a multicast group and either shuts down doublezerod or disconnects their tunnel, the upstream DoubleZero device was continuing to replicate multicast traffic towards the user for up to 210s due to mroute state not being purged. This was because we were setting the same holdtime on PIM join and prune messages which dictates how long an upstream router should maintain join or prune state:

RFC7761, section 4.9.5:

   Holdtime
         The amount of time a receiver MUST keep the Join/Prune state
         alive, in seconds.  If the Holdtime is set to '0xffff', the
         receiver of this message SHOULD hold the state until canceled
         by the appropriate canceling Join/Prune message, or timed out
         according to local policy.  This may be used with dial-on-
         demand links, to avoid keeping the link up with periodic
         Join/Prune messages.

This PR lowers the holdtime for join messages to 120s and prune messages to 5s.

Testing

Create tunnel and verify PIM join is sent w/ 2m holdtime:

ubuntu@chi-dn-bm2:~$ doublezero connect multicast subscriber mg01 --device chi-dn-dzd1
DoubleZero Service Provisioning
🔗  Start Provisioning User...
Public IP: 137.174.145.145 (If you want to specify a particular address, use the argument --client-ip x.x.x.x)
🔍  Provisioning User for IP: 137.174.145.145
    Creating an account for the IP: 137.174.145.145
    The Device has been selected: chi-dn-dzd1
    User activated with dz_ip: 137.174.145.145
    User activated with dz_ip: 137.174.145.145
Provisioning: status: ok
/  Connected

ubuntu@chi-dn-bm2:~$ sudo tcpdump -i any -v pim
...
18:04:23.321277 doublezero1 Out IP (tos 0x0, ttl 1, id 12482, offset 0, flags [none], proto PIM (103), length 54)
    chi-dn-bm2 > pim-routers.mcast.net: PIMv2, length 34
        Join / Prune, cksum 0x82ef (correct), upstream-neighbor: 169.254.0.2
          1 group(s), holdtime: 2m
            group #1: 233.84.178.0, joined sources: 1, pruned sources: 0
              joined source #1: 10.0.0.0(SWR)

Verify mroute state is created on the dzd:

chi-dn-dzd1#show ip mroute
PIM Bidirectional Mode Multicast Routing Table
RPF route: U - From unicast routing table
           M - From multicast routing table
PIM Sparse Mode Multicast Routing Table
Flags: E - Entry forwarding on the RPT, J - Joining to the SPT
    R - RPT bit is set, S - SPT bit is set, L - Source is attached
    W - Wildcard entry, X - External component interest
    I - SG Include Join alert rcvd, P - Programmed in hardware
    H - Joining SPT due to policy, D - Joining SPT due to protocol
    Z - Entry marked for deletion, C - Learned from a DR via a register
    A - Learned via Anycast RP Router, M - Learned via MSDP
    N - May notify MSDP, K - Keepalive timer not running
    T - Switching Incoming Interface, B - Learned via Border Router
    V - Source is reachable via Evpn Tenant Domain
    F - Learned via MVPN
RPF route: U - From unicast routing table
           M - From multicast routing table
233.84.178.0
  0.0.0.0, 0:00:37, RP 10.0.0.0, flags: W
    Incoming interface: Register
    Outgoing interface list:
      Tunnel501

Disconnect from group and verify PIM prune is sent w/ 5s holdtime:

ubuntu@chi-dn-bm2:~$ doublezero disconnect multicast
DoubleZero Service Provisioning
🔍  Decommissioning User
Public IP: 137.174.145.145 (If you want to specify a particular address, use the argument --client-ip x.x.x.x)
|  deleting user account...                                                                                                                                                                                                                                                                                                                                                                                                                  🔍  Deleting User Account for: 9HKbT49idxD27K2KsH7f9zZHmTS78ANYPhAG6rLtBXnn
🔍  User Account deleted
/  🔍  Deprovisioning Complete

ubuntu@chi-dn-bm2:~$ sudo tcpdump -i any -v pim
...
18:04:39.134883 doublezero1 Out IP (tos 0x0, ttl 1, id 17108, offset 0, flags [none], proto PIM (103), length 54)
    chi-dn-bm2 > pim-routers.mcast.net: PIMv2, length 34
        Join / Prune, cksum 0x8362 (correct), upstream-neighbor: 169.254.0.2
          1 group(s), holdtime: 5s
            group #1: 233.84.178.0, joined sources: 0, pruned sources: 1
              pruned source #1: 10.0.0.0(SWR)

Verify mroute state is immediately purged:

chi-dn-dzd1#show ip mroute
PIM Bidirectional Mode Multicast Routing Table
RPF route: U - From unicast routing table
           M - From multicast routing table
PIM Sparse Mode Multicast Routing Table
Flags: E - Entry forwarding on the RPT, J - Joining to the SPT
    R - RPT bit is set, S - SPT bit is set, L - Source is attached
    W - Wildcard entry, X - External component interest
    I - SG Include Join alert rcvd, P - Programmed in hardware
    H - Joining SPT due to policy, D - Joining SPT due to protocol
    Z - Entry marked for deletion, C - Learned from a DR via a register
    A - Learned via Anycast RP Router, M - Learned via MSDP
    N - May notify MSDP, K - Keepalive timer not running
    T - Switching Incoming Interface, B - Learned via Border Router
    V - Source is reachable via Evpn Tenant Domain
    F - Learned via MVPN
RPF route: U - From unicast routing table
           M - From multicast routing table
chi-dn-dzd1#

@packethog packethog added this to the Multicast milestone Jun 11, 2025
@packethog packethog requested a review from Copilot June 11, 2025 18:44
@packethog packethog self-assigned this Jun 11, 2025

This comment was marked as outdated.

@packethog packethog linked an issue Jun 11, 2025 that may be closed by this pull request
@packethog packethog requested a review from Copilot June 11, 2025 19:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reduces the default PIM join holdtime to 120 s and prune holdtime to 5 s, updates the server to pass these values when constructing messages, and aligns tests and the CLI tool accordingly.

  • Lower PIM Join holdtime from 210 s to 120 s and Prune holdtime from 210 s to 5 s
  • Introduce joinHoldtime/pruneHoldtime in the PIM server and wire through to constructJoinPruneMessage
  • Update tests’ expected checksums and holdtimes; add CLI flags to the send command including a configurable holdtime

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
client/doublezerod/internal/runtime/run_test.go Updated expected holdtime values and checksums in tests
client/doublezerod/internal/pim/server_test.go Updated expected holdtime values and checksums in tests
client/doublezerod/internal/pim/server.go Added joinHoldtime/pruneHoldtime vars and passed them
client/doublezerod/internal/pim/pim.go Changed error messages to lowercase for Go best practices
client/doublezerod/internal/pim/cmd/send/send.go Extended CLI with flags for join/prune and holdtime
Comments suppressed due to low confidence (1)

client/doublezerod/internal/pim/cmd/send/send.go:21

  • [nitpick] Add a unit test for the send command to verify that the -holdtime flag is parsed correctly and applied to the generated PIM messages.
holdtime         = flag.Int("holdtime", 120, "holdtime for JoinPrune messages (default 210 seconds)")

@packethog packethog requested a review from a team June 11, 2025 19:19
@packethog packethog marked this pull request as ready for review June 11, 2025 19:19
@packethog packethog merged commit cfdb7f5 into main Jun 11, 2025
10 of 11 checks passed
@packethog packethog deleted the fix/pim_prune branch June 11, 2025 19:39
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.

pim prune message sent but mroute isn't updated

3 participants