[PR #5707] [MERGED] [client] Add dual-stack nftables manager with IPv6 table support #28399

Closed
opened 2026-08-05 08:06:18 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/5707
Author: @lixmal
Created: 3/26/2026
Status: Merged
Merged: 4/9/2026
Merged by: @lixmal

Base: client-ipv6-routingHead: client-ipv6-nftables


📝 Commits (10+)

  • e4857b4 Add dual-stack nftables manager with IPv6 table support
  • c13f1af Fix ip6tables-save compat: skip ip6tables-managed tables in external chain scan
  • 571527c Add iptablesProto helper, filter table fallback, DNAT compat tests
  • 44d16e8 Merge branch 'client-ipv6-routing' into client-ipv6-nftables
  • 443d072 Fix CodeRabbit findings: rollback on init failure, accumulate Close errors, expand test guards
  • 546140a Extract rollbackInit helper to deduplicate Init cleanup
  • 024cc6c Split Init to reduce cognitive complexity
  • ea451df Merge remote-tracking branch 'origin/client-ipv6-routing' into client-ipv6-nftables
  • 935ca81 Merge remote-tracking branch 'origin/client-ipv6-routing' into client-ipv6-nftables
  • 6793950 Merge branch 'client-ipv6-routing' into client-ipv6-nftables

📊 Changes

46 files changed (+1790 additions, -353 deletions)

View changed files

📝 client/android/client.go (+60 -19)
📝 client/android/route_command.go (+5 -2)
📝 client/anonymize/anonymize.go (+6 -0)
📝 client/cmd/ssh.go (+2 -2)
📝 client/cmd/ssh_test.go (+2 -2)
📝 client/firewall/iptables/acl_linux.go (+28 -3)
📝 client/firewall/iptables/manager_linux.go (+210 -26)
📝 client/firewall/iptables/router_linux.go (+50 -18)
📝 client/firewall/iptables/rule.go (+1 -0)
📝 client/firewall/iptables/state_linux.go (+30 -0)
📝 client/firewall/nftables/acl_linux.go (+18 -26)
client/firewall/nftables/addr_family_linux.go (+81 -0)
📝 client/firewall/nftables/manager_linux.go (+258 -29)
📝 client/firewall/nftables/manager_linux_test.go (+124 -0)
📝 client/firewall/nftables/router_linux.go (+104 -61)
📝 client/firewall/nftables/router_linux_test.go (+186 -3)
📝 client/firewall/uspfilter/allow_netbird_windows.go (+38 -15)
📝 client/firewall/uspfilter/conntrack/common.go (+5 -2)
📝 client/firewall/uspfilter/filter.go (+2 -1)
📝 client/firewall/uspfilter/filter_test.go (+38 -0)

...and 26 more files

📄 Description

Describe your changes

  • Add addrFamily abstraction encapsulating IPv4/IPv6 header offsets, address lengths, set key types, and ICMP protocol numbers
  • Create parallel ip6 netbird table with its own router and ACL manager when the interface has IPv6
  • Route all firewall operations to the correct table by address family
  • Split UpdateSet prefixes by family for dynamic DNS route sets
  • Add IPv6 interval set tests (TestNftablesCreateIpSet_IPv6) and calculateLastIP tests covering both families
  • MSS clamping uses correct overhead per family (40 for v4, 60 for v6)

Stacked on #5706.

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)

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/667

Summary by CodeRabbit

  • New Features

    • Added full IPv6 support across firewall filtering, routing, NAT (including DNAT) and MSS handling; firewall now manages IPv4 and IPv6 in parallel with mirrored NAT for IPv6 destinations and dual-stack rule management.
  • Tests

    • Expanded IPv6 test coverage and compatibility checks, including IP set creation, prefix/address calculations, protocol handling, and ip6tables interoperability.

