[PR #6221] [client] Gate IPv6 forwarding on overlay v6 and preserve host RA acceptance #27792

Open
opened 2026-08-05 07:09:14 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6221
Author: @lixmal
Created: 5/20/2026
Status: 🔄 Open

Base: mainHead: worktree-accept-ra-forwarding


📝 Commits (6)

  • c46dee4 Gate IPv6 forwarding on overlay v6 capability and preserve host RA acceptance
  • c761d0d Address review: VLAN-safe procfs path, rollback partial v6 enable, aggregate routing errors
  • 7461d4c Move v6 forwarding helpers to dedicated file
  • 6c6ad8d Merge remote-tracking branch 'origin/main' into worktree-accept-ra-forwarding
  • ddc9f81 Balance DNAT forwarding refcount on duplicates and missing rules
  • 3b8a5c1 Address CodeRabbit review on DNAT refcount

📊 Changes

13 files changed (+702 additions, -67 deletions)

View changed files

client/firewall/iptables/dnat_refcount_linux_test.go (+199 -0)
📝 client/firewall/iptables/manager_linux.go (+22 -6)
📝 client/firewall/iptables/router_linux.go (+22 -9)
client/firewall/nftables/dnat_refcount_linux_test.go (+208 -0)
📝 client/firewall/nftables/manager_linux.go (+23 -7)
📝 client/firewall/nftables/router_linux.go (+27 -9)
📝 client/internal/debug/debug_linux.go (+4 -0)
📝 client/internal/routemanager/ipfwdstate/ipfwdstate.go (+81 -26)
📝 client/internal/routemanager/systemops/systemops_android.go (+11 -2)
📝 client/internal/routemanager/systemops/systemops_ios.go (+11 -2)
📝 client/internal/routemanager/systemops/systemops_linux.go (+1 -4)
📝 client/internal/routemanager/systemops/systemops_nonlinux.go (+11 -2)
client/internal/routemanager/systemops/v6forwarding_linux.go (+82 -0)

📄 Description

Describe your changes

Stop flipping net.ipv6.conf.all.forwarding on hosts that have no IPv6 overlay, and when we do flip it, keep RA acceptance alive on host interfaces so kernel-installed IPv6 default routes don't quietly expire.

  • Split the forwarding refcounter in ipfwdstate per family so a v4-only routing setup no longer touches v6 sysctls
  • Only request v6 forwarding when the overlay interface actually has IPv6 (and per-rule paths request based on the rule's family)
  • Bump net.ipv6.conf.<iface>.accept_ra to 2 on non-overlay interfaces before enabling v6 forwarding, with admin overrides (0/2) preserved
  • Restore the sysctls we changed on the last v6 release; v4 stays untouched since it's a global knob other tooling co-owns
  • Include accept_ra in the sysctls.txt debug bundle group

Closes https://github.com/netbirdio/netbird/discussions/6201

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal sysctl/refcount behaviour, no user-facing surface changes.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • Refactor

    • IPv4 and IPv6 forwarding are now tracked and managed independently with per-family reference counts; enabling/disabling is family-specific and supports rollback on failures.
  • Chores

    • Platform stubs added to expose separate IPv4/IPv6 forwarding hooks across OS targets.
  • Documentation

    • Clarified coordination and behaviors between IPv4 and IPv6 forwarding.
  • Debug

    • Sysctl diagnostics now include IPv6 router-advertisement (accept_ra) settings.
  • Tests

    • Added DNAT/SNAT refcounting tests covering v4/v6, duplicate add, phantom delete, and double-delete cases.

Review Change Stack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6221 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 5/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `worktree-accept-ra-forwarding` --- ### 📝 Commits (6) - [`c46dee4`](https://github.com/netbirdio/netbird/commit/c46dee4e6b8a74f3f551cd2aca91b81357531083) Gate IPv6 forwarding on overlay v6 capability and preserve host RA acceptance - [`c761d0d`](https://github.com/netbirdio/netbird/commit/c761d0d1cd48b0db20a994fec32e7226d441621c) Address review: VLAN-safe procfs path, rollback partial v6 enable, aggregate routing errors - [`7461d4c`](https://github.com/netbirdio/netbird/commit/7461d4cef422cc6317f03e81c13e4e45f23dc56c) Move v6 forwarding helpers to dedicated file - [`6c6ad8d`](https://github.com/netbirdio/netbird/commit/6c6ad8d14f587ff0ad1ee3d9cfb83e3f1b70d610) Merge remote-tracking branch 'origin/main' into worktree-accept-ra-forwarding - [`ddc9f81`](https://github.com/netbirdio/netbird/commit/ddc9f8199a26368d71967a6901e200cb07a50b1b) Balance DNAT forwarding refcount on duplicates and missing rules - [`3b8a5c1`](https://github.com/netbirdio/netbird/commit/3b8a5c15cced0b6fbdeabf3e4c76373a2390b91b) Address CodeRabbit review on DNAT refcount ### 📊 Changes **13 files changed** (+702 additions, -67 deletions) <details> <summary>View changed files</summary> ➕ `client/firewall/iptables/dnat_refcount_linux_test.go` (+199 -0) 📝 `client/firewall/iptables/manager_linux.go` (+22 -6) 📝 `client/firewall/iptables/router_linux.go` (+22 -9) ➕ `client/firewall/nftables/dnat_refcount_linux_test.go` (+208 -0) 📝 `client/firewall/nftables/manager_linux.go` (+23 -7) 📝 `client/firewall/nftables/router_linux.go` (+27 -9) 📝 `client/internal/debug/debug_linux.go` (+4 -0) 📝 `client/internal/routemanager/ipfwdstate/ipfwdstate.go` (+81 -26) 📝 `client/internal/routemanager/systemops/systemops_android.go` (+11 -2) 📝 `client/internal/routemanager/systemops/systemops_ios.go` (+11 -2) 📝 `client/internal/routemanager/systemops/systemops_linux.go` (+1 -4) 📝 `client/internal/routemanager/systemops/systemops_nonlinux.go` (+11 -2) ➕ `client/internal/routemanager/systemops/v6forwarding_linux.go` (+82 -0) </details> ### 📄 Description ## Describe your changes Stop flipping `net.ipv6.conf.all.forwarding` on hosts that have no IPv6 overlay, and when we do flip it, keep RA acceptance alive on host interfaces so kernel-installed IPv6 default routes don't quietly expire. - Split the forwarding refcounter in `ipfwdstate` per family so a v4-only routing setup no longer touches v6 sysctls - Only request v6 forwarding when the overlay interface actually has IPv6 (and per-rule paths request based on the rule's family) - Bump `net.ipv6.conf.<iface>.accept_ra` to 2 on non-overlay interfaces before enabling v6 forwarding, with admin overrides (0/2) preserved - Restore the sysctls we changed on the last v6 release; v4 stays untouched since it's a global knob other tooling co-owns - Include `accept_ra` in the `sysctls.txt` debug bundle group ## Issue ticket number and link Closes https://github.com/netbirdio/netbird/discussions/6201 ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal sysctl/refcount behaviour, no user-facing surface changes. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: https://github.com/netbirdio/docs/pull/__ <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * IPv4 and IPv6 forwarding are now tracked and managed independently with per-family reference counts; enabling/disabling is family-specific and supports rollback on failures. * **Chores** * Platform stubs added to expose separate IPv4/IPv6 forwarding hooks across OS targets. * **Documentation** * Clarified coordination and behaviors between IPv4 and IPv6 forwarding. * **Debug** * Sysctl diagnostics now include IPv6 router-advertisement (accept_ra) settings. * **Tests** * Added DNAT/SNAT refcounting tests covering v4/v6, duplicate add, phantom delete, and double-delete cases. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/netbird/pull/6221?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 07:09:14 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#27792