fix: update stale docstring for cleanup_global_nat_if_unused#289
Closed
claude-claude[bot] wants to merge 7 commits intoreview-networkingfrom
Closed
fix: update stale docstring for cleanup_global_nat_if_unused#289claude-claude[bot] wants to merge 7 commits intoreview-networkingfrom
claude-claude[bot] wants to merge 7 commits intoreview-networkingfrom
Conversation
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>
c86543e to
8125ce6
Compare
Owner
|
Cherry-picked into review-networking branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-Fix for PR #283
Issues Fixed
cleanup_global_nat_if_unusedthat still mentioned "disables ip_forward" — the code intentionally leaves ip_forward enabled after the fix in PR fix: precise IP matching, safe NAT cleanup, atomic full snapshot replace #287.Changes
cleanup_global_nat_if_unused()insrc/network/portmap.rsto accurately reflect that IP forwarding is left enabled and only MASQUERADE rules are removed.Generated by Claude | Review Run