[PR #3862] [MERGED] [client] Use native facilities to add routes on BSD and Windows #23916

Open
opened 2026-08-05 06:08:01 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/3862
Author: @lixmal
Created: 5/22/2025
Status: Merged
Merged: 6/4/2025
Merged by: @lixmal

Base: mainHead: improve-windows-client-routes


📝 Commits (10+)

📊 Changes

53 files changed (+1516 additions, -1010 deletions)

View changed files

📝 client/cmd/trace.go (+1 -1)
📝 client/firewall/iptables/manager_linux_test.go (+15 -24)
📝 client/firewall/nftables/manager_linux_test.go (+11 -20)
📝 client/firewall/uspfilter/forwarder/forwarder.go (+5 -7)
📝 client/firewall/uspfilter/localip.go (+28 -20)
📝 client/firewall/uspfilter/localip_test.go (+14 -35)
📝 client/firewall/uspfilter/tracer_test.go (+2 -5)
📝 client/firewall/uspfilter/uspfilter.go (+0 -6)
📝 client/firewall/uspfilter/uspfilter_bench_test.go (+2 -72)
📝 client/firewall/uspfilter/uspfilter_filter_test.go (+6 -16)
📝 client/firewall/uspfilter/uspfilter_test.go (+2 -18)
📝 client/iface/bind/udp_mux_universal.go (+1 -1)
📝 client/iface/device/device_filter.go (+0 -4)
📝 client/iface/device/device_netstack.go (+5 -1)
📝 client/iface/device/wg_link_freebsd.go (+9 -1)
📝 client/iface/iface.go (+0 -1)
📝 client/iface/mocks/filter.go (+0 -13)
📝 client/iface/netstack/tun.go (+5 -17)
📝 client/iface/wgaddr/address.go (+7 -8)
📝 client/internal/acl/manager_test.go (+7 -10)

...and 33 more files

📄 Description

Describe your changes

  • Use syscalls to add/remove routes on Windows
  • Use the routing socket to add/remove routes on BSD variants
  • Replace net.IP and net.IPNet with netip.Addr and netip.Prefix in wgaddr.Address
  • Fix some tests for FreeBSD
  • Remove "add route for gateway" and "duplicate route" logic
  • Add allowed route validation
  • Add better tests

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)
  • Extended the README / documentation, if necessary

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


🔄 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/3862 **Author:** [@lixmal](https://github.com/lixmal) **Created:** 5/22/2025 **Status:** ✅ Merged **Merged:** 6/4/2025 **Merged by:** [@lixmal](https://github.com/lixmal) **Base:** `main` ← **Head:** `improve-windows-client-routes` --- ### 📝 Commits (10+) - [`239458b`](https://github.com/netbirdio/netbird/commit/239458be78b089eab9c3675af2010f30b32312b9) Use windows syscalls to configure routes - [`c0f811d`](https://github.com/netbirdio/netbird/commit/c0f811d2312c3ee4599647fe78a886feac72a715) WIP - [`a8714d0`](https://github.com/netbirdio/netbird/commit/a8714d06b846fd297a56c7c5762835a644f9d1a3) Add debug output - [`988ecfb`](https://github.com/netbirdio/netbird/commit/988ecfbb1d86152e22cdacb3ba1e229714bc5c3f) Use consts - [`79b6efc`](https://github.com/netbirdio/netbird/commit/79b6efc538c73707ce322ea99bd5660219b1f10b) Remove add gateway logic - [`e036fb7`](https://github.com/netbirdio/netbird/commit/e036fb7feff5056c4841ad29d74f39711175d679) Remove powershell from test - [`0dc0962`](https://github.com/netbirdio/netbird/commit/0dc0962320f011be59ccd6e6fabfad4e11505121) Remove obsolete test case - [`baac3e9`](https://github.com/netbirdio/netbird/commit/baac3e9af631f0f89f447be99c0aec4f54ff3e31) Use bsd routing socket to add/remove routes - [`4edcaae`](https://github.com/netbirdio/netbird/commit/4edcaae942fd8404e5c88f36f34168b9604b0e24) Add native bsd methods - [`9888287`](https://github.com/netbirdio/netbird/commit/9888287e6e66a14ab1c6315632e39d7c046eba42) Remove obsolete test case ### 📊 Changes **53 files changed** (+1516 additions, -1010 deletions) <details> <summary>View changed files</summary> 📝 `client/cmd/trace.go` (+1 -1) 📝 `client/firewall/iptables/manager_linux_test.go` (+15 -24) 📝 `client/firewall/nftables/manager_linux_test.go` (+11 -20) 📝 `client/firewall/uspfilter/forwarder/forwarder.go` (+5 -7) 📝 `client/firewall/uspfilter/localip.go` (+28 -20) 📝 `client/firewall/uspfilter/localip_test.go` (+14 -35) 📝 `client/firewall/uspfilter/tracer_test.go` (+2 -5) 📝 `client/firewall/uspfilter/uspfilter.go` (+0 -6) 📝 `client/firewall/uspfilter/uspfilter_bench_test.go` (+2 -72) 📝 `client/firewall/uspfilter/uspfilter_filter_test.go` (+6 -16) 📝 `client/firewall/uspfilter/uspfilter_test.go` (+2 -18) 📝 `client/iface/bind/udp_mux_universal.go` (+1 -1) 📝 `client/iface/device/device_filter.go` (+0 -4) 📝 `client/iface/device/device_netstack.go` (+5 -1) 📝 `client/iface/device/wg_link_freebsd.go` (+9 -1) 📝 `client/iface/iface.go` (+0 -1) 📝 `client/iface/mocks/filter.go` (+0 -13) 📝 `client/iface/netstack/tun.go` (+5 -17) 📝 `client/iface/wgaddr/address.go` (+7 -8) 📝 `client/internal/acl/manager_test.go` (+7 -10) _...and 33 more files_ </details> ### 📄 Description ## Describe your changes - Use syscalls to add/remove routes on Windows - Use the routing socket to add/remove routes on BSD variants - Replace `net.IP` and `net.IPNet` with `netip.Addr` and `netip.Prefix` in `wgaddr.Address` - Fix some tests for FreeBSD - Remove "add route for gateway" and "duplicate route" logic - Add allowed route validation - Add better tests ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary > 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). --- <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 06:08:01 -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#23916