Skip to content

fix: precise IP matching, safe NAT cleanup, atomic full snapshot replace#287

Merged
ejc3 merged 1 commit intoreview-networkingfrom
claude/fix-21787874395
Feb 7, 2026
Merged

fix: precise IP matching, safe NAT cleanup, atomic full snapshot replace#287
ejc3 merged 1 commit intoreview-networkingfrom
claude/fix-21787874395

Conversation

@claude-claude
Copy link
Copy Markdown
Contributor

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

Auto-Fix for PR #283

Issues Fixed

  1. Substring IP matching false positives (bridged.rs) — is_ip_in_use_on_veth used line.contains(ip) which matches IPs as substrings (e.g., checking 10.1.1.1 would match 10.1.1.10 or 210.1.1.1). Fixed by matching the exact inet <ip>/ pattern from ip -o addr show output.

  2. Unsafe ip_forward disable on cleanup (portmap.rs) — cleanup_global_nat_if_unused unconditionally set net.ipv4.ip_forward=0 when the last bridged VM exited, which could break Docker, Kubernetes, VPNs, or other services relying on IP forwarding. Removed this — MASQUERADE rules are still cleaned up, but forwarding is left enabled.

  3. Non-atomic full snapshot replace (common.rs) — The diff snapshot path was correctly fixed to use rename-swap (move old to .old, then rename temp to final), but the full snapshot path still used remove_dir_all + rename with a crash-unsafe gap. Applied the same rename-swap technique.

Changes

  • src/network/bridged.rs: Use format!("inet {}/", ip) instead of bare ip in the contains check
  • src/network/portmap.rs: Remove sysctl -w net.ipv4.ip_forward=0 with a comment explaining why we don't touch it
  • src/commands/common.rs: Apply rename-swap pattern to full snapshot path (matching diff snapshot path)

Note

This supersedes #284 which addressed issues 1 and 2 but not issue 3.


Generated by Claude | Review Run

- 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>
@ejc3 ejc3 merged commit 20074af into review-networking Feb 7, 2026
5 checks passed
@ejc3 ejc3 deleted the claude/fix-21787874395 branch February 7, 2026 22:56
claude-claude bot pushed a commit that referenced this pull request Feb 7, 2026
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 added a commit that referenced this pull request Feb 7, 2026
Bridged networking needs net.ipv4.ip_forward=1, but fcvm shouldn't
silently enable a system-wide sysctl. Instead, check and error with
instructions if it's disabled. The Makefile setup-btrfs target and
CI workflows already enable it as part of host setup.

Also fix stale cleanup doc comment (ip_forward=0 removal was in #287).
ejc3 added a commit that referenced this pull request Feb 7, 2026
Bridged networking needs net.ipv4.ip_forward=1, but fcvm shouldn't
silently enable a system-wide sysctl. Instead, check and error with
instructions if it's disabled. The Makefile setup-btrfs target and
CI workflows already enable it as part of host setup.

Also fix stale cleanup doc comment (ip_forward=0 removal was in #287).
ejc3 pushed a commit that referenced this pull request Feb 7, 2026
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 added a commit that referenced this pull request Feb 7, 2026
Bridged networking needs net.ipv4.ip_forward=1, but fcvm shouldn't
silently enable a system-wide sysctl. Instead, check and error with
instructions if it's disabled. The Makefile setup-btrfs target and
CI workflows already enable it as part of host setup.

Also fix stale cleanup doc comment (ip_forward=0 removal was in #287).
ejc3 pushed a commit that referenced this pull request Feb 7, 2026
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 added a commit that referenced this pull request Mar 2, 2026
Bridged networking needs net.ipv4.ip_forward=1, but fcvm shouldn't
silently enable a system-wide sysctl. Instead, check and error with
instructions if it's disabled. The Makefile setup-btrfs target and
CI workflows already enable it as part of host setup.

Also fix stale cleanup doc comment (ip_forward=0 removal was in #287).
ejc3 pushed a commit that referenced this pull request Mar 2, 2026
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 added a commit that referenced this pull request Mar 2, 2026
Bridged networking needs net.ipv4.ip_forward=1, but fcvm shouldn't
silently enable a system-wide sysctl. Instead, check and error with
instructions if it's disabled. The Makefile setup-btrfs target and
CI workflows already enable it as part of host setup.

Also fix stale cleanup doc comment (ip_forward=0 removal was in #287).
ejc3 pushed a commit that referenced this pull request Mar 2, 2026
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>
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