Skip to content

fix: update stale docstring for cleanup_global_nat_if_unused#289

Closed
claude-claude[bot] wants to merge 7 commits intoreview-networkingfrom
claude/fix-21788282999
Closed

fix: update stale docstring for cleanup_global_nat_if_unused#289
claude-claude[bot] wants to merge 7 commits intoreview-networkingfrom
claude/fix-21788282999

Conversation

@claude-claude
Copy link
Copy Markdown
Contributor

@claude-claude claude-claude bot commented Feb 7, 2026

Auto-Fix for PR #283

Issues Fixed

Changes

  • Updated doc comment on cleanup_global_nat_if_unused() in src/network/portmap.rs to accurately reflect that IP forwarding is left enabled and only MASQUERADE rules are removed.

Generated by Claude | Review Run

EJ Campbell and others added 7 commits February 7, 2026 12:55
VsockListener held a raw fd with no Drop impl. If bind() or listen()
failed, the fd was closed manually, but any new error path would leak.
Worse, the AsyncFd::new() error path did a manual close after ownership
had already transferred (potential double-close).

Fix: add Drop that calls libc::close(), wrap fd immediately after
socket() succeeds, and remove all manual libc::close() calls.
- Add collision detection to hash-based subnet allocation: check if
  the derived host IP is already on a live veth, increment and retry
  if so (capped at 100 attempts)
- Add cleanup_global_nat_if_unused() that removes MASQUERADE rules
  and disables ip_forward when the last bridged VM exits
- Extract derive_host_ip() helper for collision check reuse
Rename old snapshot to .old before renaming new into place, instead
of remove_dir_all + rename. Eliminates the window where a crash
would lose the snapshot entirely.
…tion

- Remove std::env::set_var for writeback cache propagation (#26): pass
  no_writeback_cache flag through mount_vsock_with_options API instead.
  set_var is unsound in multi-threaded Rust programs.
- Bound exec line reader to 1MB (#27): prevents OOM from malicious or
  malformed exec requests sent over vsock.
- Replace bash -c shell injection with direct Command args (#28): TAP
  device verification now uses ip link show directly instead of through
  a shell.
- Use exact "inet <ip>/" pattern in is_ip_in_use_on_veth to prevent
  substring false positives (e.g., 10.1.1.1 matching 10.1.1.10)
- Remove unsafe sysctl ip_forward=0 from cleanup_global_nat_if_unused
  to avoid breaking Docker/K8s/VPNs on the host
- Apply rename-swap technique to full snapshot path (matching diff
  snapshot path) to prevent data loss on crash between remove and rename

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
fix: precise IP matching, safe NAT cleanup, atomic full snapshot replace
The doc comment still mentioned "disables ip_forward" but the code
intentionally leaves ip_forward enabled after the fix in PR #287.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ejc3
Copy link
Copy Markdown
Owner

ejc3 commented Feb 7, 2026

Cherry-picked into review-networking branch

@ejc3 ejc3 closed this Feb 7, 2026
@ejc3 ejc3 deleted the claude/fix-21788282999 branch February 8, 2026 18:28
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.

1 participant