🔄 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/5707 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 3/26/2026 **Status:** ✅ Merged **Merged:** 4/9/2026 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `client-ipv6-routing` ← **Head:** `client-ipv6-nftables` --- ### 📝 Commits (10+) - [`e4857b4`](https://github.com/netbirdio/netbird/commit/e4857b4d9d7fc5f39cea2df15b90dca2f96ac4cb) Add dual-stack nftables manager with IPv6 table support - [`c13f1af`](https://github.com/netbirdio/netbird/commit/c13f1af1968b1316158ba747a7b4369e7cdcc159) Fix ip6tables-save compat: skip ip6tables-managed tables in external chain scan - [`571527c`](https://github.com/netbirdio/netbird/commit/571527c2d3dc47710ea8c243f2d8d8d51db50511) Add iptablesProto helper, filter table fallback, DNAT compat tests - [`44d16e8`](https://github.com/netbirdio/netbird/commit/44d16e87913974445817f61830e3a401d1061c48) Merge branch 'client-ipv6-routing' into client-ipv6-nftables - [`443d072`](https://github.com/netbirdio/netbird/commit/443d0720a39d0b015de79a41d65d8aaab887d8ed) Fix CodeRabbit findings: rollback on init failure, accumulate Close errors, expand test guards - [`546140a`](https://github.com/netbirdio/netbird/commit/546140a2c226ec2baaf8e054d47ec7d8686d8e6f) Extract rollbackInit helper to deduplicate Init cleanup - [`024cc6c`](https://github.com/netbirdio/netbird/commit/024cc6cba924b2cfe0fb0979d22bc4b855c10e3e) Split Init to reduce cognitive complexity - [`ea451df`](https://github.com/netbirdio/netbird/commit/ea451dfdc6a9e80e976f3857909a6ea68d5335a5) Merge remote-tracking branch 'origin/client-ipv6-routing' into client-ipv6-nftables - [`935ca81`](https://github.com/netbirdio/netbird/commit/935ca81a8a661cb33f2e29bf89eaecea4e4340cd) Merge remote-tracking branch 'origin/client-ipv6-routing' into client-ipv6-nftables - [`6793950`](https://github.com/netbirdio/netbird/commit/6793950b42f5ca0f2468c6fc96d484700cd72a99) Merge branch 'client-ipv6-routing' into client-ipv6-nftables ### 📊 Changes **46 files changed** (+1790 additions, -353 deletions) <details> <summary>View changed files</summary> 📝 `client/android/client.go` (+60 -19) 📝 `client/android/route_command.go` (+5 -2) 📝 `client/anonymize/anonymize.go` (+6 -0) 📝 `client/cmd/ssh.go` (+2 -2) 📝 `client/cmd/ssh_test.go` (+2 -2) 📝 `client/firewall/iptables/acl_linux.go` (+28 -3) 📝 `client/firewall/iptables/manager_linux.go` (+210 -26) 📝 `client/firewall/iptables/router_linux.go` (+50 -18) 📝 `client/firewall/iptables/rule.go` (+1 -0) 📝 `client/firewall/iptables/state_linux.go` (+30 -0) 📝 `client/firewall/nftables/acl_linux.go` (+18 -26) ➕ `client/firewall/nftables/addr_family_linux.go` (+81 -0) 📝 `client/firewall/nftables/manager_linux.go` (+258 -29) 📝 `client/firewall/nftables/manager_linux_test.go` (+124 -0) 📝 `client/firewall/nftables/router_linux.go` (+104 -61) 📝 `client/firewall/nftables/router_linux_test.go` (+186 -3) 📝 `client/firewall/uspfilter/allow_netbird_windows.go` (+38 -15) 📝 `client/firewall/uspfilter/conntrack/common.go` (+5 -2) 📝 `client/firewall/uspfilter/filter.go` (+2 -1) 📝 `client/firewall/uspfilter/filter_test.go` (+38 -0) _...and 26 more files_ </details> ### 📄 Description ## Describe your changes - Add `addrFamily` abstraction encapsulating IPv4/IPv6 header offsets, address lengths, set key types, and ICMP protocol numbers - Create parallel `ip6 netbird` table with its own router and ACL manager when the interface has IPv6 - Route all firewall operations to the correct table by address family - Split `UpdateSet` prefixes by family for dynamic DNS route sets - Add IPv6 interval set tests (`TestNftablesCreateIpSet_IPv6`) and `calculateLastIP` tests covering both families - MSS clamping uses correct overhead per family (40 for v4, 60 for v6) Stacked on #5706. ## Issue ticket number and link ## Stack - #5631 - #5675 - #5686 - #5687 - #5688 - #5706 - #5707 :point_left: - #5708 ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [x] 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: - [x] I added/updated documentation for this change - [ ] Documentation is **not needed** for this change (explain why) ### 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/667 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added full IPv6 support across firewall filtering, routing, NAT (including DNAT) and MSS handling; firewall now manages IPv4 and IPv6 in parallel with mirrored NAT for IPv6 destinations and dual-stack rule management. * **Tests** * Expanded IPv6 test coverage and compatibility checks, including IP set creation, prefix/address calculations, protocol handling, and ip6tables interoperability. <!-- 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 08:06:18 -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#28399