Skip to content

client/doublezerod: set tunnel interface down before deleting#3312

Merged
snormore merged 2 commits intomainfrom
snor/tunnel-down-before-delete
Mar 19, 2026
Merged

client/doublezerod: set tunnel interface down before deleting#3312
snormore merged 2 commits intomainfrom
snor/tunnel-down-before-delete

Conversation

@snormore
Copy link
Contributor

@snormore snormore commented Mar 19, 2026

Summary

  • Set tunnel interface administratively down (LinkSetDown) before deleting it during teardown across all service types (IBRL, edge filtering, multicast)
  • Adds TunnelDown to the Netlinker interface, called in each service's Teardown() before TunnelDelete

Why

When doublezerod deletes a tunnel, external applications (e.g. validators) may have sockets bound to the tunnel interface's overlay IP. If we delete the interface directly:

  • TCP sockets: Existing connections get an abrupt RST. The peer knows the connection died, but the local application gets no advance warning.
  • UDP sockets: The socket silently loses its binding. Sends may start using a different source address or fail with ENETUNREACH/EINVAL, but there's no explicit error delivered to the application — it just breaks quietly.

Setting the interface down first triggers ENETUNREACH errors on bound sockets immediately (the kernel processes LinkSetDown synchronously). Applications blocked on recv/epoll will see errors before the interface object is removed. This is a small improvement in behavior — not strictly necessary since the kernel does clean up everything on delete, but it turns silent breakage into explicit errors that are easier to debug.

The TunnelDown error is logged but not fatal — if the interface is already gone (e.g. double teardown), we don't want to block the TunnelDelete cleanup.

Testing Verification

  • GOOS=linux go vet ./client/doublezerod/... passes
  • All mock implementations updated to satisfy the extended Netlinker interface

When tearing down a tunnel, external applications (e.g. validators) may
have sockets bound to the tunnel interface's IP address. Deleting the
interface without first setting it down causes those sockets to break
silently. Setting the interface down first triggers errors on bound
sockets, giving applications a chance to notice the interface is going
away before it is removed.
@snormore snormore requested a review from packethog March 19, 2026 01:32
@snormore snormore marked this pull request as ready for review March 19, 2026 13:20
@snormore snormore merged commit ddb3337 into main Mar 19, 2026
31 checks passed
@snormore snormore deleted the snor/tunnel-down-before-delete branch March 19, 2026 13:40
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.

2 participants